svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / DALLocator.java @ 44154
History | View | Annotate | Download (5.98 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 | 42775 | jjdelcerro | * This program is free software; you can redistribute it and/or modify it under
|
7 | * the terms of the GNU General Public License as published by the Free Software
|
||
8 | * Foundation; either version 3 of the License, or (at your option) any later
|
||
9 | * version.
|
||
10 | 40435 | jjdelcerro | *
|
11 | 42775 | jjdelcerro | * This program is distributed in the hope that it will be useful, but WITHOUT
|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
14 | * details.
|
||
15 | 40435 | jjdelcerro | *
|
16 | 42775 | jjdelcerro | * You should have received a copy of the GNU General Public License along with
|
17 | * this program; if not, write to the Free Software Foundation, Inc., 51
|
||
18 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
19 | 40435 | jjdelcerro | *
|
20 | 42775 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40435 | jjdelcerro | */
|
23 | package org.gvsig.fmap.dal; |
||
24 | |||
25 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager; |
26 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.resource.ResourceManager; |
27 | import org.gvsig.tools.locator.AbstractLocator; |
||
28 | import org.gvsig.tools.locator.Locator; |
||
29 | import org.gvsig.tools.locator.LocatorException; |
||
30 | |||
31 | /**
|
||
32 | *
|
||
33 | 42775 | jjdelcerro | * This locator is the entry point of gvSIG's DAL, providing access to all DAL
|
34 | * services. DAL services are grouped in two managers {@link DataManager} and
|
||
35 | * {@link ResourceManager}.
|
||
36 | 40435 | jjdelcerro | *
|
37 | 42775 | jjdelcerro | * This locator offers methods for registering as well as for obtaining both
|
38 | * managers' unique instances.
|
||
39 | 40435 | jjdelcerro | *
|
40 | * @see Locator
|
||
41 | */
|
||
42 | public class DALLocator extends AbstractLocator { |
||
43 | |||
44 | 42775 | jjdelcerro | private static final String LOCATOR_NAME = "DALLocator"; |
45 | 40435 | jjdelcerro | |
46 | 42775 | jjdelcerro | /**
|
47 | * DataManager name used by the locator to access the instance
|
||
48 | */
|
||
49 | public static final String DATA_MANAGER_NAME = "DataManager"; |
||
50 | 40435 | jjdelcerro | |
51 | 42775 | jjdelcerro | private static final String DATA_MANAGER_DESCRIPTION = "DataManager of gvSIG Data Access Library"; |
52 | 40435 | jjdelcerro | |
53 | 42775 | jjdelcerro | /**
|
54 | * ResourceManager name used by the locator to access the instance
|
||
55 | */
|
||
56 | public static final String RESOURCE_MANAGER_NAME = "ResourceManager"; |
||
57 | 40435 | jjdelcerro | |
58 | 42775 | jjdelcerro | private static final String RESOURCE_MANAGER_DESCRIPTION = "ResourceManager of gvSIG Data Access Library"; |
59 | 40435 | jjdelcerro | |
60 | 42775 | jjdelcerro | /**
|
61 | * DataManager name used by the locator to access the instance
|
||
62 | */
|
||
63 | public static final String FEATURETYPE_DEFINITIONS_MANAGER_NAME = "FeatureTypeDefinitionsManager"; |
||
64 | 40435 | jjdelcerro | |
65 | 42775 | jjdelcerro | private static final String FEATURETYPE_DEFINITIONS_MANAGER_DESCRIPTION = "FeatureTypeDefinitionsManager of gvSIG Data Access Library"; |
66 | 40435 | jjdelcerro | |
67 | 42775 | jjdelcerro | /**
|
68 | * Unique instance.
|
||
69 | */
|
||
70 | private static final DALLocator instance = new DALLocator(); |
||
71 | 40435 | jjdelcerro | |
72 | 42775 | jjdelcerro | /**
|
73 | * Return the singleton instance.
|
||
74 | *
|
||
75 | * @return the singleton instance
|
||
76 | */
|
||
77 | public static DALLocator getInstance() { |
||
78 | return instance;
|
||
79 | } |
||
80 | 40435 | jjdelcerro | |
81 | 42775 | jjdelcerro | /**
|
82 | * Returns the Locator name.
|
||
83 | *
|
||
84 | * @return String containing the locator name.
|
||
85 | */
|
||
86 | public String getLocatorName() { |
||
87 | return LOCATOR_NAME;
|
||
88 | } |
||
89 | 40435 | jjdelcerro | |
90 | 42775 | jjdelcerro | /**
|
91 | * Return a reference to DataManager.
|
||
92 | *
|
||
93 | * @return a reference to DataManager
|
||
94 | * @throws LocatorException if there is no access to the class or the class
|
||
95 | * cannot be instantiated
|
||
96 | * @see Locator#get(String)
|
||
97 | */
|
||
98 | public static DataManager getDataManager() throws LocatorException { |
||
99 | return (DataManager) getInstance().get(DATA_MANAGER_NAME);
|
||
100 | } |
||
101 | 40435 | jjdelcerro | |
102 | 42775 | jjdelcerro | /**
|
103 | * Registers the Class implementing the DataManager interface.
|
||
104 | *
|
||
105 | * @param clazz implementing the DataManager interface
|
||
106 | */
|
||
107 | public static void registerDataManager(Class clazz) { |
||
108 | getInstance().register(DATA_MANAGER_NAME, DATA_MANAGER_DESCRIPTION, |
||
109 | clazz); |
||
110 | } |
||
111 | 40435 | jjdelcerro | |
112 | 42775 | jjdelcerro | /**
|
113 | * Registers a class as the default DataManager.
|
||
114 | *
|
||
115 | * @param clazz implementing the DataManager interface
|
||
116 | */
|
||
117 | public static void registerDefaultDataManager(Class clazz) { |
||
118 | getInstance().registerDefault(DATA_MANAGER_NAME, DATA_MANAGER_DESCRIPTION, |
||
119 | clazz); |
||
120 | } |
||
121 | 40435 | jjdelcerro | |
122 | 42775 | jjdelcerro | /**
|
123 | * Return a reference to ResourceManager.
|
||
124 | *
|
||
125 | * @return a reference to ResourceManager
|
||
126 | * @throws LocatorException if there is no access to the class or the class
|
||
127 | * cannot be instantiated
|
||
128 | * @see Locator#get(String)
|
||
129 | */
|
||
130 | public static ResourceManager getResourceManager() throws LocatorException { |
||
131 | return (ResourceManager) getInstance().get(RESOURCE_MANAGER_NAME);
|
||
132 | } |
||
133 | |||
134 | /**
|
||
135 | * Registers the Class implementing the MDManager interface.
|
||
136 | *
|
||
137 | * @param clazz implementing the MDManager interface
|
||
138 | */
|
||
139 | public static void registerResourceManager(Class clazz) { |
||
140 | getInstance().register(RESOURCE_MANAGER_NAME, |
||
141 | RESOURCE_MANAGER_DESCRIPTION, clazz); |
||
142 | } |
||
143 | |||
144 | /**
|
||
145 | * Return a reference to FeatureTypeDefinitionsManager.
|
||
146 | *
|
||
147 | * @return a reference to FeatureTypeDefinitionsManager
|
||
148 | * @throws LocatorException if there is no access to the class or the class
|
||
149 | * cannot be instantiated
|
||
150 | * @see Locator#get(String)
|
||
151 | */
|
||
152 | public static FeatureTypeDefinitionsManager getFeatureTypeDefinitionsManager() throws LocatorException { |
||
153 | return (FeatureTypeDefinitionsManager) getInstance().get(FEATURETYPE_DEFINITIONS_MANAGER_NAME);
|
||
154 | } |
||
155 | |||
156 | /**
|
||
157 | * Registers the Class implementing the FeatureTypeDefinitionsManager
|
||
158 | * interface.
|
||
159 | *
|
||
160 | * @param clazz implementing the FeatureTypeDefinitionsManager interface
|
||
161 | */
|
||
162 | public static void registerFeatureTypeDefinitionsManager(Class clazz) { |
||
163 | getInstance().register(FEATURETYPE_DEFINITIONS_MANAGER_NAME, |
||
164 | FEATURETYPE_DEFINITIONS_MANAGER_DESCRIPTION, |
||
165 | clazz); |
||
166 | } |
||
167 | |||
168 | /**
|
||
169 | * Registers a class as the default FeatureTypeDefinitionsManager.
|
||
170 | *
|
||
171 | * @param clazz implementing the FeatureTypeDefinitionsManager interface
|
||
172 | */
|
||
173 | public static void registerDefaultFeatureTypeDefinitionsManager(Class clazz) { |
||
174 | getInstance().registerDefault(FEATURETYPE_DEFINITIONS_MANAGER_NAME, |
||
175 | FEATURETYPE_DEFINITIONS_MANAGER_DESCRIPTION, |
||
176 | clazz); |
||
177 | } |
||
178 | |||
179 | 40435 | jjdelcerro | } |