Revision 29326 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/impl/DefaultDataManager.java
DefaultDataManager.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.impl; |
2 | 2 |
|
3 |
import java.io.File; |
|
3 | 4 |
import java.lang.reflect.InvocationTargetException; |
4 | 5 |
import java.util.HashMap; |
5 | 6 |
import java.util.List; |
... | ... | |
29 | 30 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
30 | 31 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
31 | 32 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
33 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
32 | 34 |
import org.gvsig.tools.ToolsLocator; |
33 | 35 |
import org.gvsig.tools.evaluator.Evaluator; |
36 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
|
34 | 37 |
import org.gvsig.tools.operations.OperationManager; |
35 | 38 |
|
36 | 39 |
public class DefaultDataManager implements DataManager, DataManagerProviderServices { |
... | ... | |
105 | 108 |
tmp = System.getenv("TEMP"); |
106 | 109 |
} |
107 | 110 |
if (tmp == null) { |
108 |
tmp = System.getenv("HOME"); |
|
111 |
File tmp_file = new File(System.getenv("HOME"), "_daltmp_"); |
|
112 |
int i=1; |
|
113 |
while (!tmp_file.exists() || !tmp_file.isDirectory()){ |
|
114 |
tmp_file = new File(tmp_file.getAbsolutePath()+i); |
|
115 |
i++; |
|
116 |
} |
|
117 |
if (!tmp_file.exists()){ |
|
118 |
tmp_file.mkdir(); |
|
119 |
} |
|
120 |
tmp = tmp_file.getAbsolutePath(); |
|
109 | 121 |
} |
110 | 122 |
return tmp; |
111 | 123 |
} |
... | ... | |
184 | 196 |
|
185 | 197 |
parameters.validate(); |
186 | 198 |
|
187 |
try { |
|
188 |
DataStoreProvider storeProvider = (DataStoreProvider) ToolsLocator |
|
189 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).create( |
|
190 |
name, new Object[] { parameters }); |
|
191 |
if (storeProvider == null) { |
|
192 |
throw new ProviderNotRegisteredException(name); |
|
193 |
} |
|
199 |
DataStore store; |
|
200 |
Extension storeProviderExtension = ToolsLocator |
|
201 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).get(name); |
|
194 | 202 |
|
195 |
if (storeProvider instanceof CoverageStoreProvider){ |
|
196 |
return new DefaultCoverageStore(this, parameters, |
|
197 |
(CoverageStoreProvider) storeProvider); |
|
198 | 203 |
|
199 |
} else if (storeProvider instanceof FeatureStoreProvider){ |
|
200 | 204 |
|
201 |
return new DefaultFeatureStore(this, parameters, |
|
202 |
(FeatureStoreProvider) storeProvider); |
|
203 |
} else{ |
|
204 |
// FIXME Exception |
|
205 |
throw new InitializeException(new RuntimeException( |
|
206 |
"Not supported implemtation: name=" + name |
|
207 |
+ " provider class=" |
|
208 |
+ storeProvider.getClass().getName())); |
|
209 |
} |
|
205 |
if (storeProviderExtension == null) { |
|
206 |
throw new ProviderNotRegisteredException(name); |
|
207 |
} |
|
210 | 208 |
|
209 |
Class providerClass = storeProviderExtension.getExtension(); |
|
210 |
if (providerClass == null) { |
|
211 |
throw new ProviderNotRegisteredException(name); |
|
212 |
} |
|
211 | 213 |
|
212 |
} catch (InstantiationException e) { |
|
213 |
throw new InitializeException(e); |
|
214 |
} catch (IllegalAccessException e) { |
|
215 |
throw new InitializeException(e); |
|
216 |
} catch (SecurityException e) { |
|
217 |
throw new InitializeException(e); |
|
218 |
} catch (IllegalArgumentException e) { |
|
219 |
throw new InitializeException(e); |
|
220 |
} catch (NoSuchMethodException e) { |
|
221 |
throw new InitializeException(e); |
|
222 |
} catch (InvocationTargetException e) { |
|
223 |
throw new InitializeException(e); |
|
214 |
if (CoverageStoreProvider.class.isAssignableFrom(providerClass)) { |
|
215 |
store = new DefaultCoverageStore(); |
|
216 |
|
|
217 |
|
|
218 |
} else if (FeatureStoreProvider.class.isAssignableFrom(providerClass)) { |
|
219 |
|
|
220 |
store = new DefaultFeatureStore(); |
|
221 |
|
|
222 |
} else{ |
|
223 |
// FIXME Exception |
|
224 |
throw new InitializeException(new RuntimeException( |
|
225 |
"Not supported implemtation: name=" + name |
|
226 |
+ " provider class=" |
|
227 |
+ providerClass.getName())); |
|
224 | 228 |
} |
229 |
|
|
230 |
|
|
231 |
|
|
232 |
this.intializeDataStore((DataStoreImplementation) store, parameters); |
|
233 |
|
|
234 |
return store; |
|
225 | 235 |
} |
226 | 236 |
|
227 | 237 |
public List getStoreProviders() { |
... | ... | |
439 | 449 |
this.defaultDataIndexProviders = new HashMap(); |
440 | 450 |
} |
441 | 451 |
|
442 |
public DataStoreProvider createStoreProvider(String name) |
|
452 |
public void intializeDataStore(DataStoreImplementation store, |
|
453 |
DataStoreParameters parameters) |
|
443 | 454 |
throws InitializeException, ProviderNotRegisteredException { |
444 | 455 |
|
456 |
store.intializePhase1(this, parameters); |
|
457 |
String name = parameters.getDataStoreName(); |
|
458 |
DataStoreProvider provider; |
|
445 | 459 |
try { |
446 |
DataStoreProvider storeProvider = (DataStoreProvider) ToolsLocator
|
|
460 |
provider = (DataStoreProvider) ToolsLocator
|
|
447 | 461 |
.getExtensionPointManager().get(DATA_MANAGER_STORE).create( |
448 |
name); |
|
449 |
if (storeProvider == null) { |
|
450 |
throw new ProviderNotRegisteredException(name); |
|
451 |
} |
|
462 |
name, |
|
463 |
new Object[] { parameters, |
|
464 |
(DataStoreProviderServices) store }); |
|
452 | 465 |
|
453 |
return storeProvider; |
|
454 |
} catch (InstantiationException e) { |
|
466 |
} catch (Exception e) { |
|
455 | 467 |
throw new InitializeException(e); |
456 |
} catch (IllegalAccessException e) { |
|
457 |
throw new InitializeException(e); |
|
458 |
} catch (SecurityException e) { |
|
459 |
throw new InitializeException(e); |
|
460 |
} catch (IllegalArgumentException e) { |
|
461 |
throw new InitializeException(e); |
|
462 | 468 |
} |
469 |
if (provider == null) { |
|
470 |
throw new ProviderNotRegisteredException(name); |
|
471 |
} |
|
472 |
store.intializePhase2(provider); |
|
473 |
|
|
463 | 474 |
} |
464 | 475 |
|
465 | 476 |
} |
Also available in: Unified diff