diff geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java @ 132:5a583cff97ea

Implementation of the Datainfrastructure for fetching Data from different DataStores. geo-backend/trunk@12 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 04 Sep 2009 08:11:30 +0000
parents
children 3cbf11c67fdc
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java	Fri Sep 04 08:11:30 2009 +0000
@@ -0,0 +1,84 @@
+/**
+ *
+ */
+package de.intevation.gnv.geobackend.base.query.container;
+
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException;
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class QueryContainerFactory {
+    
+    /**
+     * the logger, used to log exceptions and additonaly information
+     */
+    private static Logger log = Logger.getLogger(QueryContainerFactory.class);
+
+    
+    /**
+     * The singleton Instance of this Factory.
+     */
+    private static QueryContainerFactory instance = null;
+
+    /**
+     * The ConnectionPool providing the Connections to the DatabaseBackends
+     */
+    private QueryContainer queryContainer = null;
+
+    /**
+     * Basic-Constructor of this Class
+     */
+    private QueryContainerFactory() {
+        super();
+    }
+
+    /**
+     * This Method provides an singleton Instance of this Class.
+     * @return an singleton Instance of this Class
+     */
+    public static QueryContainerFactory getInstance(){
+        if (instance == null){
+            instance = new QueryContainerFactory();
+        }
+        return instance;
+    }
+    
+    
+    /**
+     * Getting the QueryContainer
+     * @return the QueryContainer
+     */
+    public QueryContainer getQueryContainer(){
+        return this.queryContainer;
+    }
+
+    /**
+     * Initializes the QueryContainer.
+     * Should only be called once on system startup
+     * @param properties the Properties for the Individual Configuration of the QueryContainerbb
+     * @throws QueryContainerException 
+     */
+    public synchronized void initializeQueryContainer(Properties properties) throws QueryContainerException{
+        log.debug("ConnectionPoolFactory.initializeConnectionPool");
+        if (this.queryContainer == null){
+            this.queryContainer = new DefaultQueryContainer();
+            this.queryContainer.initialize(properties);
+        }else{
+            log.warn("ConnectionPool already initialized");
+        }
+    }
+
+    /**
+     * Checks if the QueryContainer has already been initialized.
+     * @return true if the QueryContainer is initialized.
+     */
+    public boolean isInitialized(){
+        return this.queryContainer != null;
+    }
+}

http://dive4elements.wald.intevation.org