Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java @ 125:cee54e52000c
Added the registration of the UserFactory to the bootstrap process.
artifacts/trunk@1349 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 01 Mar 2011 17:45:06 +0000 |
parents | 933bbc9fc11f |
children | 0245a87df368 |
comparison
equal
deleted
inserted
replaced
124:caf9f456f7e3 | 125:cee54e52000c |
---|---|
9 package de.intevation.artifactdatabase; | 9 package de.intevation.artifactdatabase; |
10 | 10 |
11 import de.intevation.artifacts.ArtifactContextFactory; | 11 import de.intevation.artifacts.ArtifactContextFactory; |
12 import de.intevation.artifacts.ArtifactFactory; | 12 import de.intevation.artifacts.ArtifactFactory; |
13 import de.intevation.artifacts.ServiceFactory; | 13 import de.intevation.artifacts.ServiceFactory; |
14 import de.intevation.artifacts.UserFactory; | |
14 | 15 |
15 import java.util.ArrayList; | 16 import java.util.ArrayList; |
16 | 17 |
17 import org.apache.log4j.Logger; | 18 import org.apache.log4j.Logger; |
18 | 19 |
55 */ | 56 */ |
56 public static final String SERVICE_FACTORIES = | 57 public static final String SERVICE_FACTORIES = |
57 "/artifact-database/factories/service-factories/service-factory"; | 58 "/artifact-database/factories/service-factories/service-factory"; |
58 | 59 |
59 /** | 60 /** |
61 * XPath to figure out the class name of the user factory from global | |
62 * configuration. | |
63 */ | |
64 public static final String USER_FACTORY = | |
65 "/artfifact-database/factories/user-factory/text()"; | |
66 | |
67 /** | |
68 * The name of the default user factory. | |
69 */ | |
70 public static final String DEFAULT_USER_FACTORY = | |
71 "de.intevation.artifactdatabase.DefaultUserFactory"; | |
72 | |
73 /** | |
60 * XPath to figure out the secret used to sign the artifact exports | 74 * XPath to figure out the secret used to sign the artifact exports |
61 * made by the artfifact database server. | 75 * made by the artfifact database server. |
62 */ | 76 */ |
63 public static final String EXPORT_SECRET = | 77 public static final String EXPORT_SECRET = |
64 "/artifact-database/export-secret/text()"; | 78 "/artifact-database/export-secret/text()"; |
85 /** | 99 /** |
86 * List of service factories which creates services that are | 100 * List of service factories which creates services that are |
87 * exposed by the artifact database. | 101 * exposed by the artifact database. |
88 */ | 102 */ |
89 protected ServiceFactory [] serviceFactories; | 103 protected ServiceFactory [] serviceFactories; |
104 | |
105 /** | |
106 * The factory that is used to create and list users. | |
107 */ | |
108 protected UserFactory userFactory; | |
90 | 109 |
91 /** | 110 /** |
92 * byte array holding the export signing secret. | 111 * byte array holding the export signing secret. |
93 */ | 112 */ |
94 protected byte [] exportSecret; | 113 protected byte [] exportSecret; |
235 | 254 |
236 serviceFactories = (ServiceFactory [])loadedFactories.toArray( | 255 serviceFactories = (ServiceFactory [])loadedFactories.toArray( |
237 new ServiceFactory[loadedFactories.size()]); | 256 new ServiceFactory[loadedFactories.size()]); |
238 } | 257 } |
239 | 258 |
259 | |
260 /** | |
261 * Scans the global configuration for the configured user factory. | |
262 */ | |
263 protected void loadUserFactory() { | |
264 logger.info("loading user factory"); | |
265 | |
266 String className = Config.getStringXPath( | |
267 USER_FACTORY, DEFAULT_USER_FACTORY); | |
268 | |
269 try { | |
270 Class clazz = Class.forName(className); | |
271 userFactory = (UserFactory) clazz.newInstance(); | |
272 } | |
273 catch (ClassNotFoundException cnfe) { | |
274 logger.error(cnfe.getLocalizedMessage(), cnfe); | |
275 } | |
276 catch (InstantiationException ie) { | |
277 logger.error(ie.getLocalizedMessage(), ie); | |
278 } | |
279 catch (ClassCastException cce) { | |
280 logger.error(cce.getLocalizedMessage(), cce); | |
281 } | |
282 catch (IllegalAccessException iae) { | |
283 logger.error(iae.getLocalizedMessage(), iae); | |
284 } | |
285 } | |
286 | |
240 /** | 287 /** |
241 * Fetches the export signing secret from the global configuration. | 288 * Fetches the export signing secret from the global configuration. |
242 * If none is found if defaults to the DEFAULT_EXORT_SECRET which | 289 * If none is found if defaults to the DEFAULT_EXORT_SECRET which |
243 * is insecure. | 290 * is insecure. |
244 */ | 291 */ |
259 public void boot() { | 306 public void boot() { |
260 setupExportSecret(); | 307 setupExportSecret(); |
261 buildContext(); | 308 buildContext(); |
262 loadArtifactFactories(); | 309 loadArtifactFactories(); |
263 loadServiceFactories(); | 310 loadServiceFactories(); |
311 loadUserFactory(); | |
264 } | 312 } |
265 | 313 |
266 /** | 314 /** |
267 * Returns the list of ready to use artifact factories. | 315 * Returns the list of ready to use artifact factories. |
268 * @return The list of artifact factories. | 316 * @return The list of artifact factories. |