annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactFactoryUtilities.java @ 99:bb45c5097cb6

ehcache Integration for storing the chartresultvalues gnv-artifacts/trunk@146 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 28 Sep 2009 14:17:15 +0000
parents e4ecf3188bdf
children 158e89c2263b
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.artifactdatabase.Config;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.ArtifactFactory;
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
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 * @author Tim Englich <tim.englich@intevation.de>
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 *
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 public class ArtifactFactoryUtilities {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 * the logger, used to log exceptions and additonaly information
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 private static Logger log = Logger.getLogger(ArtifactFactoryUtilities.class);
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
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 public ArtifactFactory createArtitfactFactor(Document config, Node artifactFactoryNode){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 String className =artifactFactoryNode.getTextContent();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 ArtifactFactory factory = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 try {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 Class clazz = Class.forName(className);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 factory = (ArtifactFactory)clazz.newInstance();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 catch (ClassNotFoundException cnfe) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 log.error(cnfe.getLocalizedMessage(), cnfe);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 catch (InstantiationException ie) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 log.error(ie.getLocalizedMessage(), ie);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 catch (ClassCastException cce) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 log.error(cce.getLocalizedMessage(), cce);
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 catch (IllegalAccessException iae) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 log.error(iae.getLocalizedMessage(), iae);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 if (factory != null) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 factory.setup(config, artifactFactoryNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 log.info("Registering '" + factory.getName() + "' as artifact 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 return factory;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 }

http://dive4elements.wald.intevation.org