annotate gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java @ 765:f28a7eac542a

Integrated valid ODV-Export to the GNV-Artifacts gnv-artifacts/trunk@821 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 23 Mar 2010 14:09:03 +0000
parents a887074460b6
children 9a828e5a2390
rev   line source
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.transition;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Node;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import de.intevation.gnv.artifacts.GNVArtifactBase;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 /**
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 * @author Tim Englich <tim.englich@intevation.de>
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 *
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 public class TransitionFactory {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 /**
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 * the logger, used to log exceptions and additonaly information
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 private static TransitionFactory instance = null;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 /**
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 * Constructor
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 public TransitionFactory() {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 super();
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 public static TransitionFactory getInstance() {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 if (instance == null) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 instance = new TransitionFactory();
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 return instance;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 public Transition createTransition(Node configuration) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 log.debug("TransitionFactory.createTransition");
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 Transition state = null;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 try {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 String classname = ((org.w3c.dom.Element)configuration).getAttribute("transition");
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 state = (Transition) (Class.forName(classname).newInstance());
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 state.setup(configuration);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 } catch (InstantiationException e) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 log.error(e, e);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 } catch (IllegalAccessException e) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 log.error(e, e);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 } catch (ClassNotFoundException e) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 log.error(e, e);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 return state;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 }

http://dive4elements.wald.intevation.org