Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactFactoryUtilities.java @ 117:ef157bd2fa92
LanguageSupport integrated
gnv-artifacts/trunk@178 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 02 Oct 2009 14:24:47 +0000 |
parents | 158e89c2263b |
children | 7fb9441dd8af |
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 /** |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
14 * @author Tim Englich <tim.englich@intevation.de> |
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 */ |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 public class ArtifactFactoryUtilities { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 /** |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 * the logger, used to log exceptions and additonaly information |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 */ |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 private static Logger log = Logger.getLogger(ArtifactFactoryUtilities.class); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 /** |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 * Constructor |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 */ |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 public ArtifactFactoryUtilities() { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 } |
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 public ArtifactFactory createArtitfactFactor(Document config, Node artifactFactoryNode){ |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 String className =artifactFactoryNode.getTextContent(); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
30 |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 ArtifactFactory factory = null; |
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 try { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 Class clazz = Class.forName(className); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 factory = (ArtifactFactory)clazz.newInstance(); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 catch (ClassNotFoundException cnfe) { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 log.error(cnfe.getLocalizedMessage(), cnfe); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 catch (InstantiationException ie) { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 log.error(ie.getLocalizedMessage(), ie); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 catch (ClassCastException cce) { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 log.error(cce.getLocalizedMessage(), cce); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
45 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 catch (IllegalAccessException iae) { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 log.error(iae.getLocalizedMessage(), iae); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 } |
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 if (factory != null) { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 factory.setup(config, artifactFactoryNode); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 log.info("Registering '" + factory.getName() + "' as artifact factory."); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 return factory; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 } |