Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java @ 1114:7e085bfb107b
Bugfix: Histogram width results in an IllegalArgumentException (issue320).
gnv-artifacts/trunk@1253 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 30 Jun 2010 13:05:42 +0000 |
parents | 05bf8534a35a |
children | f953c9a559d8 |
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 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
|
2 |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
3 import org.apache.log4j.Logger; |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
4 import org.w3c.dom.Node; |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
5 |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
6 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
|
7 |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
8 /** |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
9 * 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
|
10 * @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
|
11 * |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 public class TransitionFactory { |
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 /** |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 * 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
|
17 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 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
|
19 |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
20 /** |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
21 * The Singleton instance of the Transitionfactory. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
22 */ |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 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
|
24 |
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 * Constructor |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 */ |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 public TransitionFactory() { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 super(); |
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 |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
32 /** |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
33 * Returns the Instance of this Class. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
34 * @return the Instance of this Class. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
35 */ |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 public static TransitionFactory getInstance() { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 if (instance == null) { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 instance = new TransitionFactory(); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 return instance; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 |
824
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
43 /** |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
44 * 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
|
45 * XML-Node. |
835
2423cefe7d39
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
824
diff
changeset
|
46 * @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
|
47 * the new Transition |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
48 * @return a new Transition. |
7e5995c47125
Added more Javadoc.
Tim Englich <tim.englich@intevation.de>
parents:
813
diff
changeset
|
49 */ |
337
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 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
|
51 log.debug("TransitionFactory.createTransition"); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 Transition state = null; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 try { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 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
|
55 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
|
56 state.setup(configuration); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
57 } catch (InstantiationException e) { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 log.error(e, e); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 } catch (IllegalAccessException e) { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 log.error(e, e); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 } catch (ClassNotFoundException e) { |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
62 log.error(e, e); |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
63 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 return state; |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
65 } |
a887074460b6
Last Step of the Refactoring Work on the Transition Model.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
66 } |
836
05bf8534a35a
Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
835
diff
changeset
|
67 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |