Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactFactoryUtilities.java @ 657:af3f56758f59
merged gnv-artifacts/0.5
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:53 +0200 |
parents | 7fb9441dd8af |
children | 9a828e5a2390 |
comparison
equal
deleted
inserted
replaced
590:5f5f273c8566 | 657:af3f56758f59 |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package de.intevation.gnv.utils; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 import org.w3c.dom.Document; | |
8 import org.w3c.dom.Node; | |
9 | |
10 import de.intevation.artifacts.ArtifactFactory; | |
11 | |
12 /** | |
13 * @author Tim Englich <tim.englich@intevation.de> | |
14 * | |
15 */ | |
16 public class ArtifactFactoryUtilities { | |
17 /** | |
18 * the logger, used to log exceptions and additonaly information | |
19 */ | |
20 private static Logger log = Logger | |
21 .getLogger(ArtifactFactoryUtilities.class); | |
22 | |
23 /** | |
24 * Constructor | |
25 */ | |
26 public ArtifactFactoryUtilities() { | |
27 } | |
28 | |
29 public ArtifactFactory createArtitfactFactor(Document config, | |
30 Node artifactFactoryNode) { | |
31 String className = artifactFactoryNode.getTextContent(); | |
32 | |
33 ArtifactFactory factory = null; | |
34 | |
35 try { | |
36 Class clazz = Class.forName(className); | |
37 factory = (ArtifactFactory) clazz.newInstance(); | |
38 } catch (ClassNotFoundException cnfe) { | |
39 log.error(cnfe.getLocalizedMessage(), cnfe); | |
40 } catch (InstantiationException ie) { | |
41 log.error(ie.getLocalizedMessage(), ie); | |
42 } catch (ClassCastException cce) { | |
43 log.error(cce.getLocalizedMessage(), cce); | |
44 } catch (IllegalAccessException iae) { | |
45 log.error(iae.getLocalizedMessage(), iae); | |
46 } | |
47 | |
48 if (factory != null) { | |
49 factory.setup(config, artifactFactoryNode); | |
50 log.info("Registering '" + factory.getName() | |
51 + "' as artifact factory."); | |
52 } | |
53 return factory; | |
54 } | |
55 } |