changeset 630:a72ecacccc91

Changed cache initialization so that we can use GNV without using a cache. gnv-artifacts/trunk@708 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 25 Feb 2010 07:25:21 +0000
parents d08b9ba148c5
children f4331a0df032
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java
diffstat 3 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Wed Feb 24 14:30:52 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Thu Feb 25 07:25:21 2010 +0000
@@ -1,3 +1,14 @@
+2010-02-25  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java:
+	  Better exception handling while cache configuration. The cache is not
+	  initialized, if no cache is configured in conf.xml. There would have been
+	  an exception without having a cache section in conf.xml. Now, it's
+	  possible to use GNV without using a cache.
+
+	* src/main/java/de/intevation/gnv/state/StateBase.java: Changed logger name
+	  from irritating 'GNVArtifactBase' to 'StateBase'.
+
 2010-02-24  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Wed Feb 24 14:30:52 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Thu Feb 25 07:25:21 2010 +0000
@@ -116,7 +116,7 @@
                     XPATH_GEOBACKEND_CONFIGURATION);
             backendConfigurationFile = Config.replaceConfigDir(
                 backendConfigurationFile);
-            
+
             Properties properties = getProperties(backendConfigurationFile);
             ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance();
             cpf.initializeConnectionPool(properties);
@@ -126,19 +126,12 @@
                     XPATH_GEOBACKEND_QUERYCONFIGURATION);
             queryConfigurationFile = Config.replaceConfigDir(
                 queryConfigurationFile);
-            
+
             Properties queryProperties = getProperties(queryConfigurationFile);
             QueryContainerFactory qcf = QueryContainerFactory.getInstance();
             qcf.initializeQueryContainer(queryProperties);
 
-            log.info("Initialisation of the Cache");
-            String cacheConfigurationFile = Config.getStringXPath(config,
-                    CACHECONFIGNODEPATH);
-            cacheConfigurationFile = Config.replaceConfigDir(
-                cacheConfigurationFile);
-
-            CacheFactory cf = CacheFactory.getInstance();
-            cf.initializeCache(cacheConfigurationFile);
+            configureCache(config);
 
             returnValue = new GNVArtifactContext(config);
 
@@ -173,6 +166,23 @@
         configureVerticalCrossSectionGroundFillColor(config, context);
     }
 
+
+    protected void configureCache(Document config) {
+        String cacheConfigurationFile = Config.getStringXPath(
+            config, CACHECONFIGNODEPATH);
+
+        if (cacheConfigurationFile != null
+        && !cacheConfigurationFile.equals(""))
+        {
+            log.info("Initialisation of the Cache");
+            cacheConfigurationFile = Config.replaceConfigDir(
+                cacheConfigurationFile);
+
+            CacheFactory cf = CacheFactory.getInstance();
+            cf.initializeCache(cacheConfigurationFile);
+        }
+    }
+
     protected void configureVerticalCrossSectionGroundFillColor(
         Document           config,
         GNVArtifactContext context
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Wed Feb 24 14:30:52 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Thu Feb 25 07:25:21 2010 +0000
@@ -69,7 +69,7 @@
     /**
      * the logger, used to log exceptions and additonaly information
      */
-    private static Logger log = Logger.getLogger(GNVArtifactBase.class);
+    private static Logger log = Logger.getLogger(StateBase.class);
 
     protected final static String MINVALUEFIELDNAME = "minvalue";
     protected final static String MAXVALUEFIELDNAME = "maxvalue";

http://dive4elements.wald.intevation.org