view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.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 e4eacd613356
children 210716612c30
line wrap: on
line source
/**
 * 
 */
package de.intevation.gnv.geobackend.base.connectionpool;

import java.util.Properties;

import org.apache.log4j.Logger;

import de.intevation.gnv.geobackend.sde.connectionpool.ArcSDEConnectionPool;

/**
 * Factoryimplementation for the Interface ConnectionPool.
 * This factory delivers Instances of the Interface ConnectionPool.
 * @author Tim Englich <tim.englich@intevation.de>
 */
public class ConnectionPoolFactory {

    /**
     * the logger, used to log exceptions and additonaly information
     */
    private static Logger log = Logger.getLogger(ConnectionPoolFactory.class);

    
    /**
     * The singleton Instance of this Factory.
     */
    private static ConnectionPoolFactory instance = null;

    /**
     * The ConnectionPool providing the Connections to the DatabaseBackends
     */
    private ConnectionPool connectionPool = null;

    /**
     * Basic-Constructor of this Class
     */
    private ConnectionPoolFactory() {
    	super();
    }

    /**
     * This Method provides an singleton Instance of this Class.
     * @return an singleton Instance of this Class
     */
    public static ConnectionPoolFactory getInstance(){
        if (instance == null){
        	instance = new ConnectionPoolFactory();
        }
        return instance;
    }
    
    
    /**
     * Getting the ConnectionPool
     * @return the ConnectionPool
     */
    public ConnectionPool getConnectionPool(){
        return this.connectionPool;
    }

    /**
     * Initializes the ConnectionPool.
     * Should only be called once on system startup
     * @param properties the Properties for the Individual Configuration of the ConnectionPool
     */
    public void initializeConnectionPool(Properties properties){
        log.debug("ConnectionPoolFactory.initializeConnectionPool");
        if (this.connectionPool == null){
            //TODO: Hier k�nnte anhand eines Flags die Instanz des Connectionpools umgeschaltet werden.
            this.connectionPool = new ArcSDEConnectionPool();
            this.connectionPool.initialize(properties);
        }else{
            log.warn("ConnectionPool already initialized");
        }	
    }

    /**
     * Checks if the ConnectionPool has already been initialized.
     * @return true if the ConnectionPool is initialized.
     */
    public boolean isInitialized(){
        return this.connectionPool != null;
    }
}

http://dive4elements.wald.intevation.org