Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StateFactory.java @ 108:50273a391e53
Added missing StateFactory class of the last commit.
flys-artifacts/trunk@1293 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 Feb 2011 11:11:03 +0000 |
parents | |
children | f077df8ad54c |
comparison
equal
deleted
inserted
replaced
107:a228b39494a9 | 108:50273a391e53 |
---|---|
1 package de.intevation.flys.artifacts.states; | |
2 | |
3 import javax.xml.xpath.XPathConstants; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import org.w3c.dom.Node; | |
8 | |
9 import de.intevation.artifactdatabase.state.State; | |
10 | |
11 import de.intevation.artifacts.common.utils.XMLUtils; | |
12 | |
13 | |
14 /** | |
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
16 */ | |
17 public class StateFactory { | |
18 | |
19 /** The logger used in this class */ | |
20 private static Logger logger = Logger.getLogger(StateFactory.class); | |
21 | |
22 /** The XPath to the classname of the state */ | |
23 public static final String XPATH_STATE = "@state"; | |
24 | |
25 | |
26 /** | |
27 * Creates a new State based on the configured class provided by | |
28 * <code>stateConf</code>. | |
29 * | |
30 * @param stateConf The configuration of the state. | |
31 * | |
32 * @return a State. | |
33 */ | |
34 public static State createState(Node stateConf) { | |
35 String clazz = (String) XMLUtils.xpath( | |
36 stateConf, XPATH_STATE, XPathConstants.STRING); | |
37 | |
38 State state = null; | |
39 | |
40 try { | |
41 logger.debug("Create a new State for class: " + clazz); | |
42 state = (State) Class.forName(clazz).newInstance(); | |
43 state.setup(stateConf); | |
44 } | |
45 catch (InstantiationException ie) { | |
46 logger.error(ie, ie); | |
47 } | |
48 catch (IllegalAccessException iae) { | |
49 logger.error(iae, iae); | |
50 } | |
51 catch (ClassNotFoundException cnfe) { | |
52 logger.error(cnfe, cnfe); | |
53 } | |
54 | |
55 return state; | |
56 } | |
57 } | |
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |