view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java @ 893:8a652a451bc6

Removed trailing whitespace. geo-backend/trunk@934 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 17 Apr 2010 09:28:02 +0000
parents a277ebde74e4
children ebeb56428409
line wrap: on
line source
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;

/**
 * Factoryclass to provide a singleton-Instance of an
 * <code>QueryContainer</code>-Object
 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
 */
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 synchronized 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