Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java @ 171:7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 09 Oct 2009 07:54:48 +0000 |
parents | bb45c5097cb6 |
children | b5e55f460f0b |
comparison
equal
deleted
inserted
replaced
170:7be22e76c270 | 171:7fb9441dd8af |
---|---|
19 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; | 19 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; |
20 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; | 20 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; |
21 | 21 |
22 /** | 22 /** |
23 * @author Tim Englich <tim.englich@intevation.de> | 23 * @author Tim Englich <tim.englich@intevation.de> |
24 * | 24 * |
25 */ | 25 */ |
26 public class GNVArtifactContextFactory implements ArtifactContextFactory { | 26 public class GNVArtifactContextFactory implements ArtifactContextFactory { |
27 /** | 27 /** |
28 * the logger, used to log exceptions and additonaly information | 28 * the logger, used to log exceptions and additonaly information |
29 */ | 29 */ |
30 private static Logger log = Logger.getLogger(GNVArtifactContext.class); | 30 private static Logger log = Logger.getLogger(GNVArtifactContext.class); |
31 | 31 |
32 public static final String XPATH_GEOBACKEND_CONFIGURATION= "artifact-database/geo-backend/backend-configuration"; | 32 public static final String XPATH_GEOBACKEND_CONFIGURATION = "artifact-database/geo-backend/backend-configuration"; |
33 | 33 |
34 public static final String XPATH_GEOBACKEND_QUERYCONFIGURATION= "artifact-database/geo-backend/query-configuration"; | 34 public static final String XPATH_GEOBACKEND_QUERYCONFIGURATION = "artifact-database/geo-backend/query-configuration"; |
35 | 35 |
36 private final static String CACHECONFIGNODEPATH = "/artifact-database/ehcache/configuration"; | 36 private final static String CACHECONFIGNODEPATH = "/artifact-database/ehcache/configuration"; |
37 | 37 |
38 /** | 38 /** |
39 * Constructor | 39 * Constructor |
40 */ | 40 */ |
41 public GNVArtifactContextFactory() { | 41 public GNVArtifactContextFactory() { |
42 super(); | 42 super(); |
49 public Object createArtifactContext(Document config) { | 49 public Object createArtifactContext(Document config) { |
50 Object returnValue = null; | 50 Object returnValue = null; |
51 try { | 51 try { |
52 log.debug("GNVArtifactContextFactory.createArtifactContext"); | 52 log.debug("GNVArtifactContextFactory.createArtifactContext"); |
53 log.info("Initialisation of the Geo-BackendConnectionPool"); | 53 log.info("Initialisation of the Geo-BackendConnectionPool"); |
54 String backendConfigurationFile = Config.getStringXPath(config, XPATH_GEOBACKEND_CONFIGURATION); | 54 String backendConfigurationFile = Config.getStringXPath(config, |
55 XPATH_GEOBACKEND_CONFIGURATION); | |
55 Properties properties = getProperties(backendConfigurationFile); | 56 Properties properties = getProperties(backendConfigurationFile); |
56 ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); | 57 ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); |
57 cpf.initializeConnectionPool(properties); | 58 cpf.initializeConnectionPool(properties); |
58 | 59 |
59 log.info("Initialisation of the QueryContainer"); | 60 log.info("Initialisation of the QueryContainer"); |
60 String queryConfigurationFile = Config.getStringXPath(config, XPATH_GEOBACKEND_QUERYCONFIGURATION); | 61 String queryConfigurationFile = Config.getStringXPath(config, |
62 XPATH_GEOBACKEND_QUERYCONFIGURATION); | |
61 Properties queryProperties = getProperties(queryConfigurationFile); | 63 Properties queryProperties = getProperties(queryConfigurationFile); |
62 QueryContainerFactory qcf = QueryContainerFactory.getInstance(); | 64 QueryContainerFactory qcf = QueryContainerFactory.getInstance(); |
63 qcf.initializeQueryContainer(queryProperties); | 65 qcf.initializeQueryContainer(queryProperties); |
64 | 66 |
65 | |
66 log.info("Initialisation of the Cache"); | 67 log.info("Initialisation of the Cache"); |
67 String cacheConfigurationFile = Config.getStringXPath(config, CACHECONFIGNODEPATH); | 68 String cacheConfigurationFile = Config.getStringXPath(config, |
69 CACHECONFIGNODEPATH); | |
68 CacheFactory cf = CacheFactory.getInstance(); | 70 CacheFactory cf = CacheFactory.getInstance(); |
69 cf.initializeCache(cacheConfigurationFile); | 71 cf.initializeCache(cacheConfigurationFile); |
70 | 72 |
71 returnValue = new GNVArtifactContext(config); | 73 returnValue = new GNVArtifactContext(config); |
72 } catch (FileNotFoundException e) { | 74 } catch (FileNotFoundException e) { |
73 log.error(e,e); | 75 log.error(e, e); |
74 } catch (IOException e) { | 76 } catch (IOException e) { |
75 log.error(e,e); | 77 log.error(e, e); |
76 } catch (QueryContainerException e){ | 78 } catch (QueryContainerException e) { |
77 log.error(e,e); | 79 log.error(e, e); |
78 } | 80 } |
79 return returnValue; | 81 return returnValue; |
80 } | 82 } |
81 | 83 |
82 /** | 84 /** |
84 * @return | 86 * @return |
85 * @throws FileNotFoundException | 87 * @throws FileNotFoundException |
86 * @throws IOException | 88 * @throws IOException |
87 */ | 89 */ |
88 private Properties getProperties(String filePath) | 90 private Properties getProperties(String filePath) |
89 throws FileNotFoundException, IOException { | 91 throws FileNotFoundException, |
92 IOException { | |
90 InputStream inputStream = new FileInputStream(filePath); | 93 InputStream inputStream = new FileInputStream(filePath); |
91 Properties properties = new Properties(); | 94 Properties properties = new Properties(); |
92 properties.load(inputStream); | 95 properties.load(inputStream); |
93 return properties; | 96 return properties; |
94 } | 97 } |