annotate geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java @ 1122:1985d5db0feb

Implemented a global configuration that should be used to initialize the geobackend. geo-backend/trunk@1149 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 Jun 2010 13:31:07 +0000
parents b757def3ff55
children ebeb56428409
rev   line source
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.geobackend.base.query;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
1122
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
3 import de.intevation.gnv.geobackend.config.Configuration;
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
4
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 /**
887
b757def3ff55 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 886
diff changeset
8 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 *
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 public class QueryExecutorFactory {
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
12
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
13 public static final String QUERY_EXECUTOR_FACTORY = "query.executor.factory";
885
1c3efbd2fc5a Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 884
diff changeset
14
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 * the logger, used to log exceptions and additonaly information
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 private static Logger log = Logger.getLogger(QueryExecutorFactory.class);
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19
885
1c3efbd2fc5a Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 884
diff changeset
20
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 * The singleton Instance of this Factory.
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 private static QueryExecutorFactory instance = null;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 * Basic-Constructor of this Class
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 */
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
29 public QueryExecutorFactory() {
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 super();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 * This Method provides an singleton Instance of this Class.
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 * @return an singleton Instance of this Class
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 */
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
37 public static synchronized QueryExecutorFactory getInstance(){
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
38 if (instance == null) {
1122
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
39 Configuration config = Configuration.getInstance();
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
40
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
41 if (config.isCacheEnabled()) {
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
42 final QueryExecutorFactory factory =
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
43 new CachingQueryExecutorFactory();
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
44 Runtime.getRuntime().addShutdownHook(new Thread() {
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
45 @Override
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
46 public void run() {
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
47 factory.shutdown();
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
48 }
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
49 });
1985d5db0feb Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 887
diff changeset
50 return instance = factory;
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
51 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
52
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 instance = new QueryExecutorFactory();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 return instance;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 }
542
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
57
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
58 public void shutdown() {
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
59 }
885
1c3efbd2fc5a Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 884
diff changeset
60
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 * Getting the QueryExecutor
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 * @return the QueryExecutor
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 public QueryExecutor getQueryExecutor(){
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 return new DefaultQueryExceutor();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 }

http://dive4elements.wald.intevation.org