annotate geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java @ 886:8b442223741c

Ordered imports. Removed empty headers. geo-backend/trunk@856 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 29 Mar 2010 09:22:07 +0000
parents 1c3efbd2fc5a
children b757def3ff55
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
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 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
4
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 * @author Tim Englich <tim.englich@intevation.de>
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 *
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 public class QueryExecutorFactory {
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
10
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
11 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
12
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 * 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
15 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 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
17
885
1c3efbd2fc5a Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 884
diff changeset
18
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 * 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
21 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 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
23
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 * 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
26 */
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
27 public QueryExecutorFactory() {
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 super();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30
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 * 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
33 * @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
34 */
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
35 public static synchronized QueryExecutorFactory getInstance(){
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
36 if (instance == null) {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
37 String className = System.getProperty(QUERY_EXECUTOR_FACTORY);
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
38 if (className != null) {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
39 try {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
40 Class clazz = Class.forName(className);
542
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
41 final QueryExecutorFactory factory =
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
42 (QueryExecutorFactory)clazz.newInstance();
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
43 Runtime.getRuntime().addShutdownHook(new Thread() {
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 542
diff changeset
44 @Override
542
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
45 public void run() {
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
46 factory.shutdown();
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
47 }
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
48 });
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
49 return instance = factory;
541
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
50 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
51 catch (ClassNotFoundException cnfe) {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
52 log.error(cnfe);
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
53 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
54 catch (InstantiationException ie) {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
55 log.error(ie);
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
56 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
57 catch(IllegalAccessException iae) {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
58 log.error(iae);
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
59 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
60 catch (ClassCastException cce) {
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
61 log.error(cce);
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
62 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
63 }
3cbf11c67fdc Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 132
diff changeset
64
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 instance = new QueryExecutorFactory();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 return instance;
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 }
542
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
69
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
70 public void shutdown() {
f0b6d0e2a0f6 Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 541
diff changeset
71 }
885
1c3efbd2fc5a Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 884
diff changeset
72
132
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 /**
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 * Getting the QueryExecutor
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 * @return the QueryExecutor
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 */
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 public QueryExecutor getQueryExecutor(){
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 return new DefaultQueryExceutor();
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 }
5a583cff97ea Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 }

http://dive4elements.wald.intevation.org