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 @ 43989
History | View | Annotate | Download (9.15 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.DataTypes; |
||
35 | import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform; |
||
36 | 43954 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DALFile; |
37 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureQuery; |
38 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReference; |
||
39 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection; |
||
40 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureSelection; |
||
41 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
||
42 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
||
43 | 41239 | nbrodin | import org.gvsig.fmap.dal.feature.impl.JSIRSpatialIndexProvider; |
44 | 43020 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.JSIRSpatialIndexProviderFactory; |
45 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.MemorySpatialIndexProvider; |
46 | 43020 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.MemorySpatialIndexProviderFactory; |
47 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.ComputeAvailableValuesFromTable; |
48 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DumbFeatureTypeDefinitionsManager; |
||
49 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.relations.DALLink_getRelatedFeature; |
||
50 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.relations.DALLink_getRelatedFeatures; |
||
51 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.spi.memory.MemoryResource; |
52 | import org.gvsig.fmap.dal.feature.spi.memory.MemoryResourceParameters; |
||
53 | 43989 | jjdelcerro | import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureAttributeEmulatorExpression; |
54 | 43983 | jjdelcerro | import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureSymbolTable; |
55 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
56 | import org.gvsig.fmap.dal.resource.spi.MultiResource; |
||
57 | import org.gvsig.fmap.dal.resource.spi.MultiResourceParameters; |
||
58 | import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices; |
||
59 | import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
||
60 | import org.gvsig.i18n.Messages; |
||
61 | import org.gvsig.metadata.exceptions.MetadataException; |
||
62 | import org.gvsig.tools.ToolsLocator; |
||
63 | import org.gvsig.tools.dynobject.DynClass; |
||
64 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
65 | 41936 | jjdelcerro | import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
66 | 40435 | jjdelcerro | import org.gvsig.tools.library.AbstractLibrary; |
67 | import org.gvsig.tools.library.LibraryException; |
||
68 | import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
||
69 | import org.xmlpull.v1.XmlPullParserException; |
||
70 | |||
71 | /**
|
||
72 | * Initialize the implementation of DAL.
|
||
73 | *
|
||
74 | * @author gvSIG Team
|
||
75 | * @version $Id$
|
||
76 | *
|
||
77 | */
|
||
78 | public class DALDefaultImplLibrary extends AbstractLibrary { |
||
79 | |||
80 | 43020 | jjdelcerro | @Override
|
81 | 40435 | jjdelcerro | public void doRegistration() { |
82 | registerAsImplementationOf(DALLibrary.class); |
||
83 | } |
||
84 | |||
85 | 43020 | jjdelcerro | @Override
|
86 | 40435 | jjdelcerro | protected void doInitialize() throws LibraryException { |
87 | DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
||
88 | DALLocator.registerResourceManager(DefaultResourceManager.class); |
||
89 | 42775 | jjdelcerro | DALLocator.registerDefaultFeatureTypeDefinitionsManager(DumbFeatureTypeDefinitionsManager.class); |
90 | 40435 | jjdelcerro | } |
91 | |||
92 | 43020 | jjdelcerro | @Override
|
93 | 40435 | jjdelcerro | protected void doPostInitialize() throws LibraryException { |
94 | List exs = new ArrayList(); |
||
95 | |||
96 | Messages.addResourceFamily("org.gvsig.fmap.dal.i18n.text",
|
||
97 | DALDefaultImplLibrary.class.getClassLoader(), |
||
98 | DALDefaultImplLibrary.class.getClass().getName()); |
||
99 | |||
100 | try {
|
||
101 | registerBaseNewProvidersParametersDefinition(); |
||
102 | } catch (XmlPullParserException e) {
|
||
103 | exs.add(e); |
||
104 | } catch (IOException e) { |
||
105 | exs.add(e); |
||
106 | } |
||
107 | |||
108 | 41936 | jjdelcerro | SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
109 | identityManager.registerAction(DataManager.CREATE_STORE_AUTHORIZATION); |
||
110 | identityManager.registerAction(DataManager.READ_STORE_AUTHORIZATION); |
||
111 | identityManager.registerAction(DataManager.WRITE_STORE_AUTHORIZATION); |
||
112 | |||
113 | |||
114 | 40435 | jjdelcerro | DefaultFeatureQuery.registerPersistent(); |
115 | DefaultFeatureReference.registerPersistent(); |
||
116 | DefaultFeatureStoreTransforms.registerPersistent(); |
||
117 | AbstractFeatureStoreTransform.registerPersistent(); |
||
118 | DefaultFeatureReferenceSelection.registerPersistent(); |
||
119 | DefaultFeatureSelection.registerPersistent(); |
||
120 | |||
121 | DefaultFeatureStore.registerPersistenceDefinition(); |
||
122 | 41493 | jjdelcerro | DefaultDataServerExplorerPool.registerPersistenceDefinition(); |
123 | DefaultDataServerExplorerPoolEntry.registerPersistenceDefinition(); |
||
124 | 43954 | jjdelcerro | |
125 | DALFile.registerPersistenceDefinition(); |
||
126 | 43989 | jjdelcerro | DefaultFeatureAttributeEmulatorExpression.registerPersistenceDefinition(); |
127 | |||
128 | 40435 | jjdelcerro | try {
|
129 | DefaultFeatureStore.registerMetadataDefinition(); |
||
130 | } catch (MetadataException e) {
|
||
131 | exs.add(e); |
||
132 | } |
||
133 | |||
134 | // DefaultFeatureAttributeDescriptor.registerPersistent();
|
||
135 | |||
136 | //Register the FeatureAttributeTransform
|
||
137 | 43020 | jjdelcerro | DefaultDataManager dataManager = (DefaultDataManager) DALLocator.getDataManager(); |
138 | 40435 | jjdelcerro | if (dataManager == null) { |
139 | throw new ReferenceNotRegisteredException( |
||
140 | DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
||
141 | } |
||
142 | |||
143 | // Register a default spatial index based in the default memory spatial index of geom library
|
||
144 | 43020 | jjdelcerro | if( !dataManager.getFeatureIndexRegister().exits(MemorySpatialIndexProvider.NAME) ) {
|
145 | dataManager.getFeatureIndexRegister().register(new MemorySpatialIndexProviderFactory());
|
||
146 | } |
||
147 | if( !dataManager.getFeatureIndexRegister().exits(JSIRSpatialIndexProvider.NAME) ) {
|
||
148 | dataManager.getFeatureIndexRegister().register(new JSIRSpatialIndexProviderFactory());
|
||
149 | dataManager.setDefaultFeatureIndexProviderName( |
||
150 | DataTypes.GEOMETRY, |
||
151 | JSIRSpatialIndexProvider.NAME |
||
152 | ); |
||
153 | } |
||
154 | 40435 | jjdelcerro | |
155 | ResourceManagerProviderServices resourceManager = |
||
156 | (ResourceManagerProviderServices) DALLocator.getResourceManager(); |
||
157 | if (resourceManager == null) { |
||
158 | throw new ReferenceNotRegisteredException( |
||
159 | DALLocator.RESOURCE_MANAGER_NAME, DALLocator.getInstance()); |
||
160 | } |
||
161 | |||
162 | if (!resourceManager.getResourceProviders().contains(
|
||
163 | MultiResource.TYPE_NAME)) { |
||
164 | resourceManager.register(MultiResource.TYPE_NAME, |
||
165 | MultiResource.DESCRIPTION, MultiResource.class, |
||
166 | MultiResourceParameters.class); |
||
167 | } |
||
168 | |||
169 | if (!resourceManager.getResourceProviders().contains(
|
||
170 | MemoryResource.NAME)) { |
||
171 | resourceManager.register(MemoryResource.NAME, |
||
172 | MemoryResource.DESCRIPTION, MemoryResource.class, |
||
173 | MemoryResourceParameters.class); |
||
174 | } |
||
175 | |||
176 | 42775 | jjdelcerro | DynObjectManager dynObjectmanager = ToolsLocator.getDynObjectManager(); |
177 | dynObjectmanager.registerDynMethod(new DALLink_getRelatedFeatures());
|
||
178 | dynObjectmanager.registerDynMethod(new DALLink_getRelatedFeature());
|
||
179 | dynObjectmanager.registerDynMethod(new ComputeAvailableValuesFromTable("getAvailableValuesFromTable", "Retrieve available values from the elements of a table.")); |
||
180 | |||
181 | 43983 | jjdelcerro | DefaultFeatureSymbolTable.selfRegister(); |
182 | |||
183 | 40435 | jjdelcerro | if (exs.size() > 0) { |
184 | throw new LibraryException(this.getClass(), exs); |
||
185 | } |
||
186 | } |
||
187 | |||
188 | private void registerBaseNewProvidersParametersDefinition() |
||
189 | throws XmlPullParserException, IOException { |
||
190 | DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
||
191 | if (manager
|
||
192 | .get( |
||
193 | "DAL",
|
||
194 | DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_NAME) == null) {
|
||
195 | Map definitions =
|
||
196 | manager |
||
197 | .importDynClassDefinitions( |
||
198 | DataStoreProviderServices.class |
||
199 | .getResourceAsStream("ProviderParametersDefinition.xml"),
|
||
200 | DataStoreProviderServices.class.getClassLoader()); |
||
201 | manager |
||
202 | .add((DynClass) definitions |
||
203 | .get(DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
||
204 | manager |
||
205 | .add((DynClass) definitions |
||
206 | .get(DataStoreProviderServices.BASE_PARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
||
207 | } |
||
208 | } |
||
209 | |||
210 | } |