annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactFactoryUtilities.java @ 335:e964a3d8f7bc

Some Refactoring work done. Moved Transition to State gnv-artifacts/trunk@401 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 08 Dec 2009 08:39:03 +0000
parents 7fb9441dd8af
children 9a828e5a2390
rev   line source
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.utils;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Document;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Node;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.ArtifactFactory;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 * @author Tim Englich <tim.englich@intevation.de>
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
14 *
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 public class ArtifactFactoryUtilities {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 * the logger, used to log exceptions and additonaly information
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 */
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
20 private static Logger log = Logger
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
21 .getLogger(ArtifactFactoryUtilities.class);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
22
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 * Constructor
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 public ArtifactFactoryUtilities() {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
29 public ArtifactFactory createArtitfactFactor(Document config,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
30 Node artifactFactoryNode) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
31 String className = artifactFactoryNode.getTextContent();
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 ArtifactFactory factory = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 try {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 Class clazz = Class.forName(className);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
37 factory = (ArtifactFactory) clazz.newInstance();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
38 } catch (ClassNotFoundException cnfe) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 log.error(cnfe.getLocalizedMessage(), cnfe);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
40 } catch (InstantiationException ie) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 log.error(ie.getLocalizedMessage(), ie);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
42 } catch (ClassCastException cce) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 log.error(cce.getLocalizedMessage(), cce);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
44 } catch (IllegalAccessException iae) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 log.error(iae.getLocalizedMessage(), iae);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 if (factory != null) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 factory.setup(config, artifactFactoryNode);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
50 log.info("Registering '" + factory.getName()
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
51 + "' as artifact factory.");
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 return factory;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 }

http://dive4elements.wald.intevation.org