view geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java @ 887:b757def3ff55

Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>' geo-backend/trunk@859 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 29 Mar 2010 09:45:05 +0000
parents 8b442223741c
children 1985d5db0feb
line wrap: on
line source
package de.intevation.gnv.geobackend.base.query;

import org.apache.log4j.Logger;

/**
 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
 *
 */
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() {
                        @Override
                        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();
    }
}

http://dive4elements.wald.intevation.org