root / branches / dal_time_support / libraries / libFMap_dal / src / org / gvsig / fmap / dal / impl / DALDefaultImplLibrary.java @ 35115
History | View | Annotate | Download (6.96 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
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 |
* as published by the Free Software Foundation; either version 2
|
9 |
* 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 |
*/
|
22 |
package org.gvsig.fmap.dal.impl; |
23 |
|
24 |
import java.io.IOException; |
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
import java.util.Map; |
28 |
|
29 |
import org.xmlpull.v1.XmlPullParserException; |
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 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureQuery; |
36 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReference; |
37 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection; |
38 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureSelection; |
39 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
40 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
41 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.DayToAbsoluteInstantFeatureAttributeGetter; |
42 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.HourToAbsoluteInstantFeatureAttributeGetter; |
43 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MilliToAbsoluteInstantFeatureAttributeGetter; |
44 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MilliToRelativeInstantFeatureAttributeGetter; |
45 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MinuteToAbsoluteInstantFeatureAttributeGetter; |
46 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MonthToAbsoluteInstantFeatureAttributeGetter; |
47 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.SecondToAbsoluteInstantFeatureAttributeGetter; |
48 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.SecondToRelativeInstantFeatureAttributeGetter; |
49 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.YearToAbsoluteInstantFeatureAttributeGetter; |
50 |
import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
51 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
52 |
import org.gvsig.metadata.exceptions.MetadataException; |
53 |
import org.gvsig.tools.ToolsLocator; |
54 |
import org.gvsig.tools.dynobject.DynClass; |
55 |
import org.gvsig.tools.dynobject.DynObjectManager; |
56 |
import org.gvsig.tools.library.AbstractLibrary; |
57 |
import org.gvsig.tools.library.Library; |
58 |
import org.gvsig.tools.library.LibraryException; |
59 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
60 |
|
61 |
/**
|
62 |
* Initialize the implementation of DAL.
|
63 |
*
|
64 |
* @author gvSIG Team
|
65 |
* @version $Id$
|
66 |
*
|
67 |
*/
|
68 |
public class DALDefaultImplLibrary extends AbstractLibrary { |
69 |
|
70 |
public DALDefaultImplLibrary() {
|
71 |
super(DALLibrary.class, Library.TYPE.IMPL);
|
72 |
} |
73 |
|
74 |
protected void doInitialize() throws LibraryException { |
75 |
DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
76 |
DALLocator.registerResourceManager(DefaultResourceManager.class); |
77 |
} |
78 |
|
79 |
protected void doPostInitialize() throws LibraryException { |
80 |
List exs = new ArrayList(); |
81 |
try {
|
82 |
registerBaseNewProvidersParametersDefinition(); |
83 |
} catch (XmlPullParserException e) {
|
84 |
exs.add(e); |
85 |
} catch (IOException e) { |
86 |
exs.add(e); |
87 |
} |
88 |
|
89 |
DefaultFeatureQuery.registerPersistent(); |
90 |
DefaultFeatureReference.registerPersistent(); |
91 |
DefaultFeatureStoreTransforms.registerPersistent(); |
92 |
AbstractFeatureStoreTransform.registerPersistent(); |
93 |
DefaultFeatureReferenceSelection.registerPersistent(); |
94 |
DefaultFeatureSelection.registerPersistent(); |
95 |
// DefaultCoverageStore.registerPersistent();
|
96 |
|
97 |
DefaultFeatureStore.registerPersistenceDefinition(); |
98 |
try {
|
99 |
DefaultFeatureStore.registerMetadataDefinition(); |
100 |
} catch (MetadataException e) {
|
101 |
exs.add(e); |
102 |
} |
103 |
|
104 |
// DefaultFeatureAttributeDescriptor.registerPersistent();
|
105 |
|
106 |
//Register the FeatureAttributeTransform
|
107 |
DataManager dataManager = DALLocator.getDataManager(); |
108 |
if (dataManager == null) { |
109 |
throw new ReferenceNotRegisteredException( |
110 |
DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
111 |
} |
112 |
dataManager.registerFeatureAttributeGetter("milliToRelativeInstant", MilliToRelativeInstantFeatureAttributeGetter.class);
|
113 |
dataManager.registerFeatureAttributeGetter("secondToRelativeInstant", SecondToRelativeInstantFeatureAttributeGetter.class);
|
114 |
dataManager.registerFeatureAttributeGetter("milliToAbsoluteInstant", MilliToAbsoluteInstantFeatureAttributeGetter.class);
|
115 |
dataManager.registerFeatureAttributeGetter("secondToAbsoluteInstant",SecondToAbsoluteInstantFeatureAttributeGetter.class);
|
116 |
dataManager.registerFeatureAttributeGetter("minuteToAbsoluteInstant", MinuteToAbsoluteInstantFeatureAttributeGetter.class);
|
117 |
dataManager.registerFeatureAttributeGetter("hourToAbsoluteInstant", HourToAbsoluteInstantFeatureAttributeGetter.class);
|
118 |
dataManager.registerFeatureAttributeGetter("dayToAbsoluteInstant", DayToAbsoluteInstantFeatureAttributeGetter.class);
|
119 |
dataManager.registerFeatureAttributeGetter("monthToAbsoluteInstant", MonthToAbsoluteInstantFeatureAttributeGetter.class);
|
120 |
dataManager.registerFeatureAttributeGetter("yearToAbsoluteInstant", YearToAbsoluteInstantFeatureAttributeGetter.class);
|
121 |
|
122 |
if (exs.size() > 0) { |
123 |
throw new LibraryException(this.getClass(), exs); |
124 |
} |
125 |
} |
126 |
|
127 |
private void registerBaseNewProvidersParametersDefinition() |
128 |
throws XmlPullParserException, IOException { |
129 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
130 |
if (manager
|
131 |
.get( |
132 |
"DAL",
|
133 |
DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_NAME) == null) {
|
134 |
Map definitions =
|
135 |
manager |
136 |
.importDynClassDefinitions( |
137 |
DataStoreProviderServices.class |
138 |
.getResourceAsStream("ProviderParametersDefinition.xml"),
|
139 |
DataStoreProviderServices.class.getClassLoader()); |
140 |
manager |
141 |
.add((DynClass) definitions |
142 |
.get(DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
143 |
manager |
144 |
.add((DynClass) definitions |
145 |
.get(DataStoreProviderServices.BASE_PARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
146 |
} |
147 |
} |
148 |
|
149 |
} |