Revision 34623 branches/dal_time_support/libraries/libFMap_dal/src/org/gvsig/fmap/dal/impl/DefaultDataManager.java
DefaultDataManager.java | ||
---|---|---|
20 | 20 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
21 | 21 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
22 | 22 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
23 |
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter; |
|
23 | 24 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
24 | 25 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
25 | 26 |
import org.gvsig.fmap.dal.feature.FeatureType; |
... | ... | |
50 | 51 |
import org.gvsig.tools.operations.OperationManager; |
51 | 52 |
|
52 | 53 |
public class DefaultDataManager implements DataManager, |
53 |
DataManagerProviderServices {
|
|
54 |
DataManagerProviderServices { |
|
54 | 55 |
|
55 |
final static private String DATA_MANAGER_STORE = "Data.manager.stores";
|
|
56 |
final static private String DATA_MANAGER_STORE_DESCRIPTION = "DAL stores providers";
|
|
56 |
final static private String DATA_MANAGER_STORE = "Data.manager.stores";
|
|
57 |
final static private String DATA_MANAGER_STORE_DESCRIPTION = "DAL stores providers";
|
|
57 | 58 |
|
58 |
final static private String DATA_MANAGER_STORE_PARAMS = "Data.manager.stores.params";
|
|
59 |
final static private String DATA_MANAGER_STORE_PARAMS_DESCRIPTION = "DAL stores providers parameters";
|
|
59 |
final static private String DATA_MANAGER_STORE_PARAMS = "Data.manager.stores.params";
|
|
60 |
final static private String DATA_MANAGER_STORE_PARAMS_DESCRIPTION = "DAL stores providers parameters";
|
|
60 | 61 |
|
61 |
final static private String DATA_MANAGER_EXPLORER = "Data.manager.explorers";
|
|
62 |
final static private String DATA_MANAGER_EXPLORER_DESCRIPTION = "DAL explorers providers";
|
|
62 |
final static private String DATA_MANAGER_EXPLORER = "Data.manager.explorers";
|
|
63 |
final static private String DATA_MANAGER_EXPLORER_DESCRIPTION = "DAL explorers providers";
|
|
63 | 64 |
|
64 |
final static private String DATA_MANAGER_EXPLORER_PARAMS = "Data.manager.explorers.params";
|
|
65 |
final static private String DATA_MANAGER_EXPLORER_PARAMS_DESCRIPTION = "DAL explorer providers parameters";
|
|
65 |
final static private String DATA_MANAGER_EXPLORER_PARAMS = "Data.manager.explorers.params";
|
|
66 |
final static private String DATA_MANAGER_EXPLORER_PARAMS_DESCRIPTION = "DAL explorer providers parameters";
|
|
66 | 67 |
|
67 |
final static private String DATA_MANAGER_INDEX = "Data.manager.indexes";
|
|
68 |
final static private String DATA_MANAGER_INDEX_DESCRIPTION = "DAL index providers";
|
|
68 |
final static private String DATA_MANAGER_INDEX = "Data.manager.indexes";
|
|
69 |
final static private String DATA_MANAGER_INDEX_DESCRIPTION = "DAL index providers";
|
|
69 | 70 |
|
70 |
final static private String DATA_MANAGER_CACHE = "Data.manager.caches";
|
|
71 |
final static private String DATA_MANAGER_CACHE_DESCRIPTION = "DAL cache providers";
|
|
71 |
final static private String DATA_MANAGER_CACHE = "Data.manager.caches";
|
|
72 |
final static private String DATA_MANAGER_CACHE_DESCRIPTION = "DAL cache providers";
|
|
72 | 73 |
|
73 |
final static private String DATA_MANAGER_EXPRESION_EVALUATOR = "Data.manager.expresion.evaluator"; |
|
74 |
final static private String DATA_MANAGER_EXPRESION_EVALUATOR_DEFAULT = "default"; |
|
75 |
final static private String DATA_MANAGER_EXPRESION_EVALUATOR_DESCRIPTION = "DAL expresion evaluators."; |
|
76 |
|
|
77 |
final static private String DATA_MANAGER_STORE_FACTORY = "Data.manager.stores.factory"; |
|
78 |
final static private String DATA_MANAGER_STORE_FACTORY_DESCRIPTION = "DAL stores factories"; |
|
74 |
final static private String DATA_MANAGER_EXPRESION_EVALUATOR = "Data.manager.expresion.evaluator"; |
|
75 |
final static private String DATA_MANAGER_EXPRESION_EVALUATOR_DEFAULT = "default"; |
|
76 |
final static private String DATA_MANAGER_EXPRESION_EVALUATOR_DESCRIPTION = "DAL expresion evaluators."; |
|
79 | 77 |
|
80 |
/** This map contains the name of the default provider for each data type */
|
|
81 |
private Map defaultDataIndexProviders;
|
|
78 |
final static private String DATA_MANAGER_STORE_FACTORY = "Data.manager.stores.factory";
|
|
79 |
final static private String DATA_MANAGER_STORE_FACTORY_DESCRIPTION = "DAL stores factories";
|
|
82 | 80 |
|
83 |
public DefaultDataManager() { |
|
84 |
/* |
|
85 |
* Create te extensions point in te registry. |
|
86 |
*/ |
|
87 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE, |
|
88 |
DATA_MANAGER_STORE_DESCRIPTION); |
|
81 |
final static private String DATA_MANAGER_FEATURE_ATTTRIBUTE_GETTER = "Data.manager.feature.attribute.getter"; |
|
82 |
final static private String DATA_MANAGER_FEATURE_ATTTRIBUTE_GETTER_DESCRIPTION = "DAL feature attribute getters"; |
|
89 | 83 |
|
90 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE_PARAMS,
|
|
91 |
DATA_MANAGER_STORE_PARAMS_DESCRIPTION);
|
|
84 |
/** This map contains the name of the default provider for each data type */
|
|
85 |
private Map defaultDataIndexProviders;
|
|
92 | 86 |
|
93 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_EXPLORER, |
|
94 |
DATA_MANAGER_EXPLORER_DESCRIPTION); |
|
87 |
public DefaultDataManager() { |
|
88 |
/* |
|
89 |
* Create te extensions point in te registry. |
|
90 |
*/ |
|
91 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE, |
|
92 |
DATA_MANAGER_STORE_DESCRIPTION); |
|
95 | 93 |
|
96 |
ToolsLocator.getExtensionPointManager().add( |
|
97 |
DATA_MANAGER_EXPLORER_PARAMS, |
|
98 |
DATA_MANAGER_EXPLORER_PARAMS_DESCRIPTION); |
|
94 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE_PARAMS, |
|
95 |
DATA_MANAGER_STORE_PARAMS_DESCRIPTION); |
|
99 | 96 |
|
100 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_INDEX,
|
|
101 |
DATA_MANAGER_INDEX_DESCRIPTION);
|
|
97 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_EXPLORER,
|
|
98 |
DATA_MANAGER_EXPLORER_DESCRIPTION);
|
|
102 | 99 |
|
103 |
ToolsLocator.getExtensionPointManager().add(
|
|
104 |
DATA_MANAGER_EXPRESION_EVALUATOR,
|
|
105 |
DATA_MANAGER_EXPRESION_EVALUATOR_DESCRIPTION);
|
|
100 |
ToolsLocator.getExtensionPointManager().add(
|
|
101 |
DATA_MANAGER_EXPLORER_PARAMS,
|
|
102 |
DATA_MANAGER_EXPLORER_PARAMS_DESCRIPTION);
|
|
106 | 103 |
|
107 |
initializeIndexes();
|
|
108 |
}
|
|
104 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_INDEX,
|
|
105 |
DATA_MANAGER_INDEX_DESCRIPTION);
|
|
109 | 106 |
|
110 |
/** |
|
111 |
* |
|
112 |
* @return ResourceManager |
|
113 |
*/ |
|
107 |
ToolsLocator.getExtensionPointManager().add( |
|
108 |
DATA_MANAGER_EXPRESION_EVALUATOR, |
|
109 |
DATA_MANAGER_EXPRESION_EVALUATOR_DESCRIPTION); |
|
114 | 110 |
|
115 |
public ResourceManager getResourceManager() { |
|
116 |
return DALLocator.getResourceManager(); |
|
117 |
} |
|
111 |
initializeIndexes(); |
|
112 |
} |
|
118 | 113 |
|
119 |
public OperationManager getOperationManager() { |
|
120 |
return ToolsLocator.getOperationManager(); |
|
121 |
} |
|
114 |
/** |
|
115 |
* |
|
116 |
* @return ResourceManager |
|
117 |
*/ |
|
122 | 118 |
|
123 |
public String getTemporaryDirectory() { |
|
124 |
// FIXME Define a better tempdir solution |
|
125 |
String tmp = System.getProperty("TMP"); |
|
126 |
if (tmp == null) { |
|
127 |
tmp = System.getProperty("TEMP"); |
|
128 |
} |
|
129 |
if (tmp == null) { |
|
130 |
File tmp_file = new File(System.getProperty("HOME"), "_daltmp_"); |
|
131 |
int i = 1; |
|
132 |
while (!tmp_file.exists() || !tmp_file.isDirectory()) { |
|
133 |
tmp_file = new File(tmp_file.getAbsolutePath() + i); |
|
134 |
i++; |
|
135 |
} |
|
136 |
if (!tmp_file.exists()) { |
|
137 |
tmp_file.mkdir(); |
|
138 |
} |
|
139 |
tmp = tmp_file.getAbsolutePath(); |
|
140 |
} |
|
141 |
return tmp; |
|
142 |
} |
|
119 |
public ResourceManager getResourceManager() { |
|
120 |
return DALLocator.getResourceManager(); |
|
121 |
} |
|
143 | 122 |
|
144 |
/* |
|
145 |
* ==================================================================== |
|
146 |
* |
|
147 |
* Store related services |
|
148 |
*/ |
|
149 |
public void registerStoreProvider(String name, Class storeProviderClass, |
|
150 |
Class parametersClass) { |
|
151 |
if (name == null || storeProviderClass == null |
|
152 |
|| parametersClass == null) { |
|
153 |
// FIXME Exception |
|
154 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
155 |
} |
|
123 |
public OperationManager getOperationManager() { |
|
124 |
return ToolsLocator.getOperationManager(); |
|
125 |
} |
|
156 | 126 |
|
157 |
if (!DataStoreParameters.class.isAssignableFrom(parametersClass)) { |
|
158 |
// FIXME Exception |
|
159 |
throw new IllegalArgumentException(parametersClass.getName() |
|
160 |
+ " must implement org.gvsig.fmap.dal.DataStoreParameters"); |
|
161 |
} |
|
127 |
public String getTemporaryDirectory() { |
|
128 |
// FIXME Define a better tempdir solution |
|
129 |
String tmp = System.getProperty("TMP"); |
|
130 |
if (tmp == null) { |
|
131 |
tmp = System.getProperty("TEMP"); |
|
132 |
} |
|
133 |
if (tmp == null) { |
|
134 |
File tmp_file = new File(System.getProperty("HOME"), "_daltmp_"); |
|
135 |
int i = 1; |
|
136 |
while (!tmp_file.exists() || !tmp_file.isDirectory()) { |
|
137 |
tmp_file = new File(tmp_file.getAbsolutePath() + i); |
|
138 |
i++; |
|
139 |
} |
|
140 |
if (!tmp_file.exists()) { |
|
141 |
tmp_file.mkdir(); |
|
142 |
} |
|
143 |
tmp = tmp_file.getAbsolutePath(); |
|
144 |
} |
|
145 |
return tmp; |
|
146 |
} |
|
162 | 147 |
|
163 |
if (CoverageStoreProvider.class.isAssignableFrom(storeProviderClass)) { |
|
148 |
/* |
|
149 |
* ==================================================================== |
|
150 |
* |
|
151 |
* Store related services |
|
152 |
*/ |
|
153 |
public void registerStoreProvider(String name, Class storeProviderClass, |
|
154 |
Class parametersClass) { |
|
155 |
if (name == null || storeProviderClass == null |
|
156 |
|| parametersClass == null) { |
|
157 |
// FIXME Exception |
|
158 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
159 |
} |
|
164 | 160 |
|
165 |
} else if (FeatureStoreProvider.class |
|
166 |
.isAssignableFrom(storeProviderClass)) { |
|
161 |
if (!DataStoreParameters.class.isAssignableFrom(parametersClass)) { |
|
162 |
// FIXME Exception |
|
163 |
throw new IllegalArgumentException(parametersClass.getName() |
|
164 |
+ " must implement org.gvsig.fmap.dal.DataStoreParameters"); |
|
165 |
} |
|
167 | 166 |
|
168 |
} else { |
|
169 |
// FIXME Exception |
|
170 |
throw new IllegalArgumentException( |
|
171 |
"Not supported implemtation: name=" + name |
|
172 |
+ " provider class=" + storeProviderClass.getName()); |
|
173 |
} |
|
167 |
if (CoverageStoreProvider.class.isAssignableFrom(storeProviderClass)) { |
|
174 | 168 |
|
175 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE, |
|
176 |
DATA_MANAGER_STORE_DESCRIPTION).append(name, null, |
|
177 |
storeProviderClass); |
|
169 |
} else if (FeatureStoreProvider.class |
|
170 |
.isAssignableFrom(storeProviderClass)) { |
|
178 | 171 |
|
179 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE_PARAMS, |
|
180 |
DATA_MANAGER_STORE_PARAMS_DESCRIPTION).append(name, null, |
|
181 |
parametersClass); |
|
182 |
} |
|
183 |
|
|
184 |
/* |
|
185 |
* (non-Javadoc) |
|
186 |
* @see org.gvsig.fmap.dal.spi.DataManagerProviderServices#registerStoreFactory(java.lang.String, java.lang.Class) |
|
187 |
*/ |
|
188 |
public void registerStoreFactory(String name, Class storeProviderClass) { |
|
189 |
if (name == null || storeProviderClass == null) { |
|
190 |
// FIXME Exception |
|
191 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
192 |
} |
|
172 |
} else { |
|
173 |
// FIXME Exception |
|
174 |
throw new IllegalArgumentException( |
|
175 |
"Not supported implemtation: name=" + name |
|
176 |
+ " provider class=" + storeProviderClass.getName()); |
|
177 |
} |
|
193 | 178 |
|
194 |
if(!(DataStoreFactory.class.isAssignableFrom(storeProviderClass))) { |
|
195 |
// FIXME Exception |
|
196 |
throw new IllegalArgumentException( |
|
197 |
"Not supported implemtation: name=" + name |
|
198 |
+ " provider class=" + storeProviderClass.getName()); |
|
199 |
} |
|
179 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE, |
|
180 |
DATA_MANAGER_STORE_DESCRIPTION).append(name, null, |
|
181 |
storeProviderClass); |
|
200 | 182 |
|
201 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE_FACTORY,
|
|
202 |
DATA_MANAGER_STORE_FACTORY_DESCRIPTION).append(name, null,
|
|
203 |
storeProviderClass);
|
|
204 |
}
|
|
183 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE_PARAMS,
|
|
184 |
DATA_MANAGER_STORE_PARAMS_DESCRIPTION).append(name, null,
|
|
185 |
parametersClass);
|
|
186 |
}
|
|
205 | 187 |
|
206 |
public DataStoreParameters createStoreParameters(String name) |
|
207 |
throws InitializeException, ProviderNotRegisteredException { |
|
208 |
try { |
|
209 |
DataStoreParameters params = (DataStoreParameters) ToolsLocator |
|
210 |
.getExtensionPointManager().get(DATA_MANAGER_STORE_PARAMS) |
|
211 |
.create(name); |
|
212 |
if (params == null) { |
|
213 |
throw new ProviderNotRegisteredException(name); |
|
214 |
} |
|
215 |
return params; |
|
216 |
} catch (InstantiationException e) { |
|
217 |
throw new InitializeException(e); |
|
218 |
} catch (IllegalAccessException e) { |
|
219 |
throw new InitializeException(e); |
|
220 |
} catch (SecurityException e) { |
|
221 |
throw new InitializeException(e); |
|
222 |
} catch (IllegalArgumentException e) { |
|
223 |
throw new InitializeException(e); |
|
224 |
} |
|
225 |
} |
|
188 |
/* |
|
189 |
* (non-Javadoc) |
|
190 |
* @see org.gvsig.fmap.dal.spi.DataManagerProviderServices#registerStoreFactory(java.lang.String, java.lang.Class) |
|
191 |
*/ |
|
192 |
public void registerStoreFactory(String name, Class storeProviderClass) { |
|
193 |
if (name == null || storeProviderClass == null) { |
|
194 |
// FIXME Exception |
|
195 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
196 |
} |
|
226 | 197 |
|
227 |
public DataStore openStore(String provider, DataStoreParameters parameters) |
|
228 |
throws InitializeException, ProviderNotRegisteredException, |
|
229 |
ValidateDataParametersException { |
|
230 |
String name = provider; //parameters.getDataStoreName(); |
|
198 |
if(!(DataStoreFactory.class.isAssignableFrom(storeProviderClass))) { |
|
199 |
// FIXME Exception |
|
200 |
throw new IllegalArgumentException( |
|
201 |
"Not supported implemtation: name=" + name |
|
202 |
+ " provider class=" + storeProviderClass.getName()); |
|
203 |
} |
|
231 | 204 |
|
232 |
parameters.validate(); |
|
205 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_STORE_FACTORY, |
|
206 |
DATA_MANAGER_STORE_FACTORY_DESCRIPTION).append(name, null, |
|
207 |
storeProviderClass); |
|
208 |
} |
|
233 | 209 |
|
234 |
DataStore store; |
|
235 |
Extension storeProviderExtension = ToolsLocator |
|
236 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).get(name); |
|
210 |
public DataStoreParameters createStoreParameters(String name) |
|
211 |
throws InitializeException, ProviderNotRegisteredException { |
|
212 |
try { |
|
213 |
DataStoreParameters params = (DataStoreParameters) ToolsLocator |
|
214 |
.getExtensionPointManager().get(DATA_MANAGER_STORE_PARAMS) |
|
215 |
.create(name); |
|
216 |
if (params == null) { |
|
217 |
throw new ProviderNotRegisteredException(name); |
|
218 |
} |
|
219 |
return params; |
|
220 |
} catch (InstantiationException e) { |
|
221 |
throw new InitializeException(e); |
|
222 |
} catch (IllegalAccessException e) { |
|
223 |
throw new InitializeException(e); |
|
224 |
} catch (SecurityException e) { |
|
225 |
throw new InitializeException(e); |
|
226 |
} catch (IllegalArgumentException e) { |
|
227 |
throw new InitializeException(e); |
|
228 |
} |
|
229 |
} |
|
237 | 230 |
|
238 |
if (storeProviderExtension == null) { |
|
239 |
throw new ProviderNotRegisteredException(name); |
|
240 |
} |
|
231 |
public DataStore openStore(String provider, DataStoreParameters parameters) |
|
232 |
throws InitializeException, ProviderNotRegisteredException, |
|
233 |
ValidateDataParametersException { |
|
234 |
String name = provider; //parameters.getDataStoreName(); |
|
241 | 235 |
|
242 |
Class providerClass = storeProviderExtension.getExtension(); |
|
243 |
if (providerClass == null) { |
|
244 |
throw new ProviderNotRegisteredException(name); |
|
245 |
} |
|
236 |
parameters.validate(); |
|
246 | 237 |
|
247 |
if (CoverageStoreProvider.class.isAssignableFrom(providerClass)) { |
|
248 |
ExtensionPoint.Extension point = ToolsLocator.getExtensionPointManager(). |
|
249 |
get(DATA_MANAGER_STORE_FACTORY).get(name); |
|
250 |
DataStoreFactory factory = null; |
|
251 |
try { |
|
252 |
factory = (DataStoreFactory)point.create(); |
|
253 |
} catch (InstantiationException e) { |
|
254 |
throw new InitializeException(e); |
|
255 |
} catch (IllegalAccessException e) { |
|
256 |
throw new InitializeException(e); |
|
257 |
} |
|
258 |
factory.setParameters(parameters); |
|
259 |
store = factory.createStore(); |
|
260 |
} else if (FeatureStoreProvider.class.isAssignableFrom(providerClass)) { |
|
238 |
DataStore store; |
|
239 |
Extension storeProviderExtension = ToolsLocator |
|
240 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).get(name); |
|
261 | 241 |
|
262 |
store = new DefaultFeatureStore(); |
|
242 |
if (storeProviderExtension == null) { |
|
243 |
throw new ProviderNotRegisteredException(name); |
|
244 |
} |
|
263 | 245 |
|
264 |
} else { |
|
265 |
// FIXME Exception |
|
266 |
throw new InitializeException(name, new RuntimeException( |
|
267 |
"Not supported implemtation: name=" + name |
|
268 |
+ " provider class=" + providerClass.getName())); |
|
269 |
} |
|
246 |
Class providerClass = storeProviderExtension.getExtension(); |
|
247 |
if (providerClass == null) { |
|
248 |
throw new ProviderNotRegisteredException(name); |
|
249 |
} |
|
270 | 250 |
|
271 |
this.intializeDataStore((DataStoreImplementation) store, parameters); |
|
251 |
if (CoverageStoreProvider.class.isAssignableFrom(providerClass)) { |
|
252 |
ExtensionPoint.Extension point = ToolsLocator.getExtensionPointManager(). |
|
253 |
get(DATA_MANAGER_STORE_FACTORY).get(name); |
|
254 |
DataStoreFactory factory = null; |
|
255 |
try { |
|
256 |
factory = (DataStoreFactory)point.create(); |
|
257 |
} catch (InstantiationException e) { |
|
258 |
throw new InitializeException(e); |
|
259 |
} catch (IllegalAccessException e) { |
|
260 |
throw new InitializeException(e); |
|
261 |
} |
|
262 |
factory.setParameters(parameters); |
|
263 |
store = factory.createStore(); |
|
264 |
} else if (FeatureStoreProvider.class.isAssignableFrom(providerClass)) { |
|
272 | 265 |
|
273 |
return store; |
|
274 |
} |
|
266 |
store = new DefaultFeatureStore(); |
|
275 | 267 |
|
276 |
/** |
|
277 |
* @deprecated see openStore |
|
278 |
*/ |
|
279 |
public DataStore createStore(DataStoreParameters parameters) |
|
280 |
throws InitializeException, ProviderNotRegisteredException, |
|
281 |
ValidateDataParametersException { |
|
282 |
return openStore(parameters.getDataStoreName(), parameters); |
|
283 |
} |
|
268 |
} else { |
|
269 |
// FIXME Exception |
|
270 |
throw new InitializeException(name, new RuntimeException( |
|
271 |
"Not supported implemtation: name=" + name |
|
272 |
+ " provider class=" + providerClass.getName())); |
|
273 |
} |
|
284 | 274 |
|
285 |
public List getStoreProviders() { |
|
286 |
return ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_STORE) |
|
287 |
.getNames(); |
|
288 |
} |
|
275 |
this.intializeDataStore((DataStoreImplementation) store, parameters); |
|
289 | 276 |
|
290 |
public List getStoreProviders(String name) { |
|
291 |
return getStoreProviders(); // FIXME: need filter from the name of |
|
292 |
// the explorer |
|
293 |
} |
|
277 |
return store; |
|
278 |
} |
|
294 | 279 |
|
295 |
public NewDataStoreParameters createNewStoreParameters(String explorer, |
|
296 |
String provider) throws InitializeException, |
|
297 |
ProviderNotRegisteredException { |
|
280 |
/** |
|
281 |
* @deprecated see openStore |
|
282 |
*/ |
|
283 |
public DataStore createStore(DataStoreParameters parameters) |
|
284 |
throws InitializeException, ProviderNotRegisteredException, |
|
285 |
ValidateDataParametersException { |
|
286 |
return openStore(parameters.getDataStoreName(), parameters); |
|
287 |
} |
|
298 | 288 |
|
299 |
DataServerExplorerParameters parameters; |
|
300 |
DataServerExplorer server; |
|
301 |
try { |
|
302 |
parameters = this.createServerExplorerParameters(explorer); |
|
303 |
server = this.openServerExplorerWithoutValidate(explorer, parameters); |
|
304 |
return server.getAddParameters(provider); |
|
305 |
} catch (ValidateDataParametersException e) { |
|
306 |
throw new InitializeException(e); |
|
307 |
} catch (DataException e) { |
|
308 |
throw new InitializeException(e); |
|
309 |
} |
|
310 |
} |
|
289 |
public List getStoreProviders() { |
|
290 |
return ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_STORE) |
|
291 |
.getNames(); |
|
292 |
} |
|
311 | 293 |
|
312 |
public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite) |
|
313 |
throws InitializeException, ProviderNotRegisteredException, |
|
314 |
ValidateDataParametersException { |
|
294 |
public List getStoreProviders(String name) { |
|
295 |
return getStoreProviders(); // FIXME: need filter from the name of |
|
296 |
// the explorer |
|
297 |
} |
|
315 | 298 |
|
316 |
DataServerExplorerParameters explorerParameters; |
|
317 |
DataServerExplorer server; |
|
318 |
explorerParameters = this.createServerExplorerParameters(explorer); |
|
319 |
server = this.openServerExplorerWithoutValidate(explorer, explorerParameters); |
|
320 |
try { |
|
321 |
server.add(provider, parameters, overwrite); |
|
322 |
} catch (DataException e) { |
|
323 |
throw new InitializeException(e); |
|
324 |
} |
|
325 |
} |
|
299 |
public NewDataStoreParameters createNewStoreParameters(String explorer, |
|
300 |
String provider) throws InitializeException, |
|
301 |
ProviderNotRegisteredException { |
|
326 | 302 |
|
327 |
/* |
|
328 |
* ==================================================================== |
|
329 |
* |
|
330 |
* Explorer related services |
|
331 |
*/ |
|
332 |
public void registerExplorerProvider(String name, Class explorerClass, |
|
333 |
Class parametersClass) { |
|
303 |
DataServerExplorerParameters parameters; |
|
304 |
DataServerExplorer server; |
|
305 |
try { |
|
306 |
parameters = this.createServerExplorerParameters(explorer); |
|
307 |
server = this.openServerExplorerWithoutValidate(explorer, parameters); |
|
308 |
return server.getAddParameters(provider); |
|
309 |
} catch (ValidateDataParametersException e) { |
|
310 |
throw new InitializeException(e); |
|
311 |
} catch (DataException e) { |
|
312 |
throw new InitializeException(e); |
|
313 |
} |
|
314 |
} |
|
334 | 315 |
|
335 |
if (name == null || explorerClass == null || parametersClass == null) { |
|
336 |
// FIXME Exception |
|
337 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
338 |
} |
|
316 |
public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite) |
|
317 |
throws InitializeException, ProviderNotRegisteredException, |
|
318 |
ValidateDataParametersException { |
|
339 | 319 |
|
340 |
if (!DataServerExplorerParameters.class |
|
341 |
.isAssignableFrom(parametersClass)) { |
|
342 |
// FIXME Exception |
|
343 |
throw new IllegalArgumentException( |
|
344 |
parametersClass.getName() |
|
345 |
+ " must implement org.gvsig.fmap.dal.DataServerExplorerParameters"); |
|
346 |
} |
|
320 |
DataServerExplorerParameters explorerParameters; |
|
321 |
DataServerExplorer server; |
|
322 |
explorerParameters = this.createServerExplorerParameters(explorer); |
|
323 |
server = this.openServerExplorerWithoutValidate(explorer, explorerParameters); |
|
324 |
try { |
|
325 |
server.add(provider, parameters, overwrite); |
|
326 |
} catch (DataException e) { |
|
327 |
throw new InitializeException(e); |
|
328 |
} |
|
329 |
} |
|
347 | 330 |
|
348 |
if (!DataServerExplorer.class.isAssignableFrom(explorerClass)) { |
|
349 |
// FIXME Exception |
|
350 |
throw new IllegalArgumentException(explorerClass.getName() |
|
351 |
+ " must implement org.gvsig.fmap.dal.DataServerExplorer"); |
|
352 |
} |
|
331 |
/* |
|
332 |
* ==================================================================== |
|
333 |
* |
|
334 |
* Explorer related services |
|
335 |
*/ |
|
336 |
public void registerExplorerProvider(String name, Class explorerClass, |
|
337 |
Class parametersClass) { |
|
353 | 338 |
|
354 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_EXPLORER, |
|
355 |
DATA_MANAGER_EXPLORER_DESCRIPTION).append(name, null, |
|
356 |
explorerClass); |
|
339 |
if (name == null || explorerClass == null || parametersClass == null) { |
|
340 |
// FIXME Exception |
|
341 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
342 |
} |
|
357 | 343 |
|
358 |
ToolsLocator.getExtensionPointManager().add( |
|
359 |
DATA_MANAGER_EXPLORER_PARAMS, |
|
360 |
DATA_MANAGER_EXPLORER_PARAMS_DESCRIPTION).append(name, null, |
|
361 |
parametersClass); |
|
362 |
} |
|
344 |
if (!DataServerExplorerParameters.class |
|
345 |
.isAssignableFrom(parametersClass)) { |
|
346 |
// FIXME Exception |
|
347 |
throw new IllegalArgumentException( |
|
348 |
parametersClass.getName() |
|
349 |
+ " must implement org.gvsig.fmap.dal.DataServerExplorerParameters"); |
|
350 |
} |
|
363 | 351 |
|
364 |
public DataServerExplorerParameters createServerExplorerParameters( |
|
365 |
String name) throws InitializeException, |
|
366 |
ProviderNotRegisteredException { |
|
367 |
try { |
|
368 |
DataServerExplorerParameters params = (DataServerExplorerParameters) ToolsLocator |
|
369 |
.getExtensionPointManager().get( |
|
370 |
DATA_MANAGER_EXPLORER_PARAMS).create(name); |
|
371 |
if (params == null) { |
|
372 |
throw new ProviderNotRegisteredException(name); |
|
373 |
} |
|
374 |
return params; |
|
375 |
} catch (InstantiationException e) { |
|
376 |
throw new InitializeException(e); |
|
377 |
} catch (IllegalAccessException e) { |
|
378 |
throw new InitializeException(e); |
|
379 |
} catch (SecurityException e) { |
|
380 |
throw new InitializeException(e); |
|
381 |
} catch (IllegalArgumentException e) { |
|
382 |
throw new InitializeException(e); |
|
383 |
} |
|
384 |
} |
|
352 |
if (!DataServerExplorer.class.isAssignableFrom(explorerClass)) { |
|
353 |
// FIXME Exception |
|
354 |
throw new IllegalArgumentException(explorerClass.getName() |
|
355 |
+ " must implement org.gvsig.fmap.dal.DataServerExplorer"); |
|
356 |
} |
|
385 | 357 |
|
386 |
public DataServerExplorer openServerExplorer( |
|
387 |
String explorer, |
|
388 |
DataServerExplorerParameters parameters) |
|
389 |
throws InitializeException, ProviderNotRegisteredException, |
|
390 |
ValidateDataParametersException { |
|
358 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_EXPLORER, |
|
359 |
DATA_MANAGER_EXPLORER_DESCRIPTION).append(name, null, |
|
360 |
explorerClass); |
|
391 | 361 |
|
392 |
if( parameters != null ) {
|
|
393 |
parameters.validate();
|
|
394 |
}
|
|
395 |
return this.openServerExplorerWithoutValidate(explorer, parameters);
|
|
396 |
}
|
|
362 |
ToolsLocator.getExtensionPointManager().add(
|
|
363 |
DATA_MANAGER_EXPLORER_PARAMS,
|
|
364 |
DATA_MANAGER_EXPLORER_PARAMS_DESCRIPTION).append(name, null,
|
|
365 |
parametersClass);
|
|
366 |
}
|
|
397 | 367 |
|
398 |
private DataServerExplorer openServerExplorerWithoutValidate( |
|
399 |
String explorerName, |
|
400 |
DataServerExplorerParameters parameters) |
|
401 |
throws InitializeException, ProviderNotRegisteredException, |
|
402 |
ValidateDataParametersException { |
|
368 |
public DataServerExplorerParameters createServerExplorerParameters( |
|
369 |
String name) throws InitializeException, |
|
370 |
ProviderNotRegisteredException { |
|
371 |
try { |
|
372 |
DataServerExplorerParameters params = (DataServerExplorerParameters) ToolsLocator |
|
373 |
.getExtensionPointManager().get( |
|
374 |
DATA_MANAGER_EXPLORER_PARAMS).create(name); |
|
375 |
if (params == null) { |
|
376 |
throw new ProviderNotRegisteredException(name); |
|
377 |
} |
|
378 |
return params; |
|
379 |
} catch (InstantiationException e) { |
|
380 |
throw new InitializeException(e); |
|
381 |
} catch (IllegalAccessException e) { |
|
382 |
throw new InitializeException(e); |
|
383 |
} catch (SecurityException e) { |
|
384 |
throw new InitializeException(e); |
|
385 |
} catch (IllegalArgumentException e) { |
|
386 |
throw new InitializeException(e); |
|
387 |
} |
|
388 |
} |
|
403 | 389 |
|
404 |
String name = explorerName; //parameters.getExplorerName(); |
|
390 |
public DataServerExplorer openServerExplorer( |
|
391 |
String explorer, |
|
392 |
DataServerExplorerParameters parameters) |
|
393 |
throws InitializeException, ProviderNotRegisteredException, |
|
394 |
ValidateDataParametersException { |
|
405 | 395 |
|
406 |
try { |
|
407 |
DataServerExplorerProvider server = (DataServerExplorerProvider) ToolsLocator |
|
408 |
.getExtensionPointManager() |
|
409 |
.get(DATA_MANAGER_EXPLORER) |
|
410 |
.create( |
|
411 |
name, |
|
412 |
new Object[] { |
|
413 |
parameters, |
|
414 |
new DefaultDataServerExplorerProviderServices() }); |
|
415 |
if (server == null) { |
|
416 |
throw new ProviderNotRegisteredException(name); |
|
417 |
} |
|
418 |
return server; |
|
419 |
} catch (InstantiationException e) { |
|
420 |
throw new InitializeException(e); |
|
421 |
} catch (IllegalAccessException e) { |
|
422 |
throw new InitializeException(e); |
|
423 |
} catch (SecurityException e) { |
|
424 |
throw new InitializeException(e); |
|
425 |
} catch (IllegalArgumentException e) { |
|
426 |
throw new InitializeException(e); |
|
427 |
} catch (NoSuchMethodException e) { |
|
428 |
throw new InitializeException(e); |
|
429 |
} catch (InvocationTargetException e) { |
|
430 |
throw new InitializeException(e); |
|
431 |
} |
|
432 |
} |
|
396 |
if( parameters != null ) { |
|
397 |
parameters.validate(); |
|
398 |
} |
|
399 |
return this.openServerExplorerWithoutValidate(explorer, parameters); |
|
400 |
} |
|
433 | 401 |
|
434 |
/** |
|
435 |
* @deprecated see openServerExplorer |
|
436 |
*/ |
|
437 |
public DataServerExplorer createServerExplorer( |
|
438 |
DataServerExplorerParameters parameters) |
|
439 |
throws InitializeException, ProviderNotRegisteredException, |
|
440 |
ValidateDataParametersException { |
|
441 |
return openServerExplorer(parameters.getExplorerName(), parameters); |
|
442 |
} |
|
402 |
private DataServerExplorer openServerExplorerWithoutValidate( |
|
403 |
String explorerName, |
|
404 |
DataServerExplorerParameters parameters) |
|
405 |
throws InitializeException, ProviderNotRegisteredException, |
|
406 |
ValidateDataParametersException { |
|
443 | 407 |
|
444 |
public List getExplorerProviders() { |
|
445 |
return ToolsLocator.getExtensionPointManager().get( |
|
446 |
DATA_MANAGER_EXPLORER).getNames(); |
|
447 |
} |
|
408 |
String name = explorerName; //parameters.getExplorerName(); |
|
448 | 409 |
|
449 |
/* |
|
450 |
* ==================================================================== |
|
451 |
* |
|
452 |
* Expresion evaluation related services |
|
453 |
*/ |
|
454 |
public Evaluator createExpresion(String expresion) |
|
455 |
throws InitializeException { |
|
456 |
try { |
|
457 |
return (Evaluator) ToolsLocator.getExtensionPointManager().get( |
|
458 |
DATA_MANAGER_EXPRESION_EVALUATOR).create( |
|
459 |
DATA_MANAGER_EXPRESION_EVALUATOR_DEFAULT, |
|
460 |
new Object[] { expresion }); |
|
461 |
} catch (SecurityException e) { |
|
462 |
throw new InitializeException(e); |
|
463 |
} catch (IllegalArgumentException e) { |
|
464 |
throw new InitializeException(e); |
|
465 |
} catch (NoSuchMethodException e) { |
|
466 |
throw new InitializeException(e); |
|
467 |
} catch (InstantiationException e) { |
|
468 |
throw new InitializeException(e); |
|
469 |
} catch (IllegalAccessException e) { |
|
470 |
throw new InitializeException(e); |
|
471 |
} catch (InvocationTargetException e) { |
|
472 |
throw new InitializeException(e); |
|
473 |
} |
|
474 |
} |
|
410 |
try { |
|
411 |
DataServerExplorerProvider server = (DataServerExplorerProvider) ToolsLocator |
|
412 |
.getExtensionPointManager() |
|
413 |
.get(DATA_MANAGER_EXPLORER) |
|
414 |
.create( |
|
415 |
name, |
|
416 |
new Object[] { |
|
417 |
parameters, |
|
418 |
new DefaultDataServerExplorerProviderServices() }); |
|
419 |
if (server == null) { |
|
420 |
throw new ProviderNotRegisteredException(name); |
|
421 |
} |
|
422 |
return server; |
|
423 |
} catch (InstantiationException e) { |
|
424 |
throw new InitializeException(e); |
|
425 |
} catch (IllegalAccessException e) { |
|
426 |
throw new InitializeException(e); |
|
427 |
} catch (SecurityException e) { |
|
428 |
throw new InitializeException(e); |
|
429 |
} catch (IllegalArgumentException e) { |
|
430 |
throw new InitializeException(e); |
|
431 |
} catch (NoSuchMethodException e) { |
|
432 |
throw new InitializeException(e); |
|
433 |
} catch (InvocationTargetException e) { |
|
434 |
throw new InitializeException(e); |
|
435 |
} |
|
436 |
} |
|
475 | 437 |
|
476 |
public void registerDefaultEvaluator(Class evaluatorClass) { |
|
477 |
if (!Evaluator.class.isAssignableFrom(evaluatorClass)) { |
|
478 |
throw new ClassCastException(); |
|
479 |
} |
|
480 |
ToolsLocator.getExtensionPointManager().add( |
|
481 |
DATA_MANAGER_EXPRESION_EVALUATOR, |
|
482 |
DATA_MANAGER_EXPRESION_EVALUATOR_DESCRIPTION).append( |
|
483 |
DATA_MANAGER_EXPRESION_EVALUATOR_DEFAULT, |
|
484 |
"Default expresion evaluator for use in DAL", evaluatorClass); |
|
485 |
} |
|
438 |
/** |
|
439 |
* @deprecated see openServerExplorer |
|
440 |
*/ |
|
441 |
public DataServerExplorer createServerExplorer( |
|
442 |
DataServerExplorerParameters parameters) |
|
443 |
throws InitializeException, ProviderNotRegisteredException, |
|
444 |
ValidateDataParametersException { |
|
445 |
return openServerExplorer(parameters.getExplorerName(), parameters); |
|
446 |
} |
|
486 | 447 |
|
487 |
/* |
|
488 |
* ==================================================================== |
|
489 |
* |
|
490 |
* Index related services |
|
491 |
*/ |
|
448 |
public List getExplorerProviders() { |
|
449 |
return ToolsLocator.getExtensionPointManager().get( |
|
450 |
DATA_MANAGER_EXPLORER).getNames(); |
|
451 |
} |
|
492 | 452 |
|
493 |
public List getFeatureIndexProviders() { |
|
494 |
return ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_INDEX) |
|
495 |
.getNames(); |
|
496 |
} |
|
453 |
/* |
|
454 |
* ==================================================================== |
|
455 |
* |
|
456 |
* Expresion evaluation related services |
|
457 |
*/ |
|
458 |
public Evaluator createExpresion(String expresion) |
|
459 |
throws InitializeException { |
|
460 |
try { |
|
461 |
return (Evaluator) ToolsLocator.getExtensionPointManager().get( |
|
462 |
DATA_MANAGER_EXPRESION_EVALUATOR).create( |
|
463 |
DATA_MANAGER_EXPRESION_EVALUATOR_DEFAULT, |
|
464 |
new Object[] { expresion }); |
|
465 |
} catch (SecurityException e) { |
|
466 |
throw new InitializeException(e); |
|
467 |
} catch (IllegalArgumentException e) { |
|
468 |
throw new InitializeException(e); |
|
469 |
} catch (NoSuchMethodException e) { |
|
470 |
throw new InitializeException(e); |
|
471 |
} catch (InstantiationException e) { |
|
472 |
throw new InitializeException(e); |
|
473 |
} catch (IllegalAccessException e) { |
|
474 |
throw new InitializeException(e); |
|
475 |
} catch (InvocationTargetException e) { |
|
476 |
throw new InitializeException(e); |
|
477 |
} |
|
478 |
} |
|
497 | 479 |
|
498 |
public void setDefaultFeatureIndexProviderName(int dataType, String name) { |
|
499 |
defaultDataIndexProviders.put(new Integer(dataType), name); |
|
500 |
} |
|
480 |
public void registerDefaultEvaluator(Class evaluatorClass) { |
|
481 |
if (!Evaluator.class.isAssignableFrom(evaluatorClass)) { |
|
482 |
throw new ClassCastException(); |
|
483 |
} |
|
484 |
ToolsLocator.getExtensionPointManager().add( |
|
485 |
DATA_MANAGER_EXPRESION_EVALUATOR, |
|
486 |
DATA_MANAGER_EXPRESION_EVALUATOR_DESCRIPTION).append( |
|
487 |
DATA_MANAGER_EXPRESION_EVALUATOR_DEFAULT, |
|
488 |
"Default expresion evaluator for use in DAL", evaluatorClass); |
|
489 |
} |
|
501 | 490 |
|
502 |
public String getDefaultFeatureIndexProviderName(int dataType) { |
|
503 |
return (String) defaultDataIndexProviders.get(new Integer(dataType)); |
|
504 |
} |
|
491 |
/* |
|
492 |
* ==================================================================== |
|
493 |
* |
|
494 |
* Index related services |
|
495 |
*/ |
|
505 | 496 |
|
506 |
public FeatureIndexProviderServices createFeatureIndexProvider(String name,
|
|
507 |
FeatureStore store, FeatureType type, String indexName,
|
|
508 |
FeatureAttributeDescriptor attr) throws InitializeException,
|
|
509 |
ProviderNotRegisteredException {
|
|
497 |
public List getFeatureIndexProviders() {
|
|
498 |
return ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_INDEX)
|
|
499 |
.getNames();
|
|
500 |
}
|
|
510 | 501 |
|
511 |
if (name == null) {
|
|
512 |
name = getDefaultFeatureIndexProviderName(attr.getType());
|
|
513 |
}
|
|
502 |
public void setDefaultFeatureIndexProviderName(int dataType, String name) {
|
|
503 |
defaultDataIndexProviders.put(new Integer(dataType), name);
|
|
504 |
}
|
|
514 | 505 |
|
515 |
if (name == null) { |
|
516 |
throw new InitializeException( |
|
517 |
"There not any index provider registered.", null); |
|
518 |
} |
|
506 |
public String getDefaultFeatureIndexProviderName(int dataType) { |
|
507 |
return (String) defaultDataIndexProviders.get(new Integer(dataType)); |
|
508 |
} |
|
519 | 509 |
|
520 |
try { |
|
521 |
FeatureIndexProvider provider = (FeatureIndexProvider) ToolsLocator |
|
522 |
.getExtensionPointManager().get(DATA_MANAGER_INDEX).create( |
|
523 |
name); |
|
524 |
if (provider == null) { |
|
525 |
throw new ProviderNotRegisteredException(name); |
|
526 |
} |
|
527 |
FeatureIndexProviderServices services = new DefaultFeatureIndex( |
|
528 |
(FeatureStoreProviderServices) store, type, provider, attr |
|
529 |
.getName(), indexName); |
|
530 |
services.initialize(); |
|
531 |
return services; |
|
532 |
} catch (InstantiationException e) { |
|
533 |
throw new InitializeException(e); |
|
534 |
} catch (IllegalAccessException e) { |
|
535 |
throw new InitializeException(e); |
|
536 |
} catch (SecurityException e) { |
|
537 |
throw new InitializeException(e); |
|
538 |
} catch (IllegalArgumentException e) { |
|
539 |
throw new InitializeException(e); |
|
540 |
} |
|
541 |
} |
|
510 |
public FeatureIndexProviderServices createFeatureIndexProvider(String name, |
|
511 |
FeatureStore store, FeatureType type, String indexName, |
|
512 |
FeatureAttributeDescriptor attr) throws InitializeException, |
|
513 |
ProviderNotRegisteredException { |
|
542 | 514 |
|
543 |
public void registerFeatureIndexProvider(String name, String description, |
|
544 |
Class clazz, int dataType) { |
|
545 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_INDEX, |
|
546 |
DATA_MANAGER_INDEX_DESCRIPTION).append(name, null, clazz); |
|
515 |
if (name == null) { |
|
516 |
name = getDefaultFeatureIndexProviderName(attr.getType()); |
|
517 |
} |
|
547 | 518 |
|
548 |
if (getDefaultFeatureIndexProviderName(dataType) == null) {
|
|
549 |
setDefaultFeatureIndexProviderName(dataType, name);
|
|
550 |
}
|
|
551 |
}
|
|
519 |
if (name == null) {
|
|
520 |
throw new InitializeException(
|
|
521 |
"There not any index provider registered.", null);
|
|
522 |
}
|
|
552 | 523 |
|
553 |
private void initializeIndexes() { |
|
554 |
this.defaultDataIndexProviders = new HashMap(); |
|
555 |
} |
|
524 |
try { |
|
525 |
FeatureIndexProvider provider = (FeatureIndexProvider) ToolsLocator |
|
526 |
.getExtensionPointManager().get(DATA_MANAGER_INDEX).create( |
|
527 |
name); |
|
528 |
if (provider == null) { |
|
529 |
throw new ProviderNotRegisteredException(name); |
|
530 |
} |
|
531 |
FeatureIndexProviderServices services = new DefaultFeatureIndex( |
|
532 |
(FeatureStoreProviderServices) store, type, provider, attr |
|
533 |
.getName(), indexName); |
|
534 |
services.initialize(); |
|
535 |
return services; |
|
536 |
} catch (InstantiationException e) { |
|
537 |
throw new InitializeException(e); |
|
538 |
} catch (IllegalAccessException e) { |
|
539 |
throw new InitializeException(e); |
|
540 |
} catch (SecurityException e) { |
|
541 |
throw new InitializeException(e); |
|
542 |
} catch (IllegalArgumentException e) { |
|
543 |
throw new InitializeException(e); |
|
544 |
} |
|
545 |
} |
|
556 | 546 |
|
557 |
public void intializeDataStore(DataStoreImplementation store, |
|
558 |
DataStoreParameters parameters) throws InitializeException, |
|
559 |
ProviderNotRegisteredException { |
|
547 |
public void registerFeatureIndexProvider(String name, String description, |
|
548 |
Class clazz, int dataType) { |
|
549 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_INDEX, |
|
550 |
DATA_MANAGER_INDEX_DESCRIPTION).append(name, null, clazz); |
|
560 | 551 |
|
561 |
store.intializePhase1(this, parameters); |
|
562 |
String name = parameters.getDataStoreName(); |
|
563 |
DataStoreProvider provider; |
|
564 |
try { |
|
565 |
provider = (DataStoreProvider) ToolsLocator |
|
566 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).create( |
|
567 |
name, |
|
568 |
new Object[] { parameters, |
|
569 |
(DataStoreProviderServices) store }); |
|
552 |
if (getDefaultFeatureIndexProviderName(dataType) == null) { |
|
553 |
setDefaultFeatureIndexProviderName(dataType, name); |
|
554 |
} |
|
555 |
} |
|
570 | 556 |
|
571 |
} catch (Exception e) { |
|
572 |
throw new InitializeException(parameters.getDataStoreName(), e); |
|
573 |
} |
|
574 |
if (provider == null) { |
|
575 |
throw new ProviderNotRegisteredException(name); |
|
576 |
} |
|
577 |
store.intializePhase2(provider); |
|
557 |
private void initializeIndexes() { |
|
558 |
this.defaultDataIndexProviders = new HashMap(); |
|
559 |
} |
|
578 | 560 |
|
579 |
} |
|
561 |
public void intializeDataStore(DataStoreImplementation store, |
|
562 |
DataStoreParameters parameters) throws InitializeException, |
|
563 |
ProviderNotRegisteredException { |
|
580 | 564 |
|
581 |
public void registerFeatureCacheProvider( |
|
582 |
FeatureCacheProviderFactory providerFactory) { |
|
583 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_CACHE, |
|
584 |
DATA_MANAGER_CACHE_DESCRIPTION).append( |
|
585 |
providerFactory.getName(), "", |
|
586 |
providerFactory); |
|
587 |
} |
|
565 |
store.intializePhase1(this, parameters); |
|
566 |
String name = parameters.getDataStoreName(); |
|
567 |
DataStoreProvider provider; |
|
568 |
try { |
|
569 |
provider = (DataStoreProvider) ToolsLocator |
|
570 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).create( |
|
571 |
name, |
|
572 |
new Object[] { parameters, |
|
573 |
(DataStoreProviderServices) store }); |
|
588 | 574 |
|
589 |
public FeatureCacheProvider createFeatureCacheProvider(String name, |
|
590 |
DynObject parameters) throws DataException { |
|
591 |
if (name == null) { |
|
592 |
throw new InitializeException("It is necessary to provide a cache name", null); |
|
593 |
} |
|
594 |
if (parameters == null){ |
|
595 |
throw new InitializeException("It is necessary to provide parameters to create the explorer", null); |
|
596 |
} |
|
597 |
FeatureCacheProviderFactory featureCacheProviderFactory; |
|
598 |
try { |
|
599 |
featureCacheProviderFactory = (FeatureCacheProviderFactory) ToolsLocator |
|
600 |
.getExtensionPointManager().get(DATA_MANAGER_CACHE).create(name); |
|
601 |
if (featureCacheProviderFactory == null) { |
|
602 |
throw new ProviderNotRegisteredException(name); |
|
603 |
} |
|
604 |
return featureCacheProviderFactory.createCacheProvider(parameters); |
|
605 |
} catch (InstantiationException e) { |
|
606 |
throw new InitializeException(e); |
|
607 |
} catch (IllegalAccessException e) { |
|
608 |
throw new InitializeException(e); |
|
609 |
} |
|
610 |
} |
|
575 |
} catch (Exception e) { |
|
576 |
throw new InitializeException(parameters.getDataStoreName(), e); |
|
577 |
} |
|
578 |
if (provider == null) { |
|
579 |
throw new ProviderNotRegisteredException(name); |
|
580 |
} |
|
581 |
store.intializePhase2(provider); |
|
611 | 582 |
|
612 |
public List getFeatureCacheProviders() { |
|
613 |
ExtensionPoint extensionPoint = ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_CACHE); |
|
614 |
if (extensionPoint != null){ |
|
615 |
return ToolsLocator.getExtensionPointManager().get( |
|
616 |
DATA_MANAGER_CACHE).getNames(); |
|
617 |
}else{ |
|
618 |
return new ArrayList(); |
|
619 |
} |
|
620 |
} |
|
583 |
} |
|
621 | 584 |
|
622 |
public DynObject createCacheParameters(String name) |
|
623 |
throws InitializeException, ProviderNotRegisteredException { |
|
624 |
if (name == null) { |
|
625 |
throw new InitializeException("It is necessary to provide a cache name", null); |
|
626 |
} |
|
627 |
FeatureCacheProviderFactory featureCacheProviderFactory; |
|
628 |
try { |
|
629 |
featureCacheProviderFactory = (FeatureCacheProviderFactory) ToolsLocator |
|
630 |
.getExtensionPointManager().get(DATA_MANAGER_CACHE).create(name); |
|
631 |
if (featureCacheProviderFactory == null) { |
|
632 |
throw new ProviderNotRegisteredException(name); |
|
633 |
} |
|
634 |
return featureCacheProviderFactory.createParameters(); |
|
635 |
} catch (InstantiationException e) { |
|
636 |
throw new InitializeException(e); |
|
637 |
} catch (IllegalAccessException e) { |
|
638 |
throw new InitializeException(e); |
|
639 |
} |
|
640 |
} |
|
585 |
public void registerFeatureCacheProvider( |
|
586 |
FeatureCacheProviderFactory providerFactory) { |
|
587 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_CACHE, |
|
588 |
DATA_MANAGER_CACHE_DESCRIPTION).append( |
|
589 |
providerFactory.getName(), "", |
|
590 |
providerFactory); |
|
591 |
} |
|
641 | 592 |
|
642 |
public DataStoreParameters createMemoryStoreParameters( |
|
643 |
String autoOrderAttributeName) throws InitializeException { |
|
644 |
|
|
645 |
DataStoreParameters parameters; |
|
646 |
try { |
|
647 |
parameters = createStoreParameters(MemoryStoreProvider.NAME); |
|
648 |
if (autoOrderAttributeName != null) { |
|
649 |
parameters.setDynValue( |
|
650 |
MemoryStoreParameters.ORDER_PARAMETER_NAME, |
|
651 |
autoOrderAttributeName); |
|
652 |
} |
|
653 |
return parameters; |
|
654 |
} catch (ProviderNotRegisteredException e) { |
|
655 |
throw new InitializeException("MemoryStoreProvider", e); |
|
656 |
} |
|
657 |
} |
|
593 |
public FeatureCacheProvider createFeatureCacheProvider(String name, |
|
594 |
DynObject parameters) throws DataException { |
|
595 |
if (name == null) { |
|
596 |
throw new InitializeException("It is necessary to provide a cache name", null); |
|
597 |
} |
|
598 |
if (parameters == null){ |
|
599 |
throw new InitializeException("It is necessary to provide parameters to create the explorer", null); |
|
600 |
} |
|
601 |
FeatureCacheProviderFactory featureCacheProviderFactory; |
|
602 |
try { |
|
603 |
featureCacheProviderFactory = (FeatureCacheProviderFactory) ToolsLocator |
|
604 |
.getExtensionPointManager().get(DATA_MANAGER_CACHE).create(name); |
|
605 |
if (featureCacheProviderFactory == null) { |
|
606 |
throw new ProviderNotRegisteredException(name); |
|
607 |
} |
|
608 |
return featureCacheProviderFactory.createCacheProvider(parameters); |
|
609 |
} catch (InstantiationException e) { |
|
610 |
throw new InitializeException(e); |
|
611 |
} catch (IllegalAccessException e) { |
|
612 |
throw new InitializeException(e); |
|
613 |
} |
|
614 |
} |
|
658 | 615 |
|
659 |
public FeatureStore createMemoryStore(String autoOrderAttributeName) |
|
660 |
throws InitializeException { |
|
616 |
public List getFeatureCacheProviders() { |
|
617 |
ExtensionPoint extensionPoint = ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_CACHE); |
|
618 |
if (extensionPoint != null){ |
|
619 |
return ToolsLocator.getExtensionPointManager().get( |
|
620 |
DATA_MANAGER_CACHE).getNames(); |
|
621 |
}else{ |
|
622 |
return new ArrayList(); |
|
623 |
} |
|
624 |
} |
|
661 | 625 |
|
662 |
DataStoreParameters parameters = createMemoryStoreParameters(autoOrderAttributeName); |
|
663 |
try { |
|
664 |
return (FeatureStore) createStore(parameters); |
|
665 |
} catch (ValidateDataParametersException e) { |
|
666 |
throw new InitializeException("MemoryStoreProvider", e); |
|
667 |
} catch (ProviderNotRegisteredException e) { |
|
668 |
throw new InitializeException("MemoryStoreProvider", e); |
|
669 |
} |
|
670 |
} |
|
626 |
public DynObject createCacheParameters(String name) |
|
627 |
throws InitializeException, ProviderNotRegisteredException { |
|
628 |
if (name == null) { |
|
629 |
throw new InitializeException("It is necessary to provide a cache name", null); |
|
630 |
} |
|
631 |
FeatureCacheProviderFactory featureCacheProviderFactory; |
|
632 |
try { |
|
633 |
featureCacheProviderFactory = (FeatureCacheProviderFactory) ToolsLocator |
|
634 |
.getExtensionPointManager().get(DATA_MANAGER_CACHE).create(name); |
|
635 |
if (featureCacheProviderFactory == null) { |
|
636 |
throw new ProviderNotRegisteredException(name); |
|
637 |
} |
|
638 |
return featureCacheProviderFactory.createParameters(); |
|
639 |
} catch (InstantiationException e) { |
|
640 |
throw new InitializeException(e); |
|
641 |
} catch (IllegalAccessException e) { |
|
642 |
throw new InitializeException(e); |
|
643 |
} |
|
644 |
} |
|
671 | 645 |
|
672 |
public FeaturePagingHelper createFeaturePagingHelper( |
|
646 |
public DataStoreParameters createMemoryStoreParameters( |
|
647 |
String autoOrderAttributeName) throws InitializeException { |
|
648 |
|
|
649 |
DataStoreParameters parameters; |
|
650 |
try { |
|
651 |
parameters = createStoreParameters(MemoryStoreProvider.NAME); |
|
652 |
if (autoOrderAttributeName != null) { |
|
653 |
parameters.setDynValue( |
|
654 |
MemoryStoreParameters.ORDER_PARAMETER_NAME, |
|
655 |
autoOrderAttributeName); |
|
656 |
} |
|
657 |
return parameters; |
|
658 |
} catch (ProviderNotRegisteredException e) { |
|
659 |
throw new InitializeException("MemoryStoreProvider", e); |
|
660 |
} |
|
661 |
} |
|
662 |
|
|
663 |
public FeatureStore createMemoryStore(String autoOrderAttributeName) |
|
664 |
throws InitializeException { |
|
665 |
|
|
666 |
DataStoreParameters parameters = createMemoryStoreParameters(autoOrderAttributeName); |
|
667 |
try { |
|
668 |
return (FeatureStore) createStore(parameters); |
|
669 |
} catch (ValidateDataParametersException e) { |
|
670 |
throw new InitializeException("MemoryStoreProvider", e); |
|
671 |
} catch (ProviderNotRegisteredException e) { |
|
672 |
throw new InitializeException("MemoryStoreProvider", e); |
|
673 |
} |
|
674 |
} |
|
675 |
|
|
676 |
public FeaturePagingHelper createFeaturePagingHelper( |
|
673 | 677 |
FeatureStore featureStore, int pageSize) throws BaseException { |
674 |
return new FeaturePagingHelperImpl(featureStore, pageSize);
|
|
675 |
}
|
|
678 |
return new FeaturePagingHelperImpl(featureStore, pageSize);
|
|
679 |
}
|
|
676 | 680 |
|
677 |
public FeaturePagingHelper createFeaturePagingHelper(
|
|
678 |
FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
|
|
679 |
throws BaseException {
|
|
680 |
return new FeaturePagingHelperImpl(featureStore, featureQuery, pageSize);
|
|
681 |
}
|
|
681 |
public FeaturePagingHelper createFeaturePagingHelper(
|
|
682 |
FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
|
|
683 |
throws BaseException { |
|
684 |
return new FeaturePagingHelperImpl(featureStore, featureQuery, pageSize);
|
|
685 |
}
|
|
682 | 686 |
|
687 |
public void registerFeatureAttributeGetter(String name, Class clazz) { |
|
688 |
if (name == null || clazz == null) { |
|
689 |
throw new IllegalArgumentException("Any parameters can be null"); |
|
690 |
} |
|
691 |
|
|
692 |
if(!(FeatureAttributeGetter.class.isAssignableFrom(clazz))) { |
|
693 |
throw new IllegalArgumentException( |
|
694 |
"Not supported implemtation: name=" + name |
|
695 |
+ " class=" + clazz.getName()); |
|
696 |
} |
|
697 |
|
|
698 |
ToolsLocator.getExtensionPointManager().add(DATA_MANAGER_FEATURE_ATTTRIBUTE_GETTER, |
|
699 |
DATA_MANAGER_FEATURE_ATTTRIBUTE_GETTER_DESCRIPTION).append(name, null, |
|
700 |
clazz); |
|
701 |
|
|
702 |
} |
|
703 |
|
|
704 |
public FeatureAttributeGetter createFeatureAttributeGetter(String name) throws InitializeException { |
|
705 |
if (name == null) { |
|
706 |
throw new IllegalArgumentException("The parameter can not be null"); |
|
707 |
} |
|
708 |
|
|
709 |
try{ |
|
710 |
return (FeatureAttributeGetter) ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_FEATURE_ATTTRIBUTE_GETTER).create(name); |
|
711 |
} catch (InstantiationException e) { |
|
712 |
throw new InitializeException("FeatureAttributeGetter", e); |
|
713 |
} catch (IllegalAccessException e) { |
|
714 |
throw new InitializeException("FeatureAttributeGetter", e); |
|
715 |
} |
|
716 |
} |
|
683 | 717 |
} |
Also available in: Unified diff