tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [1/2] incubator-tamaya git commit: TAMAYA-19: Streamlined API and impl.
Date Fri, 26 Dec 2014 00:42:53 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 718362334 -> 0b5d4feef


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/AggregatedPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/AggregatedPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/AggregatedPropertySource.java
index bb95ee5..420246b 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/AggregatedPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/AggregatedPropertySource.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.core.properties;
 
 import org.apache.tamaya.*;
+import org.apache.tamaya.core.config.ConfigChangeSet;
 
 import java.util.*;
 
@@ -77,20 +78,6 @@ class AggregatedPropertySource extends AbstractPropertySource {
 		return Collections.unmodifiableList(units);
 	}
 
-    /**
-     * Apply a config change to this item. Hereby the change must be related to the same
instance.
-     * @param change the config change
-     * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
-     * @throws UnsupportedOperationException when the configuration is not writable.
-     */
-    @Override
-    public void applyChanges(ConfigChangeSet change){
-        if(mutableProvider!=null)
-            mutableProvider.applyChanges(change);
-        else
-            super.applyChanges(change);
-    }
-
     @Override
     public Map<String,String> getProperties() {
 		Map<String, String> value = new HashMap<>();
@@ -109,10 +96,4 @@ class AggregatedPropertySource extends AbstractPropertySource {
         return value;
 	}
 
-    @Override
-	public ConfigChangeSet load() {
-        units.forEach(org.apache.tamaya.PropertySource::load);
-        return super.load();
-	}
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java
index 9510c95..e64cf07 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.core.properties;
 
 import org.apache.tamaya.*;
+import org.apache.tamaya.core.config.ConfigChangeSet;
 
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -80,11 +81,6 @@ class ContextualPropertySource implements PropertySource {
     }
 
     @Override
-    public ConfigChangeSet load(){
-        return getContextualMap().load();
-    }
-
-    @Override
     public Map<String,String> getProperties(){
         return getContextualMap().getProperties();
     }
@@ -100,17 +96,6 @@ class ContextualPropertySource implements PropertySource {
     }
 
     /**
-     * Apply a config change to this item. Hereby the change must be related to the same
instance.
-     * @param change the config change
-     * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
-     * @throws UnsupportedOperationException when the configuration is not writable.
-     */
-    @Override
-    public void applyChanges(ConfigChangeSet change){
-        getContextualMap().applyChanges(change);
-    }
-
-    /**
      * Access a cached PropertyMap.
      *
      * @param key the target environment key as returned by the environment key supplier,
not null.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/DelegatingPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/DelegatingPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/DelegatingPropertySource.java
index 3c08de7..e06f08d 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/DelegatingPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/DelegatingPropertySource.java
@@ -18,9 +18,7 @@
  */
 package org.apache.tamaya.core.properties;
 
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
+import org.apache.tamaya.core.config.ConfigChangeSet;
 import org.apache.tamaya.PropertySource;
 
 import java.util.*;
@@ -57,11 +55,6 @@ class DelegatingPropertySource implements PropertySource {
     }
 
     @Override
-    public ConfigChangeSet load(){
-        return mainMap.load();
-    }
-
-    @Override
     public Map<String,String> getProperties(){
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertySource.java
index b829769..a780bcd 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertySource.java
@@ -18,9 +18,7 @@
  */
 package org.apache.tamaya.core.properties;
 
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
+import org.apache.tamaya.core.config.ConfigChangeSet;
 import org.apache.tamaya.PropertySource;
 
 import java.util.HashMap;
@@ -51,21 +49,4 @@ class FilteredPropertySource extends AbstractPropertySource {
         return result;
     }
 
-    @Override
-    public ConfigChangeSet load(){
-        unit.load();
-        return super.load();
-    }
-
-    /**
-     * Apply a config change to this item. Hereby the change must be related to the same
instance.
-     * @param change the config change
-     * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
-     * @throws UnsupportedOperationException when the configuration is not writable.
-     */
-    @Override
-    public void applyChanges(ConfigChangeSet change){
-        this.unit.applyChanges(change);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertySource.java
index 333211d..f0e5eec 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertySource.java
@@ -19,12 +19,8 @@
 package org.apache.tamaya.core.properties;
 
 import java.io.Serializable;
-import java.time.Instant;
 import java.util.*;
 
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
 import org.apache.tamaya.PropertySource;
 
 /**
@@ -34,7 +30,6 @@ import org.apache.tamaya.PropertySource;
 final class FreezedPropertySource implements PropertySource, Serializable{
 
     private static final long serialVersionUID = 3365413090311267088L;
-//    private Map<String,Map<String,String>> fieldMMetaInfo = new HashMap<>();
     private String name;
     private Map<String,String> properties = new HashMap<>();
 
@@ -52,11 +47,6 @@ final class FreezedPropertySource implements PropertySource, Serializable{
         return new FreezedPropertySource(name, propertyProvider);
     }
 
-    @Override
-    public ConfigChangeSet load(){
-        return ConfigChangeSet.emptyChangeSet(this);
-    }
-
     public int size(){
         return properties.size();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertySource.java
index d4c8968..41b730e 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertySource.java
@@ -18,10 +18,6 @@
  */
 package org.apache.tamaya.core.properties;
 
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-
-import java.beans.PropertyChangeEvent;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger;
@@ -76,31 +72,4 @@ class MapBasedPropertySource extends AbstractPropertySource {
         return new HashMap<>(this.entries);
     }
 
-    @Override
-    public ConfigChangeSet load(){
-        // Can not reload...
-        return ConfigChangeSet.emptyChangeSet(this);
-    }
-
-    /**
-     * Apply a config change to this item. Hereby the change must be related to the same
instance.
-     * @param change the config change
-     * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
-     * @throws UnsupportedOperationException when the configuration is not writable.
-     */
-    @Override
-    public void applyChanges(ConfigChangeSet change){
-        change.getEvents().forEach(this::applyChange);
-    }
-
-    private void applyChange(PropertyChangeEvent propertyChangeEvent) {
-        LOG.finest(() -> "Applying change to map provider: " + propertyChangeEvent);
-        if(propertyChangeEvent.getNewValue()==null){
-            this.entries.remove(propertyChangeEvent.getPropertyName());
-        }
-        else{
-            this.entries.put(propertyChangeEvent.getPropertyName(), propertyChangeEvent.getNewValue().toString());
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceBuilder.java
b/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceBuilder.java
index 5cc93ad..b099230 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceBuilder.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceBuilder.java
@@ -24,13 +24,10 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.function.BiFunction;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
 
-import com.oracle.webservices.internal.api.message.PropertySet;
-import org.apache.tamaya.AggregationPolicy;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
 import org.apache.tamaya.PropertySource;
 
 /**
@@ -129,8 +126,8 @@ public final class PropertySourceBuilder {
     }
 
     /**
-     * Adds the given providers with the current active {@link org.apache.tamaya.AggregationPolicy}.
By
-     * default {@link org.apache.tamaya.AggregationPolicy#OVERRIDE} is used.
+     * Adds the given providers with the current active {@link AggregationPolicy}. By
+     * default {@link AggregationPolicy#OVERRIDE} is used.
      * @see #withAggregationPolicy(AggregationPolicy)
      * @param providers providers to be added, not null.
      * @return the builder for chaining.
@@ -143,8 +140,8 @@ public final class PropertySourceBuilder {
     }
 
     /**
-     * Adds the given providers with the current active {@link org.apache.tamaya.AggregationPolicy}.
By
-     * default {@link org.apache.tamaya.AggregationPolicy#OVERRIDE} is used.
+     * Adds the given providers with the current active {@link AggregationPolicy}. By
+     * default {@link AggregationPolicy#OVERRIDE} is used.
      * @see #withAggregationPolicy(AggregationPolicy)
      * @param providers providers to be added, not null.
      * @return the builder for chaining.
@@ -277,7 +274,7 @@ public final class PropertySourceBuilder {
 
 
     /**
-     * Add the current environment properties. Aggregation is based on the current {@link
org.apache.tamaya.AggregationPolicy} acvtive.
+     * Add the current environment properties. Aggregation is based on the current {@link
AggregationPolicy} acvtive.
      *
      * @return the builder for chaining.
      */
@@ -290,7 +287,7 @@ public final class PropertySourceBuilder {
     }
 
     /**
-     * Add the current system properties. Aggregation is based on the current {@link org.apache.tamaya.AggregationPolicy}
acvtive.
+     * Add the current system properties. Aggregation is based on the current {@link AggregationPolicy}
acvtive.
      *
      * @return the builder for chaining.
      */
@@ -313,7 +310,7 @@ public final class PropertySourceBuilder {
     }
 
     /**
-     * Adds the given {@link org.apache.tamaya.PropertySource} instances using the current
{@link org.apache.tamaya.AggregationPolicy}
+     * Adds the given {@link org.apache.tamaya.PropertySource} instances using the current
{@link AggregationPolicy}
      * active.
      *
      * @param providers the maps to be included, not null.
@@ -332,7 +329,7 @@ public final class PropertySourceBuilder {
 
 
     /**
-     * Adds the given {@link org.apache.tamaya.PropertySource} instances using the current
{@link org.apache.tamaya.AggregationPolicy}
+     * Adds the given {@link org.apache.tamaya.PropertySource} instances using the current
{@link AggregationPolicy}
      * active.
      *
      * @param providers the maps to be included, not null.
@@ -351,14 +348,17 @@ public final class PropertySourceBuilder {
 
 
     /**
-     * Creates a new {@link org.apache.tamaya.PropertySource} that is mutable by adding a
map based instance that overrides
-     * values fromMap the original map.
-     *
-     * @param provider the provider to be made mutable, not null.
-     * @return the mutable instance.
+     * Filters the current {@link org.apache.tamaya.PropertySource} with the given valueFilter.
+     * @param valueFilter the value filter, not null.
+     * @return the (dynamically) filtered source instance, never null.
      */
-    public static PropertySource mutable(PropertySource provider) {
-        return PropertySourceFactory.mutable(null, provider);
+    public PropertySourceBuilder filterValues(BiFunction<String, String, String> valueFilter){
+        String name = this.currentName;
+        if (currentName == null) {
+            name = "<filteredValues> -> " + valueFilter;
+        }
+        this.current = PropertySourceFactory.filterValues(name, valueFilter, this.current);
+        return this;
     }
 
 
@@ -464,7 +464,7 @@ public final class PropertySourceBuilder {
      *
      * @return the freezed instance, never null.
      */
-    public PropertySource buildFreezed() {
+    public PropertySource buildFrozen() {
         String name = this.currentName;
         if (currentName == null) {
             name = "<freezed> -> source="+current.getName();

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFactory.java
b/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFactory.java
index 34b1cd9..3f8a0b1 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFactory.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFactory.java
@@ -21,12 +21,10 @@ package org.apache.tamaya.core.properties;
 import java.net.URL;
 import java.time.Instant;
 import java.util.*;
+import java.util.function.BiFunction;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
 
-import org.apache.tamaya.AggregationPolicy;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
 import org.apache.tamaya.PropertySource;
 
 /**
@@ -216,6 +214,7 @@ public final class PropertySourceFactory {
      * Creates a new contextual {@link org.apache.tamaya.PropertySource}. Contextual maps
delegate to different instances current PropertyMap depending
      * on the keys returned fromMap the isolationP
      *
+     * @param name the base name instance, not null.
      * @param mapSupplier          the supplier creating new provider instances
      * @param isolationKeySupplier the supplier providing contextual keys based on the current
environment.
      */
@@ -232,6 +231,7 @@ public final class PropertySourceFactory {
      * Creates a filtered {@link org.apache.tamaya.PropertySource} (a view) current a given
base {@link }PropertyMap}. The filter hereby is
      * applied dynamically on access, so also runtime changes current the base map are reflected
appropriately.
      *
+     * @param name the base name instance, not null.
      * @param source   the main map instance, not null.
      * @param parentMap the delegated parent map instance, not null.
      * @return the new delegating instance.
@@ -250,7 +250,8 @@ public final class PropertySourceFactory {
      * applied dynamically on access, so also runtime changes current the base map are reflected
appropriately.
      * Keys not existing in the {@code mainMap}, but present in {@code replacementMao} will
be hidden.
      *
-     * @param mainMap        the main map instance, which keys, present in {@code replacementMap}
will be replaced
+     * @param name the base name instance, not null.
+     * @param source the main source instance, which keys, present in {@code replacementMap}
will be replaced
      *                       with the ones
      *                       in {@code replacementMap}, not null.
      * @param replacementMap the map instance, that will replace all corresponding entries
in {@code mainMap}, not null.
@@ -274,4 +275,13 @@ public final class PropertySourceFactory {
         return new BuildablePropertySource(name, baseProvider);
     }
 
+    /**
+     * Creates a new filtered {@link org.apache.tamaya.PropertySource} using the given filter.
+     * @param name the base name instance, not null.
+     * @param valueFilter the value filter function, null result will remove the given entries.
+     * @param current the source to be filtered
+     */
+    public static PropertySource filterValues(String name, BiFunction<String, String,
String> valueFilter, PropertySource current) {
+        return new ValueFilteredPropertySource(name, valueFilter, current);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertySource.java
index a5f49fe..69bbb79 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertySource.java
@@ -18,9 +18,7 @@
  */
 package org.apache.tamaya.core.properties;
 
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
+import org.apache.tamaya.core.config.ConfigChangeSet;
 import org.apache.tamaya.PropertySource;
 
 import java.util.*;
@@ -50,11 +48,6 @@ class ReplacingPropertySource implements PropertySource {
     }
 
     @Override
-    public ConfigChangeSet load(){
-        return mainMap.load();
-    }
-
-    @Override
     public Map<String,String> getProperties(){
         Map<String,String> result = new HashMap<>(replacingMap);
         mainMap.getProperties().entrySet().stream().filter(en -> !replacingMap.containsKey(en.getKey())).forEach(en
->
@@ -76,17 +69,6 @@ class ReplacingPropertySource implements PropertySource {
         return Optional.ofNullable(val);
     }
 
-    /**
-     * Apply a config change to this item. Hereby the change must be related to the same
instance.
-     * @param change the config change
-     * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
-     * @throws UnsupportedOperationException when the configuration is not writable.
-     */
-    @Override
-    public void applyChanges(ConfigChangeSet change){
-        this.mainMap.applyChanges(change);
-    }
-
     @Override
     public String toString(){
         return super.toString() + "(mainMap=" + mainMap + ", replacingMap=" + replacingMap
+ ")";

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertySource.java
index 748c86e..f78ceb9 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertySource.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertySource.java
@@ -18,9 +18,6 @@
  */
 package org.apache.tamaya.core.properties;
 
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
 import org.apache.tamaya.PropertySource;
 
 import java.util.*;
@@ -56,21 +53,4 @@ class SubtractingPropertySource extends AbstractPropertySource {
         ));
     }
 
-    @Override
-    public ConfigChangeSet load(){
-        unit.load();
-        return super.load();
-    }
-
-    /**
-     * Apply a config change to this item. Hereby the change must be related to the same
instance.
-     * @param change the config change
-     * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
-     * @throws UnsupportedOperationException when the configuration is not writable.
-     */
-    @Override
-    public void applyChanges(ConfigChangeSet change){
-        this.unit.applyChanges(change);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/main/java/org/apache/tamaya/core/properties/ValueFilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ValueFilteredPropertySource.java
b/core/src/main/java/org/apache/tamaya/core/properties/ValueFilteredPropertySource.java
new file mode 100644
index 0000000..db17d21
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/properties/ValueFilteredPropertySource.java
@@ -0,0 +1,51 @@
+package org.apache.tamaya.core.properties;
+
+import org.apache.tamaya.PropertySource;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.BiFunction;
+
+/**
+ * Property source which filters any key/values dynamically.
+ */
+class ValueFilteredPropertySource implements PropertySource{
+
+    private String name;
+    private BiFunction<String, String, String> valueFilter;
+    private PropertySource source;
+
+    public ValueFilteredPropertySource(String name, BiFunction<String, String, String>
valueFilter, PropertySource current) {
+        this.name = Optional.ofNullable(name).orElse("<valueFiltered> -> name="+current.getName()+",
valueFilter="+valueFilter.toString());
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Optional<String> get(String key) {
+        String value = this.source.get(key).orElse(null);
+        value = valueFilter.apply(key, value);
+        return Optional.ofNullable(value);
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+        Map<String, String> map = new HashMap<>(source.getProperties());
+        map.replaceAll(valueFilter);
+        return map;
+    }
+
+    @Override
+    public String toString() {
+        return "ValueFilteredPropertySource{" +
+                "source=" + source.getName() +
+                ", name='" + name + '\'' +
+                ", valueFilter=" + valueFilter +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/test/java/org/apache/tamaya/core/config/MutableConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/config/MutableConfigTest.java b/core/src/test/java/org/apache/tamaya/core/config/MutableConfigTest.java
index 215da35..b02a58f 100644
--- a/core/src/test/java/org/apache/tamaya/core/config/MutableConfigTest.java
+++ b/core/src/test/java/org/apache/tamaya/core/config/MutableConfigTest.java
@@ -1,52 +1,50 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.ConfigChangeSetBuilder;
-import org.apache.tamaya.Configuration;
-import org.junit.Test;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-
-/**
- * Simple test for a mutable Configuration instance.
- */
-public class MutableConfigTest {
-
-    @Test
-    public void accessMutableConfig() {
-        Configuration config = Configuration.current("mutableTestConfig");
-        ConfigChangeSet changeSet = ConfigChangeSetBuilder.of(config).put("testCase", "accessMutableConfig")
-                .put("execTime", System.currentTimeMillis()).put("execution", "once").build();
-        List<PropertyChangeEvent> changes = new ArrayList<>();
-        Configuration.addChangeListener(change -> {
-            if (change.getPropertySource() == config) {
-                changes.addAll(change.getEvents());
-            }
-        });
-        config.applyChanges(changeSet);
-        assertFalse(changes.isEmpty());
-        System.out.println(changes);
-    }
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements.  See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership.  The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License.  You may obtain a copy of the License at
+// *
+// *   http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing,
+// * software distributed under the License is distributed on an
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// * KIND, either express or implied.  See the License for the
+// * specific language governing permissions and limitations
+// * under the License.
+// */
+//package org.apache.tamaya.core.config;
+//
+//import org.apache.tamaya.Configuration;
+//import org.junit.Test;
+//
+//import java.beans.PropertyChangeEvent;
+//import java.util.ArrayList;
+//import java.util.List;
+//
+//import static org.junit.Assert.assertFalse;
+//
+///**
+// * Simple test for a mutable Configuration instance.
+// */
+//public class MutableConfigTest {
+//
+//    @Test
+//    public void accessMutableConfig() {
+//        Configuration config = Configuration.current("mutableTestConfig");
+//        ConfigChangeSet changeSet = ConfigChangeSetBuilder.of(config).put("testCase", "accessMutableConfig")
+//                .put("execTime", System.currentTimeMillis()).put("execution", "once").build();
+//        List<PropertyChangeEvent> changes = new ArrayList<>();
+//        Configuration.addChangeListener(change -> {
+//            if (change.getPropertySource() == config) {
+//                changes.addAll(change.getEvents());
+//            }
+//        });
+//        config.applyChanges(changeSet);
+//        assertFalse(changes.isEmpty());
+//        System.out.println(changes);
+//    }
+//}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
index bdda4d1..4a5bfe7 100644
--- a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
+++ b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
@@ -24,9 +24,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.tamaya.ConfigChangeSet;
+import org.apache.tamaya.core.config.ConfigChangeSet;
 import org.apache.tamaya.Configuration;
-import org.apache.tamaya.MetaInfo;
 import org.apache.tamaya.core.config.AbstractConfiguration;
 import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
 
@@ -87,24 +86,6 @@ public class MutableTestConfigProvider implements ConfigurationProviderSpi{
         }
 
         @Override
-        public boolean isMutable() {
-            return true;
-        }
-
-        @Override
-        public void applyChanges(ConfigChangeSet changeSet) {
-            for(PropertyChangeEvent change: changeSet.getEvents()){
-                if(change.getNewValue()==null){
-                    this.data.remove(change.getPropertyName());
-                }
-                else{
-                    this.data.put(change.getPropertyName(), (String) change.getNewValue());
-                }
-            }
-            Configuration.publishChange(changeSet);
-        }
-
-        @Override
         public Configuration toConfiguration(){
             return this;
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/core/src/test/java/org/apache/tamaya/ucs/deltaspike/ConfigFiltering.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/deltaspike/ConfigFiltering.java b/core/src/test/java/org/apache/tamaya/ucs/deltaspike/ConfigFiltering.java
new file mode 100644
index 0000000..910610f
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/ucs/deltaspike/ConfigFiltering.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy current the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.ucs.deltaspike;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.core.config.ConfigFunctions;
+import org.apache.tamaya.core.config.ConfigurationBuilder;
+
+import java.net.URL;
+
+/**
+ * This is one of possible multiple comparisons of Tamaya functionality with Deltapike.
+ * <pre>
+ * A company uses REST endpoints and need to talk to those.
+ * So we need to configure a few things:
+ * 1.) the endpoint URL
+ * 2.) the username which should be used to connect (e.g. over https, BASIC auth, whatever)
+ * 3.) the passphrase which should be used to connect.
+ *
+ * The security credentials (passphrase) should not get stored in plaintext but encrypted
using PKI. It should of course also not get logged out in clear text but shall get masked
if logging out the configured values is enabled.
+ *
+ * In DeltaSpike I'd just register a ConfigFilter to do the password decoding on the fly.
+ * </pre>
+ */
+public class ConfigFiltering {
+
+    public void scenario1UseAdapter(){
+        URL endPoint = Configuration.current().get("endPointURL", URL.class).get();
+        String uid = Configuration.current().get("endPointURL.user").get();
+//        String pwd = Configuration.current().getAdapted("endPointURL.password", v ->
MyPKI.decrypt(v));
+    }
+
+    public void scenario1AddFilterOnSPI(){
+        URL endPoint = Configuration.current().get("endPointURL", URL.class).get();
+        String uid = Configuration.current().get("endPointURL.user").get();
+        String pwd = Configuration.current().get("endPointURL.password").get();
+
+        // In the SPI
+        ConfigurationBuilder.of().addPaths("...").filterValues((k,v) -> k.equals("endPointURL.password")?MyPKI.decrypt(v):v).build();
+    }
+
+    private static class MyPKI{
+        public static String decrypt(String val){return val;};
+    }
+}


Mime
View raw message