annotate gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java @ 369:77cd3a2bc381

Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase. gnv-artifacts/trunk@446 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Dec 2009 11:42:21 +0000
parents 2f7a28f211c7
children 3a0c0ad113d9
rev   line source
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.artifacts.context;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.io.FileInputStream;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import java.io.FileNotFoundException;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import java.io.IOException;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import java.io.InputStream;
369
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
10 import java.io.File;
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
11
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import java.util.Properties;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import org.apache.log4j.Logger;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import org.w3c.dom.Document;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import de.intevation.artifactdatabase.Config;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import de.intevation.artifacts.ArtifactContextFactory;
99
bb45c5097cb6 ehcache Integration for storing the chartresultvalues
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
19 import de.intevation.gnv.artifacts.cache.CacheFactory;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException;
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
23 import de.intevation.gnv.chart.XMLChartTheme;
369
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
24
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
25 import de.intevation.artifactdatabase.XMLUtils;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 * @author Tim Englich <tim.englich@intevation.de>
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
29 *
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 public class GNVArtifactContextFactory implements ArtifactContextFactory {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * the logger, used to log exceptions and additonaly information
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 private static Logger log = Logger.getLogger(GNVArtifactContext.class);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
36
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
37 public static final String XPATH_GEOBACKEND_CONFIGURATION = "artifact-database/geo-backend/backend-configuration";
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
38
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
39 public static final String XPATH_GEOBACKEND_QUERYCONFIGURATION = "artifact-database/geo-backend/query-configuration";
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
40
99
bb45c5097cb6 ehcache Integration for storing the chartresultvalues
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
41 private final static String CACHECONFIGNODEPATH = "/artifact-database/ehcache/configuration";
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
42
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
43 private final static String CHARTCONFIGNODEPATH = "/artifact-database/charttemplate/configuration";
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
44
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
45 public final static String CHARTTEMPLATE = "template";
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
46
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 * Constructor
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 public GNVArtifactContextFactory() {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 super();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 log.debug("GNVArtifactContextFactory.Constructor");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 * @see de.intevation.artifacts.ArtifactContextFactory#createArtifactContext(org.w3c.dom.Document)
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 public Object createArtifactContext(Document config) {
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
59 GNVArtifactContext returnValue = null;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 try {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 log.debug("GNVArtifactContextFactory.createArtifactContext");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 log.info("Initialisation of the Geo-BackendConnectionPool");
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
63 String backendConfigurationFile = Config.getStringXPath(config,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
64 XPATH_GEOBACKEND_CONFIGURATION);
203
226091ed3cbd Added relative locations for further required Configurationfiles . issue59
Tim Englich <tim.englich@intevation.de>
parents: 172
diff changeset
65 backendConfigurationFile = Config.replaceConfigDir(backendConfigurationFile);
226091ed3cbd Added relative locations for further required Configurationfiles . issue59
Tim Englich <tim.englich@intevation.de>
parents: 172
diff changeset
66
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 Properties properties = getProperties(backendConfigurationFile);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 cpf.initializeConnectionPool(properties);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
70
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 log.info("Initialisation of the QueryContainer");
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
72 String queryConfigurationFile = Config.getStringXPath(config,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
73 XPATH_GEOBACKEND_QUERYCONFIGURATION);
203
226091ed3cbd Added relative locations for further required Configurationfiles . issue59
Tim Englich <tim.englich@intevation.de>
parents: 172
diff changeset
74 queryConfigurationFile = Config.replaceConfigDir(queryConfigurationFile);
226091ed3cbd Added relative locations for further required Configurationfiles . issue59
Tim Englich <tim.englich@intevation.de>
parents: 172
diff changeset
75
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 Properties queryProperties = getProperties(queryConfigurationFile);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 QueryContainerFactory qcf = QueryContainerFactory.getInstance();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 qcf.initializeQueryContainer(queryProperties);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
79
99
bb45c5097cb6 ehcache Integration for storing the chartresultvalues
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
80 log.info("Initialisation of the Cache");
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
81 String cacheConfigurationFile = Config.getStringXPath(config,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
82 CACHECONFIGNODEPATH);
203
226091ed3cbd Added relative locations for further required Configurationfiles . issue59
Tim Englich <tim.englich@intevation.de>
parents: 172
diff changeset
83 cacheConfigurationFile = Config.replaceConfigDir(cacheConfigurationFile);
99
bb45c5097cb6 ehcache Integration for storing the chartresultvalues
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
84 CacheFactory cf = CacheFactory.getInstance();
bb45c5097cb6 ehcache Integration for storing the chartresultvalues
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
85 cf.initializeCache(cacheConfigurationFile);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
86
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
87 log.info("Initialisation of chart template");
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
88 String chartConfigFile = Config.getStringXPath(
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
89 config, CHARTCONFIGNODEPATH
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
90 );
369
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
91 chartConfigFile = Config.replaceConfigDir(chartConfigFile);
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
92 log.debug("Parse xml configuration of " + chartConfigFile);
369
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
93
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
94 Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile));
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
95 XMLChartTheme theme = new XMLChartTheme("XMLChartTheme");
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
96 if (tmpl != null) {
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
97 theme.applyXMLConfiguration(tmpl);
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
98 }
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
99 else {
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
100 log.error(
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
101 "Cannot load chart template from '" +
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
102 chartConfigFile + "'");
77cd3a2bc381 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 358
diff changeset
103 }
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
104
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 returnValue = new GNVArtifactContext(config);
358
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
106
2f7a28f211c7 Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 203
diff changeset
107 returnValue.put(CHARTTEMPLATE, theme);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 } catch (FileNotFoundException e) {
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
109 log.error(e, e);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 } catch (IOException e) {
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
111 log.error(e, e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
112 } catch (QueryContainerException e) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
113 log.error(e, e);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 return returnValue;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 * @param filePath
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 * @return
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 * @throws FileNotFoundException
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 * @throws IOException
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 private Properties getProperties(String filePath)
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
125 throws FileNotFoundException,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 99
diff changeset
126 IOException {
172
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
127 InputStream inputStream = null;
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
128 try {
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
129 inputStream = new FileInputStream(filePath);
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
130 Properties properties = new Properties();
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
131 properties.load(inputStream);
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
132 return properties;
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
133 }
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
134 finally {
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
135 if (inputStream != null) {
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
136 try { inputStream.close(); }
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
137 catch (IOException ioe) {}
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
138 }
b5e55f460f0b Closed small file descriptor leak in loading SQL properties file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
139 }
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 }

http://dive4elements.wald.intevation.org