You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rm...@apache.org on 2017/07/04 10:06:44 UTC

svn commit: r1800745 - /geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/SystemPropertyConfigSource.java

Author: rmannibucau
Date: Tue Jul  4 10:06:44 2017
New Revision: 1800745

URL: http://svn.apache.org/viewvc?rev=1800745&view=rev
Log:
adding org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy option since System properties being Properties are locking way too much for any runtime

Modified:
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/SystemPropertyConfigSource.java

Modified: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/SystemPropertyConfigSource.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/SystemPropertyConfigSource.java?rev=1800745&r1=1800744&r2=1800745&view=diff
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/SystemPropertyConfigSource.java (original)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/SystemPropertyConfigSource.java Tue Jul  4 10:06:44 2017
@@ -18,12 +18,14 @@
  */
 package org.apache.geronimo.config.configsource;
 
-import java.util.Map;
+import org.eclipse.microprofile.config.spi.ConfigSource;
 
 import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.Vetoed;
+import java.util.Map;
 
-import org.eclipse.microprofile.config.spi.ConfigSource;
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.toMap;
 
 /**
  * {@link ConfigSource} which uses {@link System#getProperties()}
@@ -33,18 +35,23 @@ import org.eclipse.microprofile.config.s
 @Typed
 @Vetoed
 public class SystemPropertyConfigSource extends BaseConfigSource {
+    private final Map<String, String> instance;
+
     public SystemPropertyConfigSource() {
         initOrdinal(400);
+        instance = "true".equalsIgnoreCase(getValue("org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy")) ?
+                System.getProperties().stringPropertyNames().stream().collect(toMap(identity(), System::getProperty)) :
+                Map.class.cast(System.getProperties());
     }
 
     @Override
     public Map<String, String> getProperties() {
-        return (Map) System.getProperties();
+        return instance;
     }
 
     @Override
     public String getValue(String key) {
-        return System.getProperty(key);
+        return instance.get(key);
     }
 
     @Override