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/11/13 22:28:09 UTC

[3/6] incubator-tamaya-sandbox git commit: TAMAYA-196: Added mutable name support to BaseProperty, simplifying downstream.

TAMAYA-196: Added mutable name support to BaseProperty, simplifying downstream.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/dd1d0d31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/dd1d0d31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/dd1d0d31

Branch: refs/heads/master
Commit: dd1d0d31f4d550a595906570cf80eabb7bf8eaa5
Parents: 003dc04
Author: anatole <an...@apache.org>
Authored: Sun Nov 13 23:14:32 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Nov 13 23:14:32 2016 +0100

----------------------------------------------------------------------
 .../tamaya/consul/ConsulPropertySource.java     |  2 +-
 .../apache/tamaya/consul/ConsulWriteTest.java   |  3 +--
 .../apache/tamaya/etcd/EtcdPropertySource.java  | 23 ++++++++------------
 .../ConfigDirPropertySourceProvider.java        |  4 ++--
 .../MetainfConfigPropertySourceProvider.java    |  4 ++--
 5 files changed, 15 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/dd1d0d31/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
----------------------------------------------------------------------
diff --git a/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java b/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
index 1936362..74b60eb 100644
--- a/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
+++ b/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
@@ -23,7 +23,7 @@ import com.google.common.net.HostAndPort;
 import com.orbitz.consul.Consul;
 import com.orbitz.consul.KeyValueClient;
 import com.orbitz.consul.model.kv.Value;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
 import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 import org.apache.tamaya.spi.PropertyValueBuilder;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/dd1d0d31/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java
----------------------------------------------------------------------
diff --git a/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java b/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java
index 2f0fc09..b66d68c 100644
--- a/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java
+++ b/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java
@@ -19,8 +19,7 @@
 package org.apache.tamaya.consul;
 
 import com.google.common.net.HostAndPort;
-import org.apache.tamaya.consul.ConsulPropertySource;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
 import org.junit.BeforeClass;
 
 import java.net.MalformedURLException;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/dd1d0d31/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
----------------------------------------------------------------------
diff --git a/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java b/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
index 5e129f7..0daa4bf 100644
--- a/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
+++ b/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.etcd;
 
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
 import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 import org.apache.tamaya.spi.PropertyValueBuilder;
@@ -44,6 +44,14 @@ public class EtcdPropertySource extends BasePropertySource
 
     private final boolean disabled = evaluateDisabled();
 
+    public EtcdPropertySource(){
+        super("etcd", 1000);
+    }
+
+    public EtcdPropertySource(int defaultOrdinal){
+        super("etcd", defaultOrdinal);
+    }
+
     private boolean evaluateDisabled() {
         String value = System.getProperty("tamaya.etcdprops.disable");
         if(value==null){
@@ -69,19 +77,6 @@ public class EtcdPropertySource extends BasePropertySource
         return getDefaultOrdinal();
     }
 
-    /**
-     * Returns the  default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
-     * @return the  default ordinal used, by default 0.
-     */
-    public int getDefaultOrdinal(){
-        return 1000;
-    }
-
-    @Override
-    public String getName() {
-        return "etcd";
-    }
-
     @Override
     public PropertyValue get(String key) {
         if(disabled){

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/dd1d0d31/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java
index 03183f2..fc38c73 100644
--- a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java
+++ b/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirPropertySourceProvider.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.propertysources;
 
 import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
+import org.apache.tamaya.format.MappedConfigurationDataPropertySource;
 import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
 import org.apache.tamaya.spi.PropertySource;
 
@@ -65,7 +65,7 @@ public class ConfigDirPropertySourceProvider extends AbstractPathPropertySourceP
                         "Failed to read configuration from " + url);
                 return Collections.emptySet();
             }
-            return asCollection(new FlattenedDefaultPropertySource(config));
+            return asCollection(new MappedConfigurationDataPropertySource(config));
         } catch (Exception e) {
             Logger.getLogger(getClass().getName()).log(Level.SEVERE,
                     "Failed to read configuration from " + url, e);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/dd1d0d31/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java
index 88164fa..d86f3fd 100644
--- a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java
+++ b/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProvider.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.propertysources;
 
 import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
+import org.apache.tamaya.format.MappedConfigurationDataPropertySource;
 import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
 import org.apache.tamaya.spi.PropertySource;
 
@@ -46,7 +46,7 @@ public class MetainfConfigPropertySourceProvider extends AbstractPathPropertySou
     protected Collection<PropertySource> getPropertySources(URL url) {
         try {
             ConfigurationData config = ConfigurationFormats.readConfigurationData(url);
-            return asCollection(new FlattenedDefaultPropertySource(config));
+            return asCollection(new MappedConfigurationDataPropertySource(config));
         } catch (Exception e) {
             Logger.getLogger(getClass().getName()).log(Level.SEVERE,
                     "Failed to read configuration from " + url, e);