tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject incubator-tamaya-sandbox git commit: Fixed build issues.
Date Mon, 27 Feb 2017 07:17:41 GMT
Repository: incubator-tamaya-sandbox
Updated Branches:
  refs/heads/master ca485b2e7 -> 275cd625b


Fixed build issues.


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/275cd625
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/275cd625
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/275cd625

Branch: refs/heads/master
Commit: 275cd625b172e841c23dfdb6f07e28a038668352
Parents: ca485b2
Author: anatole <anatole@apache.org>
Authored: Mon Feb 27 08:17:28 2017 +0100
Committer: anatole <anatole@apache.org>
Committed: Mon Feb 27 08:17:28 2017 +0100

----------------------------------------------------------------------
 .../tamaya/commons/IniConfigurationFormat.java  | 23 +++++++++++------
 .../tamaya/commons/XmlConfigurationFormat.java  | 27 ++++++++++++--------
 .../apache/tamaya/etcd/EtcdPropertySource.java  |  8 ++++++
 .../tamaya/remote/BaseRemotePropertySource.java |  2 +-
 4 files changed, 41 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/275cd625/apache-commons/src/main/java/org/apache/tamaya/commons/IniConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/apache-commons/src/main/java/org/apache/tamaya/commons/IniConfigurationFormat.java
b/apache-commons/src/main/java/org/apache/tamaya/commons/IniConfigurationFormat.java
index de1a35b..d0e8c05 100644
--- a/apache-commons/src/main/java/org/apache/tamaya/commons/IniConfigurationFormat.java
+++ b/apache-commons/src/main/java/org/apache/tamaya/commons/IniConfigurationFormat.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tamaya.commons;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalINIConfiguration;
 import org.apache.commons.configuration.SubnodeConfiguration;
 import org.apache.tamaya.ConfigException;
@@ -26,6 +25,8 @@ import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationDataBuilder;
 import org.apache.tamaya.format.ConfigurationFormat;
 
+import java.io.File;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -49,22 +50,28 @@ public class IniConfigurationFormat implements ConfigurationFormat {
     }
 
     @Override
-    public ConfigurationData readConfiguration(URL url) {
-        ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(url.toString(), this);
+    public ConfigurationData readConfiguration(String name, InputStream inputStream) {
+        ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(name, this);
         try {
-            HierarchicalINIConfiguration commonIniConfiguration = new HierarchicalINIConfiguration(url);
-            for(String section:commonIniConfiguration.getSections()){
+            HierarchicalINIConfiguration commonIniConfiguration;
+            File file = new File(name);
+            if (file.exists()) {
+                commonIniConfiguration = new HierarchicalINIConfiguration(file);
+            }else{
+                commonIniConfiguration = new HierarchicalINIConfiguration(new URL(name));
+            }
+            for (String section : commonIniConfiguration.getSections()) {
                 SubnodeConfiguration sectionConfig = commonIniConfiguration.getSection(section);
                 Map<String, String> properties = new HashMap<>();
                 Iterator<String> keyIter = sectionConfig.getKeys();
-                while(keyIter.hasNext()){
+                while (keyIter.hasNext()) {
                     String key = keyIter.next();
                     properties.put(key, sectionConfig.getString(key));
                 }
                 builder.addSectionProperties(section, properties);
             }
-        } catch (ConfigurationException e) {
-            throw new ConfigException("Failed to parse ini-file format from " + url, e);
+        } catch (Exception e) {
+            throw new ConfigException("Failed to parse ini-file format from " + name, e);
         }
         return builder.build();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/275cd625/apache-commons/src/main/java/org/apache/tamaya/commons/XmlConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/apache-commons/src/main/java/org/apache/tamaya/commons/XmlConfigurationFormat.java
b/apache-commons/src/main/java/org/apache/tamaya/commons/XmlConfigurationFormat.java
index 9f3a503..ecb154c 100644
--- a/apache-commons/src/main/java/org/apache/tamaya/commons/XmlConfigurationFormat.java
+++ b/apache-commons/src/main/java/org/apache/tamaya/commons/XmlConfigurationFormat.java
@@ -18,13 +18,14 @@
  */
 package org.apache.tamaya.commons;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationDataBuilder;
 import org.apache.tamaya.format.ConfigurationFormat;
 
+import java.io.File;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.Iterator;
 
@@ -46,17 +47,23 @@ public class XmlConfigurationFormat implements ConfigurationFormat {
     }
 
     @Override
-    public ConfigurationData readConfiguration(URL url) {
-        ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(url.toString(), this);
+    public ConfigurationData readConfiguration(String name, InputStream inputStream) {
+        ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(name, this);
         try {
-            XMLConfiguration commonXmlConfiguration = new XMLConfiguration(url);
-                Iterator<String> keyIter = commonXmlConfiguration.getKeys();
-                while(keyIter.hasNext()){
-                    String key = keyIter.next();
-                    builder.addDefaultProperty(key, commonXmlConfiguration.getString(key));
+            XMLConfiguration commonXmlConfiguration;
+            File file = new File(name);
+            if (file.exists()) {
+                commonXmlConfiguration = new XMLConfiguration(file);
+            }else{
+                commonXmlConfiguration = new XMLConfiguration(new URL(name));
             }
-        } catch (ConfigurationException e) {
-            throw new ConfigException("Failed to parse xml-file format from " + url, e);
+            Iterator<String> keyIter = commonXmlConfiguration.getKeys();
+            while (keyIter.hasNext()) {
+                String key = keyIter.next();
+                builder.addDefaultProperty(key, commonXmlConfiguration.getString(key));
+            }
+        } catch (Exception e) {
+            throw new ConfigException("Failed to parse xml-file format from " + name, e);
         }
         return builder.build();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/275cd625/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 326097f..b3469fc 100644
--- a/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
+++ b/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
@@ -53,6 +53,8 @@ public class EtcdPropertySource extends BasePropertySource
         for(String s:backends){
             etcdBackends.add(new EtcdAccessor(s));
         }
+        setDefaultOrdinal(1000);
+        setName("etcd");
     }
 
     public EtcdPropertySource(Collection<String> backends){
@@ -60,10 +62,14 @@ public class EtcdPropertySource extends BasePropertySource
         for(String s:backends){
             etcdBackends.add(new EtcdAccessor(s));
         }
+        setDefaultOrdinal(1000);
+        setName("etcd");
     }
 
     public EtcdPropertySource(){
         prefix = System.getProperty("tamaya.etcd.prefix", "");
+        setDefaultOrdinal(1000);
+        setName("etcd");
     }
 
     public EtcdPropertySource(String... backends){
@@ -71,6 +77,8 @@ public class EtcdPropertySource extends BasePropertySource
         for (String s : backends) {
             etcdBackends.add(new EtcdAccessor(s));
         }
+        setDefaultOrdinal(1000);
+        setName("etcd");
     }
 
     public String getPrefix() {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/275cd625/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
----------------------------------------------------------------------
diff --git a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java b/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
index 19bebb5..fcf2256 100644
--- a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
+++ b/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
@@ -65,7 +65,7 @@ public abstract class BaseRemotePropertySource implements PropertySource{
         ConfigurationFormat format = getConfigurationFormat();
         for(URL url:getAccessURLs()) {
             try(InputStream is = url.openStream()) {
-                ConfigurationData data = format.readConfiguration(url);
+                ConfigurationData data = format.readConfiguration(url.toString(), is);
                 if(data!=null){
                     Map<String,String> newProperties = mapConfigurationData(data);
                     // the configs served by the tamaya server module has a 'data' root section
containing the


Mime
View raw message