Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java @ 657:af3f56758f59
merged gnv-artifacts/0.5
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:53 +0200 |
parents | a887074460b6 |
children | 9a828e5a2390 |
comparison
equal
deleted
inserted
replaced
590:5f5f273c8566 | 657:af3f56758f59 |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package de.intevation.gnv.transition; | |
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 TransitionFactory { | |
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 TransitionFactory instance = null; | |
23 | |
24 /** | |
25 * Constructor | |
26 */ | |
27 public TransitionFactory() { | |
28 super(); | |
29 } | |
30 | |
31 public static TransitionFactory getInstance() { | |
32 if (instance == null) { | |
33 instance = new TransitionFactory(); | |
34 } | |
35 return instance; | |
36 } | |
37 | |
38 public Transition createTransition(Node configuration) { | |
39 log.debug("TransitionFactory.createTransition"); | |
40 Transition state = null; | |
41 try { | |
42 String classname = ((org.w3c.dom.Element)configuration).getAttribute("transition"); | |
43 state = (Transition) (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 } |