Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java @ 1145:dfe1ac687c7f tip
added tags
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:16:15 +0200 |
parents | ebeb56428409 |
children |
line wrap: on
line source
/* * Copyright (c) 2010 by Intevation GmbH * * This program is free software under the LGPL (>=v2.1) * Read the file LGPL.txt coming with the software for details * or visit http://www.gnu.org/licenses/ if it does not exist. */ 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; } }