tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [3/3] incubator-tamaya git commit: Added filter for extracting data section as delivered by the tamaya-server module.
Date Fri, 28 Aug 2015 16:17:00 GMT
Added filter for extracting data section as delivered by the tamaya-server module.


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

Branch: refs/heads/master
Commit: a0fa25c755dfb041eb96ab320ced8e7b48b54df4
Parents: 80c8fa6
Author: anatole <anatole@apache.org>
Authored: Fri Aug 28 18:16:12 2015 +0200
Committer: anatole <anatole@apache.org>
Committed: Fri Aug 28 18:16:12 2015 +0200

----------------------------------------------------------------------
 .../apache/tamaya/jodatime/PeriodConverter.java |  2 --
 .../tamaya/jodatime/DateTimeConverterIT.java    |  2 +-
 .../jodatime/DateTimeZoneConverterIT.java       |  2 +-
 .../org/apache/tamaya/jodatime/FullStackIT.java |  3 ---
 .../ConfigDirPropertySourceProvider.java        |  1 -
 .../MetainfConfigPropertySourceProvider.java    |  1 -
 .../tamaya/remote/BaseRemotePropertySource.java | 23 ++++++++++++++++----
 7 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
b/sandbox/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
index 6950606..f6ad67b 100644
--- a/sandbox/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
+++ b/sandbox/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
@@ -21,13 +21,11 @@ package org.apache.tamaya.jodatime;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.joda.time.MutablePeriod;
 import org.joda.time.Period;
-import org.joda.time.ReadWritablePeriod;
 import org.joda.time.format.ISOPeriodFormat;
 import org.joda.time.format.PeriodParser;
 
 import java.util.Locale;
 import java.util.Objects;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
----------------------------------------------------------------------
diff --git a/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
b/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
index 4681449..2c4130e 100644
--- a/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
+++ b/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
@@ -35,7 +35,7 @@ public class DateTimeConverterIT {
         List<PropertyConverter> formats = ServiceContext.getInstance()
                                                         .getServices(PropertyConverter.class);
 
-        PropertyConverter converter = formats.stream()
+        PropertyConverter<?> converter = formats.stream()
                                              .filter(s -> s instanceof DateTimeConverter)
                                              .findFirst().get();
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
----------------------------------------------------------------------
diff --git a/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
b/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
index eef0ecc..a72d84e 100644
--- a/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
+++ b/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
@@ -35,7 +35,7 @@ public class DateTimeZoneConverterIT {
         List<PropertyConverter> formats = ServiceContext.getInstance()
                                                         .getServices(PropertyConverter.class);
 
-        PropertyConverter converter = formats.stream()
+        PropertyConverter<?> converter = formats.stream()
                                              .filter(s -> s instanceof DateTimeZoneConverter)
                                              .findFirst().get();
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
----------------------------------------------------------------------
diff --git a/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java b/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
index fcba5d6..e6c3a9c 100644
--- a/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
+++ b/sandbox/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
@@ -18,18 +18,15 @@
  */
 package org.apache.tamaya.jodatime;
 
-import jdk.nashorn.internal.runtime.regexp.joni.Config;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.ConfigurationProvider;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
-import org.joda.time.format.ISODateTimeFormat;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.joda.time.format.ISODateTimeFormat.basicDateTime;
 import static org.joda.time.format.ISODateTimeFormat.dateTime;
 
 public class FullStackIT {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
b/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
index 83784a8..e3c9cbf 100644
--- a/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
+++ b/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
@@ -27,7 +27,6 @@ import org.apache.tamaya.spi.PropertySource;
 
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
b/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
index 55f27f9..0edbbc7 100644
--- a/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
+++ b/sandbox/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
@@ -27,7 +27,6 @@ import org.apache.tamaya.spi.PropertySource;
 
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a0fa25c7/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
----------------------------------------------------------------------
diff --git a/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
b/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
index 7cd4572..fd1bd7c 100644
--- a/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
+++ b/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java
@@ -60,16 +60,31 @@ public abstract class BaseRemotePropertySource implements PropertySource{
      * stay untouched.
      */
     public void reload(){
-        Map newProperties;
+        Map readProperties;
         ConfigurationFormat format = getConfigurationFormat();
         for(URL url:getAccessURLs()) {
             try(InputStream is = url.openStream()) {
                 ConfigurationData data = format.readConfiguration(url.toExternalForm(), is);
                 if(data!=null){
-                    newProperties = data.getDefaultSection();
-                    if(newProperties!=null){
+                    readProperties = data.getDefaultSection();
+                    if(readProperties!=null){
+                        Map<String,String> newProperties = new HashMap<>();
+                        for(Map.Entry<String,String> en:readProperties.entrySet()){
+                            // filter data entries
+                            if(en.getKey().startsWith("data.")) {
+                                newProperties.put(en.getKey().substring(5), en.getValue());
+                            }
+                        }
+                        // the configs served by the tamaya server module has a 'data' root
section containing the
+                        // config  entries. if not present, we assume an alternate format,
which is sued as is...
+                        if(newProperties.isEmpty()){
+                            Logger.getLogger(getClass().getName()).info(
+                                    "Loaded remote config from: " + url + ", does not have
a data section, using as is...");
+                            newProperties = readProperties;
+                        }
                         this.properties = newProperties;
-                        Logger.getLogger(getClass().getName()).info("Reloaded remote config
from: " + url);
+                        Logger.getLogger(getClass().getName()).info(
+                                "Reloaded remote config from: " + url + ", entriea read:
" + this.properties.size());
                     }
                 }
             }


Mime
View raw message