svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / impl / DALDefaultImplLibrary.java @ 44158
History | View | Annotate | Download (9.21 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.fmap.dal.impl; |
||
25 | |||
26 | import java.io.IOException; |
||
27 | import java.util.ArrayList; |
||
28 | import java.util.List; |
||
29 | import java.util.Map; |
||
30 | |||
31 | import org.gvsig.fmap.dal.DALLibrary; |
||
32 | import org.gvsig.fmap.dal.DALLocator; |
||
33 | import org.gvsig.fmap.dal.DataManager; |
||
34 | import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform; |
||
35 | 43954 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DALFile; |
36 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureQuery; |
37 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReference; |
||
38 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection; |
||
39 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureSelection; |
||
40 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
||
41 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
||
42 | 44158 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.indexes.jsir.JSIRSpatialIndexProviderFactory; |
43 | import org.gvsig.fmap.dal.feature.impl.indexes.memoryspatial.MemorySpatialIndexProviderFactory; |
||
44 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.ComputeAvailableValuesFromTable; |
45 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DumbFeatureTypeDefinitionsManager; |
||
46 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.relations.DALLink_getRelatedFeature; |
||
47 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.relations.DALLink_getRelatedFeatures; |
||
48 | 44158 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryDoubleIndexProviderFactory; |
49 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryFloatIndexProviderFactory; |
||
50 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryIntIndexProviderFactory; |
||
51 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryLongIndexProviderFactory; |
||
52 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryStringIndexProviderFactory; |
||
53 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.spi.memory.MemoryResource; |
54 | import org.gvsig.fmap.dal.feature.spi.memory.MemoryResourceParameters; |
||
55 | 43989 | jjdelcerro | import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureAttributeEmulatorExpression; |
56 | 43983 | jjdelcerro | import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureSymbolTable; |
57 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
58 | import org.gvsig.fmap.dal.resource.spi.MultiResource; |
||
59 | import org.gvsig.fmap.dal.resource.spi.MultiResourceParameters; |
||
60 | import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices; |
||
61 | import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
||
62 | import org.gvsig.i18n.Messages; |
||
63 | import org.gvsig.metadata.exceptions.MetadataException; |
||
64 | import org.gvsig.tools.ToolsLocator; |
||
65 | import org.gvsig.tools.dynobject.DynClass; |
||
66 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
67 | 41936 | jjdelcerro | import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
68 | 40435 | jjdelcerro | import org.gvsig.tools.library.AbstractLibrary; |
69 | import org.gvsig.tools.library.LibraryException; |
||
70 | import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
||
71 | import org.xmlpull.v1.XmlPullParserException; |
||
72 | |||
73 | /**
|
||
74 | * Initialize the implementation of DAL.
|
||
75 | *
|
||
76 | * @author gvSIG Team
|
||
77 | * @version $Id$
|
||
78 | *
|
||
79 | */
|
||
80 | public class DALDefaultImplLibrary extends AbstractLibrary { |
||
81 | |||
82 | 43020 | jjdelcerro | @Override
|
83 | 40435 | jjdelcerro | public void doRegistration() { |
84 | registerAsImplementationOf(DALLibrary.class); |
||
85 | } |
||
86 | |||
87 | 43020 | jjdelcerro | @Override
|
88 | 40435 | jjdelcerro | protected void doInitialize() throws LibraryException { |
89 | DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
||
90 | DALLocator.registerResourceManager(DefaultResourceManager.class); |
||
91 | 42775 | jjdelcerro | DALLocator.registerDefaultFeatureTypeDefinitionsManager(DumbFeatureTypeDefinitionsManager.class); |
92 | 40435 | jjdelcerro | } |
93 | |||
94 | 43020 | jjdelcerro | @Override
|
95 | 40435 | jjdelcerro | protected void doPostInitialize() throws LibraryException { |
96 | List exs = new ArrayList(); |
||
97 | |||
98 | Messages.addResourceFamily("org.gvsig.fmap.dal.i18n.text",
|
||
99 | DALDefaultImplLibrary.class.getClassLoader(), |
||
100 | DALDefaultImplLibrary.class.getClass().getName()); |
||
101 | |||
102 | try {
|
||
103 | registerBaseNewProvidersParametersDefinition(); |
||
104 | } catch (XmlPullParserException e) {
|
||
105 | exs.add(e); |
||
106 | } catch (IOException e) { |
||
107 | exs.add(e); |
||
108 | } |
||
109 | |||
110 | 41936 | jjdelcerro | SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
111 | identityManager.registerAction(DataManager.CREATE_STORE_AUTHORIZATION); |
||
112 | identityManager.registerAction(DataManager.READ_STORE_AUTHORIZATION); |
||
113 | identityManager.registerAction(DataManager.WRITE_STORE_AUTHORIZATION); |
||
114 | |||
115 | |||
116 | 40435 | jjdelcerro | DefaultFeatureQuery.registerPersistent(); |
117 | DefaultFeatureReference.registerPersistent(); |
||
118 | DefaultFeatureStoreTransforms.registerPersistent(); |
||
119 | AbstractFeatureStoreTransform.registerPersistent(); |
||
120 | DefaultFeatureReferenceSelection.registerPersistent(); |
||
121 | DefaultFeatureSelection.registerPersistent(); |
||
122 | |||
123 | DefaultFeatureStore.registerPersistenceDefinition(); |
||
124 | 41493 | jjdelcerro | DefaultDataServerExplorerPool.registerPersistenceDefinition(); |
125 | DefaultDataServerExplorerPoolEntry.registerPersistenceDefinition(); |
||
126 | 43954 | jjdelcerro | |
127 | DALFile.registerPersistenceDefinition(); |
||
128 | 43989 | jjdelcerro | DefaultFeatureAttributeEmulatorExpression.registerPersistenceDefinition(); |
129 | |||
130 | 40435 | jjdelcerro | try {
|
131 | DefaultFeatureStore.registerMetadataDefinition(); |
||
132 | } catch (MetadataException e) {
|
||
133 | exs.add(e); |
||
134 | } |
||
135 | |||
136 | // DefaultFeatureAttributeDescriptor.registerPersistent();
|
||
137 | |||
138 | //Register the FeatureAttributeTransform
|
||
139 | 43020 | jjdelcerro | DefaultDataManager dataManager = (DefaultDataManager) DALLocator.getDataManager(); |
140 | 40435 | jjdelcerro | if (dataManager == null) { |
141 | throw new ReferenceNotRegisteredException( |
||
142 | DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
||
143 | } |
||
144 | |||
145 | 44158 | jjdelcerro | MemorySpatialIndexProviderFactory.selfRegister(); |
146 | JSIRSpatialIndexProviderFactory.selfRegister(); |
||
147 | MemoryStringIndexProviderFactory.selfRegister(); |
||
148 | MemoryIntIndexProviderFactory.selfRegister(); |
||
149 | MemoryLongIndexProviderFactory.selfRegister(); |
||
150 | MemoryFloatIndexProviderFactory.selfRegister(); |
||
151 | MemoryDoubleIndexProviderFactory.selfRegister(); |
||
152 | |||
153 | 40435 | jjdelcerro | ResourceManagerProviderServices resourceManager = |
154 | (ResourceManagerProviderServices) DALLocator.getResourceManager(); |
||
155 | if (resourceManager == null) { |
||
156 | throw new ReferenceNotRegisteredException( |
||
157 | DALLocator.RESOURCE_MANAGER_NAME, DALLocator.getInstance()); |
||
158 | } |
||
159 | |||
160 | if (!resourceManager.getResourceProviders().contains(
|
||
161 | MultiResource.TYPE_NAME)) { |
||
162 | resourceManager.register(MultiResource.TYPE_NAME, |
||
163 | MultiResource.DESCRIPTION, MultiResource.class, |
||
164 | MultiResourceParameters.class); |
||
165 | } |
||
166 | |||
167 | if (!resourceManager.getResourceProviders().contains(
|
||
168 | MemoryResource.NAME)) { |
||
169 | resourceManager.register(MemoryResource.NAME, |
||
170 | MemoryResource.DESCRIPTION, MemoryResource.class, |
||
171 | MemoryResourceParameters.class); |
||
172 | } |
||
173 | |||
174 | 42775 | jjdelcerro | DynObjectManager dynObjectmanager = ToolsLocator.getDynObjectManager(); |
175 | dynObjectmanager.registerDynMethod(new DALLink_getRelatedFeatures());
|
||
176 | dynObjectmanager.registerDynMethod(new DALLink_getRelatedFeature());
|
||
177 | dynObjectmanager.registerDynMethod(new ComputeAvailableValuesFromTable("getAvailableValuesFromTable", "Retrieve available values from the elements of a table.")); |
||
178 | |||
179 | 43983 | jjdelcerro | DefaultFeatureSymbolTable.selfRegister(); |
180 | |||
181 | 40435 | jjdelcerro | if (exs.size() > 0) { |
182 | throw new LibraryException(this.getClass(), exs); |
||
183 | } |
||
184 | } |
||
185 | |||
186 | private void registerBaseNewProvidersParametersDefinition() |
||
187 | throws XmlPullParserException, IOException { |
||
188 | DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
||
189 | if (manager
|
||
190 | .get( |
||
191 | "DAL",
|
||
192 | DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_NAME) == null) {
|
||
193 | Map definitions =
|
||
194 | manager |
||
195 | .importDynClassDefinitions( |
||
196 | DataStoreProviderServices.class |
||
197 | .getResourceAsStream("ProviderParametersDefinition.xml"),
|
||
198 | DataStoreProviderServices.class.getClassLoader()); |
||
199 | manager |
||
200 | .add((DynClass) definitions |
||
201 | .get(DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
||
202 | manager |
||
203 | .add((DynClass) definitions |
||
204 | .get(DataStoreProviderServices.BASE_PARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
||
205 | } |
||
206 | } |
||
207 | |||
208 | } |