Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java @ 542:f0b6d0e2a0f6
Small fixes for Ehcache based SQL results caching.
geo-backend/trunk@463 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 19 Dec 2009 14:45:21 +0000 |
parents | 3cbf11c67fdc |
children | 12f88239fb33 |
line wrap: on
line source
/** * */ package de.intevation.gnv.geobackend.base.query; import org.apache.log4j.Logger; /** * @author Tim Englich <tim.englich@intevation.de> * */ public class QueryExecutorFactory { public static final String QUERY_EXECUTOR_FACTORY = "query.executor.factory"; /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(QueryExecutorFactory.class); /** * The singleton Instance of this Factory. */ private static QueryExecutorFactory instance = null; /** * Basic-Constructor of this Class */ public QueryExecutorFactory() { super(); } /** * This Method provides an singleton Instance of this Class. * @return an singleton Instance of this Class */ public static synchronized QueryExecutorFactory getInstance(){ if (instance == null) { String className = System.getProperty(QUERY_EXECUTOR_FACTORY); if (className != null) { try { Class clazz = Class.forName(className); final QueryExecutorFactory factory = (QueryExecutorFactory)clazz.newInstance(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { factory.shutdown(); } }); return instance = factory; } 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; } public void shutdown() { } /** * Getting the QueryExecutor * @return the QueryExecutor */ public QueryExecutor getQueryExecutor(){ return new DefaultQueryExceutor(); } }