Mercurial > dive4elements > gnv-client
annotate geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java @ 1127:ebeb56428409
Added license headers and license file.
geo-backend/trunk@1261 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 02 Nov 2010 17:52:22 +0000 |
parents | 1985d5db0feb |
children |
rev | line source |
---|---|
1127
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
1 /* |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
3 * |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
7 */ |
ebeb56428409
Added license headers and license file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1122
diff
changeset
|
8 |
132
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 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
|
10 |
1122
1985d5db0feb
Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
887
diff
changeset
|
11 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
|
12 |
132
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 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
|
14 |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 /** |
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
|
16 * @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
|
17 * |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 */ |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 public class QueryExecutorFactory { |
541
3cbf11c67fdc
Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
132
diff
changeset
|
20 |
3cbf11c67fdc
Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
132
diff
changeset
|
21 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
|
22 |
132
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 * 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
|
25 */ |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 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
|
27 |
885
1c3efbd2fc5a
Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
884
diff
changeset
|
28 |
132
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 * 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
|
31 */ |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 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
|
33 |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 /** |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 * 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
|
36 */ |
541
3cbf11c67fdc
Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
132
diff
changeset
|
37 public QueryExecutorFactory() { |
132
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 super(); |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 } |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 /** |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 * 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
|
43 * @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
|
44 */ |
541
3cbf11c67fdc
Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
132
diff
changeset
|
45 public static synchronized QueryExecutorFactory getInstance(){ |
3cbf11c67fdc
Experimental caching of SQL results via Ehache
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
132
diff
changeset
|
46 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
|
47 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
|
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 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
|
50 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
|
51 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
|
52 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
|
53 @Override |
1985d5db0feb
Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
887
diff
changeset
|
54 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
|
55 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
|
56 } |
1985d5db0feb
Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
887
diff
changeset
|
57 }); |
1985d5db0feb
Implemented a global configuration that should be used to initialize the geobackend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
887
diff
changeset
|
58 return instance = factory; |
541
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 |
132
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 instance = new QueryExecutorFactory(); |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
62 } |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
63 return instance; |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 } |
542
f0b6d0e2a0f6
Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
541
diff
changeset
|
65 |
f0b6d0e2a0f6
Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
541
diff
changeset
|
66 public void shutdown() { |
f0b6d0e2a0f6
Small fixes for Ehcache based SQL results caching.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
541
diff
changeset
|
67 } |
885
1c3efbd2fc5a
Removes trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
884
diff
changeset
|
68 |
132
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 /** |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 * Getting the QueryExecutor |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 * @return the QueryExecutor |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
72 */ |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
73 public QueryExecutor getQueryExecutor(){ |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
74 return new DefaultQueryExceutor(); |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
75 } |
5a583cff97ea
Implementation of the Datainfrastructure for fetching Data from different DataStores.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
76 } |