tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [12/16] incubator-tamaya git commit: Added Configuration.getConfigurationContext(), added EMPTY for config and context.
Date Sun, 13 Mar 2016 23:59:13 GMT
Added Configuration.getConfigurationContext(), added EMPTY for config and context.


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

Branch: refs/heads/master
Commit: d59dd8282cf14128da912974ee56ba37befbdb03
Parents: 7b6148c
Author: anatole <anatole@apache.org>
Authored: Mon Mar 14 00:37:43 2016 +0100
Committer: anatole <anatole@apache.org>
Committed: Mon Mar 14 00:37:43 2016 +0100

----------------------------------------------------------------------
 .../tamaya/functions/CombinedConfiguration.java |  7 ++
 .../functions/ConfigurationFunctions.java       | 72 +++++++++++++++++---
 .../tamaya/functions/EnrichedConfiguration.java |  6 ++
 .../tamaya/functions/FilteredConfiguration.java |  6 ++
 .../tamaya/functions/MappedConfiguration.java   |  6 ++
 5 files changed, 87 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d59dd828/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
b/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
index 543bd1b..8a479e9 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
 
 import java.util.Arrays;
 import java.util.HashMap;
@@ -130,6 +131,12 @@ class CombinedConfiguration implements Configuration{
     }
 
     @Override
+    public ConfigurationContext getContext() {
+        // TODO thjink on combining the participating contexts...
+        return configurations[0].getContext();
+    }
+
+    @Override
     public String toString() {
         return "CombinedConfiguration{" +
                 "name='" + name + '\'' +

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d59dd828/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
index eee3b02..624d10f 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
@@ -22,16 +22,10 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.*;
 
 import java.net.Inet4Address;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -96,11 +90,63 @@ public final class ConfigurationFunctions {
         }
 
         @Override
+        public ConfigurationContext getContext() {
+            return EMPTY_CONFIGURATION_CONTEXT;
+        }
+
+        @Override
         public String toString(){
             return "Configuration<empty>";
         }
     };
 
+    private static final ConfigurationContext EMPTY_CONFIGURATION_CONTEXT = new ConfigurationContext()
{
+        @Override
+        public void addPropertySources(PropertySource... propertySourcesToAdd) {
+            // ignore
+        }
+
+        @Override
+        public List<PropertySource> getPropertySources() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T>
propertyConverter) {
+            // ignore
+        }
+
+        @Override
+        public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters()
{
+            return Collections.emptyMap();
+        }
+
+        @Override
+        public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T>
type) {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<PropertyFilter> getPropertyFilters() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy() {
+            return PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+        }
+
+        @Override
+        public ConfigurationContextBuilder toBuilder() {
+            throw new UnsupportedOperationException("Cannot build from ConfigurationContext.EMPTY.");
+        }
+
+        @Override
+        public String toString(){
+            return "ConfigurationContext.EMPTY";
+        }
+    };
+
     /**
      * Private singleton constructor.
      */
@@ -583,11 +629,17 @@ public final class ConfigurationFunctions {
     }
 
     /**
-     * Accesses an empty PropertySource.
-     * @return an empty PropertySource, never null.
+     * Accesses an empty {@link Configuration}.
+     * @return an empty {@link Configuration}, never null.
      */
     public static Configuration emptyConfiguration(){
         return EMPTY_CONFIGURATION;
     }
 
+    /**
+     * Accesses an empty {@link ConfigurationContext}.
+     * @return an empty {@link ConfigurationContext}, never null.
+     */
+    public static ConfigurationContext emptyConfigurationContext(){ return EMPTY_CONFIGURATION_CONTEXT;
}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d59dd828/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
index 93eae3a..7969563 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -150,4 +151,9 @@ class EnrichedConfiguration implements Configuration {
         return query.query(this);
     }
 
+    @Override
+    public ConfigurationContext getContext() {
+        return baseConfiguration.getContext();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d59dd828/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
index 2d23450..e8acaaa 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -110,6 +111,11 @@ class FilteredConfiguration implements Configuration {
     }
 
     @Override
+    public ConfigurationContext getContext() {
+        return baseConfiguration.getContext();
+    }
+
+    @Override
     public String toString() {
         return "FilteredConfiguration{" +
                 "baseConfiguration=" + baseConfiguration +

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d59dd828/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
index 1170023..b93b9ca 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -116,6 +117,11 @@ class MappedConfiguration implements Configuration {
     }
 
     @Override
+    public ConfigurationContext getContext() {
+        return baseConfiguration.getContext();
+    }
+
+    @Override
     public String toString() {
         return "FilteredConfiguration{" +
                 "baseConfiguration=" + baseConfiguration +


Mime
View raw message