annotate gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java @ 1129:ccfa07b88476

merged geo-backend
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:01 +0200
parents f953c9a559d8
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
8
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 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
10
824
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
11 import org.apache.log4j.Logger;
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
12 import org.w3c.dom.Node;
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
13
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
14 import de.intevation.gnv.artifacts.GNVArtifactBase;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
15
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 /**
824
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
17 * This Factoryclass instantiates Objects of Type Transition.
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
18 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 337
diff changeset
19 *
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 public class TransitionFactory {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22
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 * 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
25 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 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
27
824
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
28 /**
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
29 * The Singleton instance of the Transitionfactory.
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
30 */
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 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
32
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 /**
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 * Constructor
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 */
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 public TransitionFactory() {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 super();
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39
824
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
40 /**
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
41 * Returns the Instance of this Class.
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
42 * @return the Instance of this Class.
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
43 */
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 public static TransitionFactory getInstance() {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 if (instance == null) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 instance = new TransitionFactory();
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 return instance;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50
824
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
51 /**
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
52 * Creates a new Transition using the Configuration that is provided by the
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
53 * XML-Node.
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 824
diff changeset
54 * @param configuration The configuration that should be used to initialize
824
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
55 * the new Transition
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
56 * @return a new Transition.
7e5995c47125 Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
57 */
337
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 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
59 log.debug("TransitionFactory.createTransition");
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 Transition state = null;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 try {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 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
63 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
64 state.setup(configuration);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 } catch (InstantiationException e) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 log.error(e, e);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 } catch (IllegalAccessException e) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 log.error(e, e);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 } catch (ClassNotFoundException e) {
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 log.error(e, e);
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 return state;
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 }
a887074460b6 Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 }
836
05bf8534a35a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 835
diff changeset
75 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org