root / branches / dal_time_support / libraries / libFMap_dal / src / org / gvsig / fmap / dal / impl / DALDefaultImplLibrary.java @ 35465
History | View | Annotate | Download (7.59 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.DayToRelativeInstantFeatureAttributeGetter; |
43 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.HourToAbsoluteInstantFeatureAttributeGetter; |
44 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.HourToRelativeInstantFeatureAttributeGetter; |
45 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MilliToAbsoluteInstantFeatureAttributeGetter; |
46 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MilliToRelativeInstantFeatureAttributeGetter; |
47 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MinuteToAbsoluteInstantFeatureAttributeGetter; |
48 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MinuteToRelativeInstantFeatureAttributeGetter; |
49 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MonthToAbsoluteInstantFeatureAttributeGetter; |
50 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.SecondToAbsoluteInstantFeatureAttributeGetter; |
51 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.SecondToRelativeInstantFeatureAttributeGetter; |
52 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.YearToAbsoluteInstantFeatureAttributeGetter; |
53 |
import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
54 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
55 |
import org.gvsig.metadata.exceptions.MetadataException; |
56 |
import org.gvsig.tools.ToolsLocator; |
57 |
import org.gvsig.tools.dynobject.DynClass; |
58 |
import org.gvsig.tools.dynobject.DynObjectManager; |
59 |
import org.gvsig.tools.library.AbstractLibrary; |
60 |
import org.gvsig.tools.library.LibraryException; |
61 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
62 |
|
63 |
/**
|
64 |
* Initialize the implementation of DAL.
|
65 |
*
|
66 |
* @author gvSIG Team
|
67 |
* @version $Id$
|
68 |
*
|
69 |
*/
|
70 |
public class DALDefaultImplLibrary extends AbstractLibrary { |
71 |
|
72 |
public void doRegistration() { |
73 |
registerAsImplementationOf(DALLibrary.class); |
74 |
} |
75 |
|
76 |
protected void doInitialize() throws LibraryException { |
77 |
DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
78 |
DALLocator.registerResourceManager(DefaultResourceManager.class); |
79 |
} |
80 |
|
81 |
protected void doPostInitialize() throws LibraryException { |
82 |
List exs = new ArrayList(); |
83 |
try {
|
84 |
registerBaseNewProvidersParametersDefinition(); |
85 |
} catch (XmlPullParserException e) {
|
86 |
exs.add(e); |
87 |
} catch (IOException e) { |
88 |
exs.add(e); |
89 |
} |
90 |
|
91 |
DefaultFeatureQuery.registerPersistent(); |
92 |
DefaultFeatureReference.registerPersistent(); |
93 |
DefaultFeatureStoreTransforms.registerPersistent(); |
94 |
AbstractFeatureStoreTransform.registerPersistent(); |
95 |
DefaultFeatureReferenceSelection.registerPersistent(); |
96 |
DefaultFeatureSelection.registerPersistent(); |
97 |
// DefaultCoverageStore.registerPersistent();
|
98 |
|
99 |
DefaultFeatureStore.registerPersistenceDefinition(); |
100 |
try {
|
101 |
DefaultFeatureStore.registerMetadataDefinition(); |
102 |
} catch (MetadataException e) {
|
103 |
exs.add(e); |
104 |
} |
105 |
|
106 |
// DefaultFeatureAttributeDescriptor.registerPersistent();
|
107 |
|
108 |
//Register the FeatureAttributeTransform
|
109 |
DataManager dataManager = DALLocator.getDataManager(); |
110 |
if (dataManager == null) { |
111 |
throw new ReferenceNotRegisteredException( |
112 |
DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
113 |
} |
114 |
dataManager.registerFeatureAttributeGetter("milliToRelativeInstant", MilliToRelativeInstantFeatureAttributeGetter.class);
|
115 |
dataManager.registerFeatureAttributeGetter("milliToAbsoluteInstant", MilliToAbsoluteInstantFeatureAttributeGetter.class);
|
116 |
dataManager.registerFeatureAttributeGetter("secondToRelativeInstant", SecondToRelativeInstantFeatureAttributeGetter.class);
|
117 |
dataManager.registerFeatureAttributeGetter("secondToAbsoluteInstant",SecondToAbsoluteInstantFeatureAttributeGetter.class);
|
118 |
dataManager.registerFeatureAttributeGetter("minuteToRelativeInstant",MinuteToRelativeInstantFeatureAttributeGetter.class);
|
119 |
dataManager.registerFeatureAttributeGetter("minuteToAbsoluteInstant", MinuteToAbsoluteInstantFeatureAttributeGetter.class);
|
120 |
dataManager.registerFeatureAttributeGetter("hourToRelativeInstant", HourToRelativeInstantFeatureAttributeGetter.class);
|
121 |
dataManager.registerFeatureAttributeGetter("hourToAbsoluteInstant", HourToAbsoluteInstantFeatureAttributeGetter.class);
|
122 |
dataManager.registerFeatureAttributeGetter("dayToAbsoluteInstant", DayToAbsoluteInstantFeatureAttributeGetter.class);
|
123 |
dataManager.registerFeatureAttributeGetter("dayToRelativeInstant", DayToRelativeInstantFeatureAttributeGetter.class);
|
124 |
dataManager.registerFeatureAttributeGetter("monthToAbsoluteInstant", MonthToAbsoluteInstantFeatureAttributeGetter.class);
|
125 |
dataManager.registerFeatureAttributeGetter("yearToAbsoluteInstant", YearToAbsoluteInstantFeatureAttributeGetter.class);
|
126 |
|
127 |
if (exs.size() > 0) { |
128 |
throw new LibraryException(this.getClass(), exs); |
129 |
} |
130 |
} |
131 |
|
132 |
private void registerBaseNewProvidersParametersDefinition() |
133 |
throws XmlPullParserException, IOException { |
134 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
135 |
if (manager
|
136 |
.get( |
137 |
"DAL",
|
138 |
DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_NAME) == null) {
|
139 |
Map definitions =
|
140 |
manager |
141 |
.importDynClassDefinitions( |
142 |
DataStoreProviderServices.class |
143 |
.getResourceAsStream("ProviderParametersDefinition.xml"),
|
144 |
DataStoreProviderServices.class.getClassLoader()); |
145 |
manager |
146 |
.add((DynClass) definitions |
147 |
.get(DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
148 |
manager |
149 |
.add((DynClass) definitions |
150 |
.get(DataStoreProviderServices.BASE_PARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
151 |
} |
152 |
} |
153 |
|
154 |
} |