Mercurial > dive4elements > gnv-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
1121:9d530f913729 | 1122:1985d5db0feb |
---|---|
1 package de.intevation.gnv.geobackend.base.query; | 1 package de.intevation.gnv.geobackend.base.query; |
2 | |
3 import de.intevation.gnv.geobackend.config.Configuration; | |
2 | 4 |
3 import org.apache.log4j.Logger; | 5 import org.apache.log4j.Logger; |
4 | 6 |
5 /** | 7 /** |
6 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | 8 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
32 * This Method provides an singleton Instance of this Class. | 34 * This Method provides an singleton Instance of this Class. |
33 * @return an singleton Instance of this Class | 35 * @return an singleton Instance of this Class |
34 */ | 36 */ |
35 public static synchronized QueryExecutorFactory getInstance(){ | 37 public static synchronized QueryExecutorFactory getInstance(){ |
36 if (instance == null) { | 38 if (instance == null) { |
37 String className = System.getProperty(QUERY_EXECUTOR_FACTORY); | 39 Configuration config = Configuration.getInstance(); |
38 if (className != null) { | 40 |
39 try { | 41 if (config.isCacheEnabled()) { |
40 Class clazz = Class.forName(className); | 42 final QueryExecutorFactory factory = |
41 final QueryExecutorFactory factory = | 43 new CachingQueryExecutorFactory(); |
42 (QueryExecutorFactory)clazz.newInstance(); | 44 Runtime.getRuntime().addShutdownHook(new Thread() { |
43 Runtime.getRuntime().addShutdownHook(new Thread() { | 45 @Override |
44 @Override | 46 public void run() { |
45 public void run() { | 47 factory.shutdown(); |
46 factory.shutdown(); | 48 } |
47 } | 49 }); |
48 }); | 50 return instance = factory; |
49 return instance = factory; | |
50 } | |
51 catch (ClassNotFoundException cnfe) { | |
52 log.error(cnfe); | |
53 } | |
54 catch (InstantiationException ie) { | |
55 log.error(ie); | |
56 } | |
57 catch(IllegalAccessException iae) { | |
58 log.error(iae); | |
59 } | |
60 catch (ClassCastException cce) { | |
61 log.error(cce); | |
62 } | |
63 } | 51 } |
64 | 52 |
65 instance = new QueryExecutorFactory(); | 53 instance = new QueryExecutorFactory(); |
66 } | 54 } |
67 return instance; | 55 return instance; |