svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DALLibrary.java @ 25785
History | View | Annotate | Download (2.57 KB)
1 |
package org.gvsig.fmap.dal; |
---|---|
2 |
|
3 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
4 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
5 |
import org.gvsig.fmap.dal.resource.ResourceManager; |
6 |
import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
7 |
import org.gvsig.tools.ToolsLibrary; |
8 |
import org.gvsig.tools.ToolsLocator; |
9 |
import org.gvsig.tools.dynobject.DynClass; |
10 |
import org.gvsig.tools.dynobject.DynField; |
11 |
import org.gvsig.tools.dynobject.DynObjectManager; |
12 |
import org.gvsig.tools.locator.BaseLibrary; |
13 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
14 |
|
15 |
/**
|
16 |
* Initializes gvSIG's desktop DAL by registering the default implementation for {@link DataManager}
|
17 |
* and {@link ResourceManager}.
|
18 |
*
|
19 |
*/
|
20 |
public class DALLibrary extends BaseLibrary { |
21 |
|
22 |
public void initialize() throws ReferenceNotRegisteredException { |
23 |
super.initialize();
|
24 |
ToolsLibrary toolsLib = new ToolsLibrary();
|
25 |
|
26 |
toolsLib.initialize(); |
27 |
toolsLib.postInitialize(); |
28 |
|
29 |
DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
30 |
DALLocator.registerResourceManager(DefaultResourceManager.class); |
31 |
|
32 |
DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
33 |
|
34 |
DynField field; |
35 |
DynClass dataStoreDynClass = dynManager.get(DataStore.DYNCLASS_NAME); |
36 |
|
37 |
if (dataStoreDynClass == null) { |
38 |
dataStoreDynClass = dynManager.add(DataStore.DYNCLASS_NAME); |
39 |
|
40 |
field = dataStoreDynClass.addDynField("SRS");
|
41 |
field.setType(DataTypes.STRING); |
42 |
field.setDescription("Spatial Referencing System");
|
43 |
|
44 |
field = dataStoreDynClass.addDynField("Envelope");
|
45 |
field.setType(DataTypes.OBJECT); // FIXME ???
|
46 |
field.setDescription("Envelope");
|
47 |
|
48 |
} |
49 |
|
50 |
DynClass featureStoreDynClass = dynManager |
51 |
.get(FeatureStore.DYNCLASS_NAME); |
52 |
|
53 |
if (featureStoreDynClass == null) { |
54 |
featureStoreDynClass = dynManager.add(FeatureStore.DYNCLASS_NAME); |
55 |
|
56 |
featureStoreDynClass.extend(dataStoreDynClass); |
57 |
|
58 |
// XXX ???
|
59 |
// field = featureStoreDynClass.addDynField("nativeGeometrySupported");
|
60 |
// field.setType(DataTypes.STRING);
|
61 |
// field.setDescription("Goemtry data type is supported natively");
|
62 |
} |
63 |
|
64 |
} |
65 |
|
66 |
public void postInitialize() { |
67 |
super.postInitialize();
|
68 |
|
69 |
// Validate there is any implementation registered.
|
70 |
DataManager dataManager = DALLocator.getDataManager(); |
71 |
if (dataManager == null) { |
72 |
throw new ReferenceNotRegisteredException( |
73 |
DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
74 |
} |
75 |
|
76 |
ResourceManager resourceManager = DALLocator.getResourceManager(); |
77 |
if (resourceManager == null) { |
78 |
throw new ReferenceNotRegisteredException( |
79 |
DALLocator.RESOURCE_MANAGER_NAME, DALLocator.getInstance()); |
80 |
} |
81 |
} |
82 |
|
83 |
} |