Revision 23867 branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/impl/DefaultDataManager.java
DefaultDataManager.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.impl; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 | 3 |
import java.lang.reflect.Constructor; |
5 | 4 |
import java.lang.reflect.InvocationTargetException; |
6 | 5 |
import java.util.ArrayList; |
... | ... | |
22 | 21 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
23 | 22 |
import org.gvsig.fmap.data.feature.FeatureStore; |
24 | 23 |
import org.gvsig.fmap.data.feature.FeatureType; |
25 |
import org.gvsig.fmap.data.index.DataIndexProvider; |
|
24 |
import org.gvsig.fmap.data.feature.impl.DefaultFeatureStore; |
|
25 |
import org.gvsig.fmap.data.feature.spi.DataIndexProvider; |
|
26 |
import org.gvsig.fmap.data.feature.spi.FeatureStoreProvider; |
|
26 | 27 |
import org.gvsig.tools.evaluator.Evaluator; |
27 | 28 |
import org.gvsig.tools.extensionPoint.ExtensionPoint; |
28 | 29 |
import org.gvsig.tools.extensionPoint.ExtensionPointsSingleton; |
... | ... | |
52 | 53 |
public static final String DATAEXPLORER_PROVIDER = "DataExplorerProvider"; |
53 | 54 |
} |
54 | 55 |
|
55 |
/**
|
|
56 |
/* |
|
56 | 57 |
* Create extension points |
57 | 58 |
*/ |
58 | 59 |
private static ExtensionPoint dataExplorerProviderEP = new ExtensionPoint( |
... | ... | |
62 | 63 |
private static ExtensionPoint dataIndexProviderEP = new ExtensionPoint( |
63 | 64 |
ExtensionPointNames.DATAINDEX_PROVIDER, "Data Index Provider"); |
64 | 65 |
|
65 |
/**
|
|
66 |
/* |
|
66 | 67 |
* Register extension points |
67 | 68 |
*/ |
68 | 69 |
static { |
... | ... | |
70 | 71 |
ExtensionPointsSingleton.getInstance().put(dataStoreProviderEP); |
71 | 72 |
ExtensionPointsSingleton.getInstance().put(dataIndexProviderEP); |
72 | 73 |
} |
73 |
|
|
74 |
|
|
74 | 75 |
/** |
75 | 76 |
* |
76 | 77 |
* @return ResourceManager |
... | ... | |
663 | 664 |
|
664 | 665 |
public DataIndexProvider createDataIndexProvider(FeatureStore store, |
665 | 666 |
FeatureType type, FeatureAttributeDescriptor attr, |
666 |
String[] providerNames) { |
|
667 |
// TODO Auto-generated method stub |
|
668 |
return null; |
|
667 |
String[] providerNames) throws InitializeException, NotResgisteredStore { |
|
668 |
|
|
669 |
String name = null; |
|
670 |
|
|
671 |
// look up the specified preferred providers. The first found is chosen |
|
672 |
if (providerNames != null) { |
|
673 |
boolean notFound = true; |
|
674 |
for (int i = 0; i < providerNames.length && notFound; i++) { |
|
675 |
if (dataIndexProviderEP.containsKey(providerNames[i])) { |
|
676 |
notFound = false; |
|
677 |
name = providerNames[i]; |
|
678 |
} |
|
679 |
} |
|
680 |
} |
|
681 |
|
|
682 |
// if no preferred providers were specified or none was found, use the default one |
|
683 |
if (providerNames == null || name == null) { |
|
684 |
name = getDefaultDataIndexProviderName(attr.getDataType()); |
|
685 |
} |
|
686 |
|
|
687 |
// instantiate, initialize and return it |
|
688 |
try { |
|
689 |
DataIndexProvider dataIndexProvider = (DataIndexProvider) dataIndexProviderEP.create(name); |
|
690 |
dataIndexProvider.initialize(); |
|
691 |
return dataIndexProvider; |
|
692 |
} catch (IllegalAccessException e) { |
|
693 |
throw new NotResgisteredStore(name); |
|
694 |
} catch (InstantiationException e) { |
|
695 |
throw new InitializeException(name, e); |
|
696 |
} |
|
669 | 697 |
} |
670 | 698 |
|
671 | 699 |
public DataIndexProvider createDataIndexProvider(FeatureStore store, |
672 |
FeatureType type, FeatureAttributeDescriptor attr) { |
|
673 |
// TODO Auto-generated method stub |
|
674 |
return null; |
|
700 |
FeatureType type, FeatureAttributeDescriptor attr) throws InitializeException, NotResgisteredStore { |
|
701 |
return createDataIndexProvider(store, type, attr, null); |
|
675 | 702 |
} |
676 | 703 |
|
677 | 704 |
public String[] getDataIndexProviders(int dataType) { |
705 |
//FIXME |
|
678 | 706 |
Set set = dataIndexProviderEP.keySet(); |
679 | 707 |
return (String[])set.toArray(); |
680 | 708 |
} |
681 | 709 |
|
682 | 710 |
public String getTemporaryDirectory() { |
711 |
// FIXME Define a better tempdir solution |
|
683 | 712 |
String tmp = System.getenv("TMP"); |
684 | 713 |
if (tmp == null) { |
685 | 714 |
tmp = System.getenv("TEMP"); |
Also available in: Unified diff