diff geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java @ 541:3cbf11c67fdc

Experimental caching of SQL results via Ehache geo-backend/trunk@462 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Dec 2009 16:13:52 +0000
parents 5a583cff97ea
children f0b6d0e2a0f6
line wrap: on
line diff
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java	Thu Dec 17 14:35:02 2009 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java	Fri Dec 18 16:13:52 2009 +0000
@@ -10,6 +10,8 @@
  *
  */
 public class QueryExecutorFactory {
+
+    public static final String QUERY_EXECUTOR_FACTORY = "query.executor.factory";
     
     /**
      * the logger, used to log exceptions and additonaly information
@@ -25,7 +27,7 @@
     /**
      * Basic-Constructor of this Class
      */
-    private QueryExecutorFactory() {
+    public QueryExecutorFactory() {
         super();
     }
 
@@ -33,8 +35,29 @@
      * This Method provides an singleton Instance of this Class.
      * @return an singleton Instance of this Class
      */
-    public static QueryExecutorFactory getInstance(){
-        if (instance == null){
+    public static synchronized QueryExecutorFactory getInstance(){
+        if (instance == null) {
+            String className = System.getProperty(QUERY_EXECUTOR_FACTORY);
+            if (className != null) {
+                try {
+                    Class clazz = Class.forName(className);
+                    instance = (QueryExecutorFactory)clazz.newInstance();
+                    return instance;
+                }
+                catch (ClassNotFoundException cnfe) {
+                    log.error(cnfe);
+                }
+                catch (InstantiationException ie) {
+                    log.error(ie);
+                }
+                catch(IllegalAccessException iae) {
+                    log.error(iae);
+                }
+                catch (ClassCastException cce) {
+                    log.error(cce);
+                }
+            }
+
             instance = new QueryExecutorFactory();
         }
         return instance;

http://dive4elements.wald.intevation.org