comparison artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java @ 17:5a6b6a3debc7

Integrated logging into artifact database. artifacts/trunk@33 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 08 Sep 2009 06:29:52 +0000
parents e8626caac353
children d5dc2900392f
comparison
equal deleted inserted replaced
16:635310c6a20e 17:5a6b6a3debc7
4 import org.w3c.dom.Node; 4 import org.w3c.dom.Node;
5 5
6 import de.intevation.artifacts.ArtifactFactory; 6 import de.intevation.artifacts.ArtifactFactory;
7 import de.intevation.artifacts.Artifact; 7 import de.intevation.artifacts.Artifact;
8 8
9 import org.apache.log4j.Logger;
10
11 /**
12 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
13 */
9 public class DefaultArtifactFactory 14 public class DefaultArtifactFactory
10 implements ArtifactFactory 15 implements ArtifactFactory
11 { 16 {
17 private static Logger logger =
18 Logger.getLogger(DefaultArtifactFactory.class);
19
12 public static final String XPATH_TTL = "@ttl"; 20 public static final String XPATH_TTL = "@ttl";
13 public static final String XPATH_NAME = "@name"; 21 public static final String XPATH_NAME = "@name";
14 public static final String XPATH_DESCRIPTION = "@description"; 22 public static final String XPATH_DESCRIPTION = "@description";
15 public static final String XPATH_ARTIFACT = "@artifact"; 23 public static final String XPATH_ARTIFACT = "@artifact";
16 24
48 artifact.setup(identifier, context); 56 artifact.setup(identifier, context);
49 57
50 return artifact; 58 return artifact;
51 } 59 }
52 catch (InstantiationException ie) { 60 catch (InstantiationException ie) {
53 ie.printStackTrace(System.err); 61 logger.error(ie.getLocalizedMessage(), ie);
54 } 62 }
55 catch (IllegalAccessException iae) { 63 catch (IllegalAccessException iae) {
56 iae.printStackTrace(System.err); 64 logger.error(iae.getLocalizedMessage(), iae);
57 } 65 }
58 catch (ClassCastException cce) { 66 catch (ClassCastException cce) {
59 cce.printStackTrace(System.err); 67 logger.error(cce.getLocalizedMessage(), cce);
60 } 68 }
61 69
62 return null; 70 return null;
63 } 71 }
64 72
68 if (ttlString != null) { 76 if (ttlString != null) {
69 try { 77 try {
70 ttl = Long.valueOf(ttlString); 78 ttl = Long.valueOf(ttlString);
71 } 79 }
72 catch (NumberFormatException nfe) { 80 catch (NumberFormatException nfe) {
73 nfe.printStackTrace(System.err); 81 logger.warn("'" + ttlString + "' is not an integer.");
74 } 82 }
75 } 83 }
76 84
77 description = Config.getStringXPath( 85 description = Config.getStringXPath(
78 factoryNode, XPATH_DESCRIPTION, DEFAULT_DESCRIPTION); 86 factoryNode, XPATH_DESCRIPTION, DEFAULT_DESCRIPTION);
85 93
86 try { 94 try {
87 artifactClass = Class.forName(artifact); 95 artifactClass = Class.forName(artifact);
88 } 96 }
89 catch (ClassNotFoundException cnfe) { 97 catch (ClassNotFoundException cnfe) {
90 cnfe.printStackTrace(System.err); 98 logger.error(cnfe.getLocalizedMessage(), cnfe);
91 } 99 }
92 100
93 if (artifactClass == null) { 101 if (artifactClass == null) {
94 artifactClass = DefaultArtifact.class; 102 artifactClass = DefaultArtifact.class;
95 } 103 }

http://dive4elements.wald.intevation.org