From: <fg...@us...> - 2007-07-23 15:03:28
|
Revision: 366 http://svn.sourceforge.net/openutils/?rev=366&view=rev Author: fgiust Date: 2007-07-23 08:03:27 -0700 (Mon, 23 Jul 2007) Log Message: ----------- added getProperties() and getProperty() to the base envPropertyConfigurer Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java 2007-07-13 08:00:12 UTC (rev 365) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java 2007-07-23 15:03:27 UTC (rev 366) @@ -39,8 +39,6 @@ private DataSource dataSource; - private Properties props; - private ApplicationContext applicationContext; public void setSqlQuery(String sqlQuery) @@ -64,13 +62,21 @@ /** * Get Spring Context proprieties. * @return A properties object containing all spring properties. - * @throws IOException Any IOException. */ - public Properties getProperties() throws IOException + @Override + public Properties getProperties() { - props = mergeProperties(); + // loadAndRefresh(); @todo is this needed anymore? + return properties; + } + + /** + * @throws IOException + */ + private void loadAndRefresh() throws IOException + { + properties = mergeProperties(); refresh(); - return props; } /** @@ -97,7 +103,7 @@ String parmValue = rs.getString(2); log.debug("Configuring property {}={}", parmName, parmValue); - props.put(parmName, parmValue); + properties.put(parmName, parmValue); } } @@ -122,7 +128,7 @@ } /** - * + * */ private void manuallyLoadDatasource() { @@ -131,7 +137,7 @@ dataSource = (DataSource) applicationContext.getBean(dataSourceName); try { - props = mergeProperties(); + properties = mergeProperties(); } catch (IOException e) { @@ -151,7 +157,8 @@ try { - Properties mergedProps = getProperties(); + loadAndRefresh(); + Properties mergedProps = properties; // Convert the merged properties, if necessary. convertProperties(mergedProps); Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2007-07-13 08:00:12 UTC (rev 365) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2007-07-23 15:03:27 UTC (rev 366) @@ -1,6 +1,5 @@ package it.openutils.deployment.spring; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; @@ -57,6 +56,11 @@ private String fileLocation; /** + * Cached properties (super field is private). + */ + protected Properties properties; + + /** * Are properties inherited from default configuration? default is true, */ private boolean inherit = true; @@ -205,6 +209,7 @@ log.error("No properties found at {}", replacedLocations); } + this.properties = props; super.setProperties(props); } @@ -280,4 +285,28 @@ return StringUtils.EMPTY; } + /** + * Returns the Properties loaded by this configurer. + * @return Properties + */ + public Properties getProperties() + { + return properties; + } + + /** + * Returns a single property. + * @param key Property key + * @return property value or <code>null</code> if not found. + */ + public String getProperty(String key) + { + // better be safe, it doesn't hurt + if (properties == null) + { + return null; + } + return properties.getProperty(key); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |