comparison artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java @ 130:147610c43863

The UserFactory got a setup() method that is called while bootstrap. artifacts/trunk@1354 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 02 Mar 2011 07:36:00 +0000
parents 0245a87df368
children f797093c60bd
comparison
equal deleted inserted replaced
129:10d726907419 130:147610c43863
16 import java.util.ArrayList; 16 import java.util.ArrayList;
17 17
18 import org.apache.log4j.Logger; 18 import org.apache.log4j.Logger;
19 19
20 import org.w3c.dom.Document; 20 import org.w3c.dom.Document;
21 import org.w3c.dom.Node;
21 import org.w3c.dom.NodeList; 22 import org.w3c.dom.NodeList;
22 23
23 /** 24 /**
24 * Bootstrap facility for the global context and the artifact factories. 25 * Bootstrap facility for the global context and the artifact factories.
25 * 26 *
60 /** 61 /**
61 * XPath to figure out the class name of the user factory from global 62 * XPath to figure out the class name of the user factory from global
62 * configuration. 63 * configuration.
63 */ 64 */
64 public static final String USER_FACTORY = 65 public static final String USER_FACTORY =
65 "/artfifact-database/factories/user-factory/text()"; 66 "/artfifact-database/factories/user-factory";
66 67
67 /** 68 /**
68 * The name of the default user factory. 69 * The name of the default user factory.
69 */ 70 */
70 public static final String DEFAULT_USER_FACTORY = 71 public static final String DEFAULT_USER_FACTORY =
261 * Scans the global configuration for the configured user factory. 262 * Scans the global configuration for the configured user factory.
262 */ 263 */
263 protected void loadUserFactory() { 264 protected void loadUserFactory() {
264 logger.info("loading user factory"); 265 logger.info("loading user factory");
265 266
267 Node factory = Config.getNodeXPath(USER_FACTORY);
268
266 String className = Config.getStringXPath( 269 String className = Config.getStringXPath(
267 USER_FACTORY, DEFAULT_USER_FACTORY); 270 factory, "text()", DEFAULT_USER_FACTORY);
268 271
269 try { 272 try {
270 Class clazz = Class.forName(className); 273 Class clazz = Class.forName(className);
271 userFactory = (UserFactory) clazz.newInstance(); 274 userFactory = (UserFactory) clazz.newInstance();
275
276 userFactory.setup(Config.getConfig(), factory);
272 } 277 }
273 catch (ClassNotFoundException cnfe) { 278 catch (ClassNotFoundException cnfe) {
274 logger.error(cnfe.getLocalizedMessage(), cnfe); 279 logger.error(cnfe.getLocalizedMessage(), cnfe);
275 } 280 }
276 catch (InstantiationException ie) { 281 catch (InstantiationException ie) {

http://dive4elements.wald.intevation.org