diff artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.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 635310c6a20e
children 1259d192e3c3
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java	Mon Sep 07 13:22:48 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java	Tue Sep 08 06:29:52 2009 +0000
@@ -8,6 +8,8 @@
 import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.ArtifactContextFactory;
 
+import org.apache.log4j.Logger;
+
 /**
  * Bootstrap facility for the global context and the artifact factories.
  *
@@ -15,6 +17,8 @@
  */
 public class FactoryBootstrap
 {
+    private static Logger logger = Logger.getLogger(FactoryBootstrap.class);
+
     public static final String CONTEXT_FACTORY =
         "/artifact-database/factories/context-factory/text()";
 
@@ -42,16 +46,16 @@
             factory = (ArtifactContextFactory)clazz.newInstance();
         }
         catch (ClassNotFoundException cnfe) {
-            cnfe.printStackTrace(System.err);
+            logger.error(cnfe.getLocalizedMessage(), cnfe);
         }
         catch (InstantiationException ie) {
-            ie.printStackTrace(System.err);
+            logger.error(ie.getLocalizedMessage(), ie);
         }
         catch (ClassCastException cce) {
-            cce.printStackTrace(System.err);
+            logger.error(cce.getLocalizedMessage(), cce);
         }
         catch (IllegalAccessException iae) {
-            iae.printStackTrace(System.err);
+            logger.error(iae.getLocalizedMessage(), iae);
         }
 
         if (factory == null) {
@@ -67,7 +71,7 @@
         NodeList nodes = Config.getNodeSetXPath(ARTIFACT_FACTORIES);
 
         if (nodes == null) {
-            System.err.println("ERROR: no factories found");
+            logger.warn("No factories found");
             return;
         }
 
@@ -83,16 +87,16 @@
                 factory = (ArtifactFactory)clazz.newInstance();
             }
             catch (ClassNotFoundException cnfe) {
-                cnfe.printStackTrace(System.err);
+                logger.error(cnfe.getLocalizedMessage(), cnfe);
             }
             catch (InstantiationException ie) {
-                ie.printStackTrace(System.err);
+                logger.error(ie.getLocalizedMessage(), ie);
             }
             catch (ClassCastException cce) {
-                cce.printStackTrace(System.err);
+                logger.error(cce.getLocalizedMessage(), cce);
             }
             catch (IllegalAccessException iae) {
-                iae.printStackTrace(System.err);
+                logger.error(iae.getLocalizedMessage(), iae);
             }
 
             if (factory != null) {

http://dive4elements.wald.intevation.org