comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java @ 1119:7c4f81f74c47

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

http://dive4elements.wald.intevation.org