diff options
author | Robert Greig <rgreig@apache.org> | 2006-12-26 21:10:20 +0000 |
---|---|---|
committer | Robert Greig <rgreig@apache.org> | 2006-12-26 21:10:20 +0000 |
commit | 779bdce3e5a2541b28c28892dd19b3bd7cc72ece (patch) | |
tree | 80153050d440898679ef59d09b3a66a2dc911dd8 /java/common/src | |
parent | 6536407690660e10529c826ab3aa21baaa121ea1 (diff) | |
download | qpid-python-779bdce3e5a2541b28c28892dd19b3bd7cc72ece.tar.gz |
QPID-227 Renamed version.properties to qpidversion.properties due to clash with a dependency also using version.properties. Also improved robustness where properties file does not contain expected properties.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@490373 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/common/QpidProperties.java | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java b/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java index 4b281e9f8d..f4f764db1b 100644 --- a/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java +++ b/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java @@ -20,12 +20,18 @@ */ package org.apache.qpid.common; +import org.apache.log4j.Logger; + import java.util.Properties; +import java.util.Map; import java.io.IOException; +import java.io.InputStream; public class QpidProperties { - public static final String VERSION_RESOURCE = "version.properties"; + private static final Logger _logger = Logger.getLogger(QpidProperties.class); + + public static final String VERSION_RESOURCE = "qpidversion.properties"; public static final String PRODUCT_NAME_PROPERTY = "qpid.name"; public static final String RELEASE_VERSION_PROPERTY = "qpid.version"; @@ -44,16 +50,34 @@ public class QpidProperties try { - props.load(QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE)); + InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE); + if (propertyStream == null) + { + _logger.warn("Unable to find resource " + VERSION_RESOURCE + " from classloader"); + } + else + { + props.load(propertyStream); + + if (_logger.isDebugEnabled()) + { + _logger.debug("Dumping QpidProperties"); + for (Map.Entry<Object,Object> entry : props.entrySet()) + { + _logger.debug("Property: " + entry.getKey() + " Value: "+ entry.getValue()); + } + _logger.debug("End of property dump"); + } - productName = props.getProperty(PRODUCT_NAME_PROPERTY); - releaseVersion = props.getProperty(RELEASE_VERSION_PROPERTY); - buildVersion = props.getProperty(BUILD_VERSION_PROPERTY); + productName = readPropertyValue(props, PRODUCT_NAME_PROPERTY); + releaseVersion = readPropertyValue(props, RELEASE_VERSION_PROPERTY); + buildVersion = readPropertyValue(props, BUILD_VERSION_PROPERTY); + } } catch (IOException e) { // Log a warning about this and leave the values initialized to unknown. - System.err.println("Could not load version.properties resource."); + _logger.error("Could not load version.properties resource: " + e, e); } } @@ -77,6 +101,16 @@ public class QpidProperties return getProductName() + " - " + getReleaseVersion() + " build: " + getBuildVersion(); } + private static String readPropertyValue(Properties props, String propertyName) + { + String retVal = (String) props.get(propertyName); + if (retVal == null) + { + retVal = DEFAULT; + } + return retVal; + } + public static void main(String[] args) { System.out.println(getVersionString()); |