[ARIES-1311] Support for env:XXX variable names in property placeholders to access environment variables instead of system variables
git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-core@1760342 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index a2c1712..1a4622c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
<artifactId>org.apache.aries.blueprint.core</artifactId>
<packaging>bundle</packaging>
<name>Apache Aries Blueprint Core</name>
- <version>1.6.3-SNAPSHOT</version>
+ <version>1.7.0-SNAPSHOT</version>
<description>
This bundle contains the core implementation of Blueprint
along with the "ext" namespace handler.
diff --git a/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java b/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java
index 1990986..cde541f 100644
--- a/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java
+++ b/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java
@@ -122,7 +122,7 @@
LOGGER.debug("Retrieving property {}", val);
Object v = null;
if (v == null && systemProperties == SystemProperties.override) {
- v = System.getProperty(val);
+ v = getSystemProperty(val);
if (v != null) {
LOGGER.debug("Found system property {} with value {}", val, v);
}
@@ -134,7 +134,7 @@
}
}
if (v == null && systemProperties == SystemProperties.fallback) {
- v = System.getProperty(val);
+ v = getSystemProperty(val);
if (v != null) {
LOGGER.debug("Found system property {} with value {}", val, v);
}
@@ -151,6 +151,13 @@
return v != null ? v.toString() : null;
}
+ protected String getSystemProperty(String val) {
+ if (val.startsWith("env:")) {
+ return System.getenv(val.substring("env:".length()));
+ }
+ return System.getProperty(val);
+ }
+
@Override
protected String retrieveValue(String expression) {
LOGGER.debug("Retrieving Value from expression: {}", expression);