comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/StateFactory.java @ 335:e964a3d8f7bc

Some Refactoring work done. Moved Transition to State gnv-artifacts/trunk@401 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 08 Dec 2009 08:39:03 +0000
parents
children 9a828e5a2390
comparison
equal deleted inserted replaced
334:e37930705daa 335:e964a3d8f7bc
1 /**
2 *
3 */
4 package de.intevation.gnv.state;
5
6 import org.apache.log4j.Logger;
7 import org.w3c.dom.Node;
8
9 import de.intevation.gnv.artifacts.GNVArtifactBase;
10
11 /**
12 * @author Tim Englich <tim.englich@intevation.de>
13 *
14 */
15 public class StateFactory {
16
17 /**
18 * the logger, used to log exceptions and additonaly information
19 */
20 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
21
22 private static StateFactory instance = null;
23
24 /**
25 * Constructor
26 */
27 public StateFactory() {
28 super();
29 }
30
31 public static StateFactory getInstance() {
32 if (instance == null) {
33 instance = new StateFactory();
34 }
35 return instance;
36 }
37
38 public State createState(Node configuration) {
39 log.debug("StateFactory.createState");
40 State state = null;
41 try {
42 String classname = ((org.w3c.dom.Element)configuration).getAttribute("state");
43 state = (State) (Class.forName(classname).newInstance());
44 state.setup(configuration);
45 } catch (InstantiationException e) {
46 log.error(e, e);
47 } catch (IllegalAccessException e) {
48 log.error(e, e);
49 } catch (ClassNotFoundException e) {
50 log.error(e, e);
51 }
52 return state;
53 }
54
55 }

http://dive4elements.wald.intevation.org