annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/StateFactory.java @ 779:b1f5f2a8840f

Ordered imports. Removed needless imports. Removed empty headers. gnv-artifacts/trunk@854 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 29 Mar 2010 08:51:20 +0000
parents 9a828e5a2390
children c4156275c1e1
rev   line source
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.state;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
3 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
4
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
6
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Node;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 * @author Tim Englich <tim.englich@intevation.de>
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
11 *
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 public class StateFactory {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 * the logger, used to log exceptions and additonaly information
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 private static StateFactory instance = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 * Constructor
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 public StateFactory() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 super();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 public static StateFactory getInstance() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 if (instance == null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 instance = new StateFactory();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 return instance;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 public State createState(Node configuration) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 log.debug("StateFactory.createState");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 State state = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 String classname = ((org.w3c.dom.Element)configuration).getAttribute("state");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 state = (State) (Class.forName(classname).newInstance());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 state.setup(configuration);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 } catch (InstantiationException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 } catch (IllegalAccessException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 } catch (ClassNotFoundException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 return state;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 }

http://dive4elements.wald.intevation.org