comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java @ 875:5e9efdda6894

merged gnv-artifacts/1.0
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:56 +0200
parents 05bf8534a35a
children f953c9a559d8
comparison
equal deleted inserted replaced
722:bb3ffe7d719e 875:5e9efdda6894
1 package de.intevation.gnv.transition;
2
3 import org.apache.log4j.Logger;
4 import org.w3c.dom.Node;
5
6 import de.intevation.gnv.artifacts.GNVArtifactBase;
7
8 /**
9 * This Factoryclass instantiates Objects of Type Transition.
10 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
11 *
12 */
13 public class TransitionFactory {
14
15 /**
16 * the logger, used to log exceptions and additonaly information
17 */
18 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
19
20 /**
21 * The Singleton instance of the Transitionfactory.
22 */
23 private static TransitionFactory instance = null;
24
25 /**
26 * Constructor
27 */
28 public TransitionFactory() {
29 super();
30 }
31
32 /**
33 * Returns the Instance of this Class.
34 * @return the Instance of this Class.
35 */
36 public static TransitionFactory getInstance() {
37 if (instance == null) {
38 instance = new TransitionFactory();
39 }
40 return instance;
41 }
42
43 /**
44 * Creates a new Transition using the Configuration that is provided by the
45 * XML-Node.
46 * @param configuration The configuration that should be used to initialize
47 * the new Transition
48 * @return a new Transition.
49 */
50 public Transition createTransition(Node configuration) {
51 log.debug("TransitionFactory.createTransition");
52 Transition state = null;
53 try {
54 String classname = ((org.w3c.dom.Element)configuration).getAttribute("transition");
55 state = (Transition) (Class.forName(classname).newInstance());
56 state.setup(configuration);
57 } catch (InstantiationException e) {
58 log.error(e, e);
59 } catch (IllegalAccessException e) {
60 log.error(e, e);
61 } catch (ClassNotFoundException e) {
62 log.error(e, e);
63 }
64 return state;
65 }
66 }
67 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org