You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/03/30 22:56:29 UTC
[2/5] incubator-tamaya git commit: Added metainfo to env and sys prop
entries.
Added metainfo to env and sys prop entries.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/dbb9f4cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/dbb9f4cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/dbb9f4cb
Branch: refs/heads/master
Commit: dbb9f4cb71cb0e11266f8f28988aa8e36ea232ee
Parents: d75d194
Author: anatole <an...@apache.org>
Authored: Wed Mar 30 22:49:59 2016 +0200
Committer: anatole <an...@apache.org>
Committed: Wed Mar 30 22:49:59 2016 +0200
----------------------------------------------------------------------
.../tamaya/core/propertysource/EnvironmentPropertySource.java | 7 ++++++-
.../tamaya/core/propertysource/SimplePropertySource.java | 3 ++-
.../tamaya/core/propertysource/SystemPropertySource.java | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dbb9f4cb/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
index 1324ebd..140ca55 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -83,7 +84,11 @@ public class EnvironmentPropertySource implements PropertySource {
if(disabled){
return Collections.emptyMap();
}
- return System.getenv(); // already a map and unmodifiable
+ Map<String, String> entries = new HashMap<>(System.getenv());
+ for(Map.Entry<String, String> entry:System.getenv().entrySet()){
+ entries.put("_"+entry.getKey()+".source", getName());
+ }
+ return entries;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dbb9f4cb/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
index 3ae4f2d..ad46dac 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
@@ -50,8 +50,8 @@ public class SimplePropertySource extends BasePropertySource {
public SimplePropertySource(File propertiesLocation) {
super(0);
try {
- this.properties = load(propertiesLocation.toURI().toURL());
this.name = propertiesLocation.toString();
+ this.properties = load(propertiesLocation.toURI().toURL());
} catch (IOException e) {
throw new ConfigException("Failed to load properties from " + propertiesLocation, e);
}
@@ -118,6 +118,7 @@ public class SimplePropertySource extends BasePropertySource {
}
for (String key : props.stringPropertyNames()) {
properties.put(key, props.getProperty(key));
+ properties.put("_"+key+".source",getName());
}
} catch (IOException e) {
throw new ConfigException("Error loading properties " + propertiesFile, e);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dbb9f4cb/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
index a5b748f..40576fa 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
@@ -77,6 +77,7 @@ public class SystemPropertySource implements PropertySource {
Properties sysProps = System.getProperties();
for(String name: sysProps.stringPropertyNames()) {
props.put(name,sysProps.getProperty(name));
+ props.put("_"+name+".source",getName());
}
return props;
}