TAMAYA-252: Unified PropertyValue builder API.

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

Branch: refs/heads/master
Commit: 01ba7463ea705d9f8725bd594aeac6af648df16c
Parents: 0e16f4e
Author: anatole <anat...@apache.org>
Authored: Mon Mar 6 00:28:58 2017 +0100
Committer: anatole <anat...@apache.org>
Committed: Mon Mar 6 00:28:58 2017 +0100

----------------------------------------------------------------------
 .../tamaya/events/RandomPropertySource.java     |   2 +-
 .../apache/tamaya/events/TestConfigView.java    |   2 +-
 .../filter/internal/DefaultMetadataFilter.java  |   2 +-
 .../tamaya/filter/ConfigurationFilterTest.java  |  10 +-
 .../tamaya/filter/ProgrammableFilterTest.java   |  76 ++++++-----
 .../integration/cdi/EnvironmentsTest.java       |   2 +-
 .../internal/ExpressionResolutionFilter.java    |   4 +-
 .../tamaya/spisupport/DefaultConfiguration.java |   2 +-
 .../spisupport/PropertyFilterManager.java       | 131 -------------------
 .../tamaya/spisupport/PropertyFiltering.java    | 110 ++++++++--------
 .../spisupport/PropertySourceComparator.java    |   4 +-
 .../tamaya/spisupport/RegexPropertyFilter.java  |   4 +-
 .../spisupport/RegexPropertyFilterTest.java     |  30 +++--
 13 files changed, 125 insertions(+), 254 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git 
a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
 
b/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
index 041056b..746c5f3 100644
--- 
a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
+++ 
b/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
@@ -53,7 +53,7 @@ public class RandomPropertySource implements PropertySource{
     @Override
     public Map<String, PropertyValue> getProperties() {
         synchronized(data) {
-            data.put("random.new", new PropertyValueBuilder("random.new", 
String.valueOf(Math.random()), getName())
+            data.put("random.new", PropertyValue.builder("random.new", 
String.valueOf(Math.random()), getName())
             .addMetaEntry("_random.new.timestamp", 
String.valueOf(System.currentTimeMillis())).build());
             return new HashMap<>(data);
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
----------------------------------------------------------------------
diff --git 
a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java 
b/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
index 8e5b397..0713298 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
@@ -60,7 +60,7 @@ public class TestConfigView implements ConfigOperator{
                 }
                 return result;
 //                return config.getProperties().entrySet().stream().filter(e 
-> e.getKey().startsWith("test")).collect(
-//                        Collectors.toMap(en -> en.getKey(), en -> 
en.getValue()));
+//                        Collectors.toMap(en -> en.getKey(), en -> 
en.getProperty()));
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
----------------------------------------------------------------------
diff --git 
a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
 
b/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
index 5694a9d..e9554a2 100644
--- 
a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
+++ 
b/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
@@ -34,7 +34,7 @@ public final class DefaultMetadataFilter implements 
PropertyFilter{
             return valueToBeFiltered;
         }
         if(ConfigurationFilter.isMetadataFiltered()) {
-            if (context.getKey().startsWith("_")) {
+            if (context.getProperty().getKey().startsWith("_")) {
                 // Hide metadata entries.
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
----------------------------------------------------------------------
diff --git 
a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
 
b/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
index 6a9e309..a3a75a3 100644
--- 
a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
+++ 
b/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
@@ -47,7 +47,7 @@ public class ConfigurationFilterTest {
         PropertyFilter testFilter = new PropertyFilter() {
             @Override
             public PropertyValue filterProperty(PropertyValue value, 
FilterContext context) {
-                return PropertyValue.of(context.getKey(), context.getKey() + 
":testGetSingleFilters", "test");
+                return value.toBuilder().setValue(value.getKey() + 
":testGetSingleFilters").build();
             }
         };
         
ConfigurationFilter.getSingleValueFilterContext().addFilter(testFilter);
@@ -63,7 +63,7 @@ public class ConfigurationFilterTest {
         PropertyFilter testFilter = new PropertyFilter() {
             @Override
             public PropertyValue filterProperty(PropertyValue value, 
FilterContext context) {
-                return PropertyValue.of(context.getKey(), context.getKey() + 
":testGetSingleFilters", "test");
+                return value.toBuilder().setValue(value.getKey() + 
":testGetSingleFilters").build();
             }
         };
         
ConfigurationFilter.getSingleValueFilterContext().addFilter(testFilter);
@@ -79,7 +79,7 @@ public class ConfigurationFilterTest {
         PropertyFilter testFilter = new PropertyFilter() {
             @Override
             public PropertyValue filterProperty(PropertyValue value, 
FilterContext context) {
-                return PropertyValue.of(context.getKey(), context.getKey() + 
":testGetMapFilters", "test");
+                return value.toBuilder().setValue(value.getKey() + 
":testGetMapFilters").build();
             }
         };
         ConfigurationFilter.getMapFilterContext().addFilter(testFilter);
@@ -95,7 +95,7 @@ public class ConfigurationFilterTest {
         PropertyFilter testFilter = new PropertyFilter() {
             @Override
             public PropertyValue filterProperty(PropertyValue value, 
FilterContext context) {
-                return PropertyValue.of(context.getKey(), context.getKey() + 
":testGetMapFilters", "test");
+                return value .toBuilder().setValue(value.getKey() + 
":testGetMapFilters").build();
             }
         };
         ConfigurationFilter.getMapFilterContext().addFilter(testFilter);
@@ -111,7 +111,7 @@ public class ConfigurationFilterTest {
         PropertyFilter testFilter = new PropertyFilter() {
             @Override
             public PropertyValue filterProperty(PropertyValue value, 
FilterContext context) {
-                return PropertyValue.of(context.getKey(), context.getKey() + 
":testGetSingleFilters", "test");
+                return value.toBuilder().setValue(value.getKey() + 
":testGetSingleFilters").build();
             }
         };
         
ConfigurationFilter.getSingleValueFilterContext().addFilter(testFilter);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
----------------------------------------------------------------------
diff --git 
a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
 
b/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
index 910e089..f886ba0 100644
--- 
a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
+++ 
b/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
@@ -18,8 +18,11 @@
  */
 package org.apache.tamaya.filter;
 
+import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.PropertyFilter;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.DefaultConfigurationContext;
+import org.apache.tamaya.spisupport.DefaultConfigurationContextBuilder;
 import org.apache.tamaya.spisupport.RegexPropertyFilter;
 import org.junit.Test;
 
@@ -34,31 +37,32 @@ import static org.junit.Assert.*;
  */
 public class ProgrammableFilterTest {
 
-    PropertyValue test1Property = PropertyValue.of("test1","test1","test");
-    PropertyValue test2Property = PropertyValue.of("test2","test2","test");
-    PropertyValue test3Property = 
PropertyValue.of("test.test3","test.test3","test");
+    private static ConfigurationContext context = new 
DefaultConfigurationContextBuilder().build();
+    private static PropertyValue test1Property = 
PropertyValue.of("test1","test1","test");
+    private static PropertyValue test2Property = 
PropertyValue.of("test2","test2","test");
+    private static PropertyValue test3Property = 
PropertyValue.of("test.test3","test.test3","test");
 
     @Test
     public void testAddRemoveFilter() throws Exception {
         FilterContext filter = new FilterContext();
         Map<String,PropertyValue> map = new HashMap<>();
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", map)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", map)), test2Property);
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", map)), test3Property);
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, map, context)), 
test1Property);
+        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, map, context)), 
test2Property);
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, map, context)), 
test3Property);
         RegexPropertyFilter regexFilter = new RegexPropertyFilter();
         regexFilter.setIncludes("test\\..*");
         filter.addFilter(regexFilter);
-        assertNull(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", map)));
-        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", map)));
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", map)), test3Property);
+        assertNull(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, map, context)));
+        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, map, context)));
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, map, context)), 
test3Property);
         filter.removeFilter(0);
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", map)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", map)), test2Property);
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", map)), test3Property);
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, map, context)), 
test1Property);
+        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, map, context)), 
test2Property);
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, map, context)), 
test3Property);
         filter.addFilter(0, regexFilter);
-        assertNull(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", map)));
-        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", map)));
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", map)), test3Property);
+        assertNull(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, map, context)));
+        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, map, context)));
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, map, context)), 
test3Property);
     }
 
     @Test
@@ -70,17 +74,17 @@ public class ProgrammableFilterTest {
         map.put("test1", "test1");
         map.put("test2", "test2");
         map.put("test.test3", "test.test3");
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", test1Property)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test1.", test2Property)), test2Property);
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test1.test3", test3Property)), 
test3Property);
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, context)), test1Property);
+        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, context)), test2Property);
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, context)), test3Property);
         filter.addFilter(regexFilter);
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", test1Property)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test1.", test2Property)), test2Property);
-        assertNull(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", test3Property)));
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, context)), test1Property);
+        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, context)));
+        assertNull(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, context)));
         filter.clearFilters();
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", test1Property)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", test2Property)), test2Property);
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", test3Property)), 
test3Property);
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, context)), test1Property);
+        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, context)), test2Property);
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, context)), test3Property);
     }
 
     @Test
@@ -92,13 +96,13 @@ public class ProgrammableFilterTest {
         map.put("test1", test1Property);
         map.put("test2", test1Property);
         map.put("test.test3", test3Property);
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", test1Property)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", map)), test2Property);
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", map)), test3Property);
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, context)), test1Property);
+        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, map, context)), 
test2Property);
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, map, context)), 
test3Property);
         filter.setFilters(regexFilter);
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test.1", map)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test.2", map)), test2Property);
-        assertNull(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test3.test3", map)));
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, map, context)), 
test3Property);
+        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, map, context)));
+        assertNull(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, map, context)));
     }
 
     @Test
@@ -107,13 +111,13 @@ public class ProgrammableFilterTest {
         RegexPropertyFilter regexFilter = new RegexPropertyFilter();
         regexFilter.setIncludes("test1.*");
         Map<String,String> map = new HashMap<>();
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", test1Property)), test1Property);
-        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", test2Property)), test2Property);
-        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test1.test3", test3Property)), 
test3Property);
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, context)), test1Property);
+        assertEquals(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, context)), test2Property);
+        assertEquals(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, context)), test3Property);
         filter.setFilters(Arrays.asList(new PropertyFilter[]{regexFilter}));
-        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext("test1", test1Property)), test1Property);
-        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext("test2", test2Property)));
-        assertNull(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext("test.test3", test3Property)));
+        assertEquals(filter.filterProperty(test1Property, new 
org.apache.tamaya.spi.FilterContext(test1Property, context)), test1Property);
+        assertNull(filter.filterProperty(test2Property, new 
org.apache.tamaya.spi.FilterContext(test2Property, context)));
+        assertNull(filter.filterProperty(test3Property, new 
org.apache.tamaya.spi.FilterContext(test3Property, context)));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/injection/cdi-ee/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
----------------------------------------------------------------------
diff --git 
a/modules/injection/cdi-ee/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
 
b/modules/injection/cdi-ee/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
index cb60307..6b73294 100644
--- 
a/modules/injection/cdi-ee/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
+++ 
b/modules/injection/cdi-ee/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
@@ -77,7 +77,7 @@ package org.apache.tamaya.integration.cdi;
 //
 //    private static void generateAsserts(Properties test) {
 //        for (Map.Entry<Object, Object> entry : test.entrySet()) {
-//            System.out.printf("assertEquals(\"%s\", 
test.getProperty(\"%s\"));%n", entry.getValue(), entry.getKey());
+//            System.out.printf("assertEquals(\"%s\", 
test.getProperty(\"%s\"));%n", entry.getProperty(), entry.getKey());
 //        }
 //    }
 //}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
----------------------------------------------------------------------
diff --git 
a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
 
b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
index 2f2de62..e7d9ff6 100644
--- 
a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
+++ 
b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
@@ -86,8 +86,8 @@ public class ExpressionResolutionFilter implements 
PropertyFilter {
      */
     @Override
     public PropertyValue filterProperty(PropertyValue valueToBeFiltered, 
FilterContext context){
-        LOG.finest("Resolving " + valueToBeFiltered + "(key=" + 
context.getKey() + ")");
-        String newVal = evaluator().evaluateExpression(context.getKey(), 
valueToBeFiltered.getValue(), true);
+        LOG.finest("Resolving " + valueToBeFiltered);
+        String newVal = 
evaluator().evaluateExpression(valueToBeFiltered.getKey(), 
valueToBeFiltered.getValue(), true);
         if(newVal!=null){
             return valueToBeFiltered.toBuilder().setValue(newVal).build();
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
index a0a621a..55399de 100644
--- 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
+++ 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
@@ -95,7 +95,7 @@ public class DefaultConfiguration implements Configuration {
         if(value==null || value.getValue()==null){
             return null;
         }
-        value = PropertyFilterManager.applyFilter(key, value, 
configurationContext);
+        value = PropertyFiltering.applyFilter(value, configurationContext);
         if(value!=null){
             return value.getValue();
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterManager.java
----------------------------------------------------------------------
diff --git 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterManager.java
 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterManager.java
deleted file mode 100644
index cdef84d..0000000
--- 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterManager.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.spisupport;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of the Configuration API. This class uses the current {@link 
ConfigurationContext} to evaluate the
- * chain of {@link org.apache.tamaya.spi.PropertySource} and {@link 
PropertyFilter}
- * instance to evaluate the current Configuration.
- */
-public final class PropertyFilterManager {
-    /**
-     * The logger.
-     */
-    private static final Logger LOG = 
Logger.getLogger(PropertyFilterManager.class.getName());
-    /**
-     * The maximal number of filter cycles performed before aborting.
-     */
-    private static final int MAX_FILTER_LOOPS = 10;
-
-    /**
-     * Private singleton constructor.
-     */
-    private PropertyFilterManager(){}
-
-    public static PropertyValue applyFilter(String key, PropertyValue 
unfilteredValue, ConfigurationContext configurationContext) {
-        // Apply filters to values, prevent values filtered to null!
-        for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
-            boolean changed = false;
-            // Apply filters to values, prevent values filtered to null!
-            for (PropertyFilter filter : 
configurationContext.getPropertyFilters()) {
-                PropertyValue newValue = 
filter.filterProperty(unfilteredValue, new FilterContext(key, unfilteredValue));
-                if (newValue != null && !newValue.equals(unfilteredValue)) {
-                    changed = true;
-                    if (LOG.isLoggable(Level.FINEST)) {
-                        LOG.finest("Filter - " + key + ": " + unfilteredValue 
+ " -> " + newValue + " by " + filter);
-                    }
-                } else if (unfilteredValue != null && 
!unfilteredValue.equals(newValue)) {
-                    changed = true;
-                    if (LOG.isLoggable(Level.FINEST)) {
-                        LOG.finest("Filter - " + key + ": " + unfilteredValue 
+ " -> " + newValue + " by " + filter);
-                    }
-                }
-                unfilteredValue = newValue;
-            }
-            if (!changed) {
-                LOG.finest("Finishing filter loop, no changes detected.");
-                break;
-            } else {
-                if (i == (MAX_FILTER_LOOPS - 1)) {
-                    if (LOG.isLoggable(Level.WARNING)) {
-                        LOG.warning("Maximal filter loop count reached, 
aborting filter evaluation after cycles: " + i);
-                    }
-                } else {
-                    LOG.finest("Repeating filter loop, changes detected.");
-                }
-            }
-        }
-        return unfilteredValue;
-    }
-
-    public static Map<String, PropertyValue> applyFilters(Map<String, 
PropertyValue> inputMap, ConfigurationContext configurationContext) {
-        Map<String, PropertyValue> resultMap = new HashMap<>(inputMap);
-        // Apply filters to values, prevent values filtered to null!
-        for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
-            AtomicInteger changes = new AtomicInteger();
-            for (PropertyFilter filter : 
configurationContext.getPropertyFilters()) {
-                for (Map.Entry<String, PropertyValue> entry : 
inputMap.entrySet()) {
-                    final String k = entry.getKey();
-                    final PropertyValue v = entry.getValue();
-
-                    PropertyValue newValue = filter.filterProperty(v, new 
FilterContext(k, inputMap));
-                    if (newValue != null && !newValue.equals(v)) {
-                        changes.incrementAndGet();
-                        LOG.finest("Filter - " + k + ": " + v + " -> " + 
newValue + " by " + filter);
-                    } else if (v != null && !v.equals(newValue)) {
-                        changes.incrementAndGet();
-                        LOG.finest("Filter - " + k + ": " + v + " -> " + 
newValue + " by " + filter);
-                    }
-                    // Remove null values
-                    if (null != newValue) {
-                        resultMap.put(k, newValue);
-                    }else{
-                        resultMap.remove(k);
-                    }
-                }
-            }
-            if (changes.get() == 0) {
-                LOG.finest("Finishing filter loop, no changes detected.");
-                break;
-            } else {
-                if (i == (MAX_FILTER_LOOPS - 1)) {
-                    if (LOG.isLoggable(Level.WARNING)) {
-                        LOG.warning("Maximal filter loop count reached, 
aborting filter evaluation after cycles: " + i);
-                    }
-                } else {
-                    LOG.finest("Repeating filter loop, changes detected: " + 
changes.get());
-                }
-                changes.set(0);
-            }
-        }
-        return resultMap;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
----------------------------------------------------------------------
diff --git 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
index f614471..ee76623 100644
--- 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
+++ 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
@@ -49,84 +49,76 @@ public final class PropertyFiltering{
      */
     private PropertyFiltering(){}
 
-    public static PropertyValue applyFilter(String key, 
Map<String,PropertyValue> configData, ConfigurationContext 
configurationContext) {
+    /**
+     * Filters a single value.
+     * @param value the raw value, not null.
+     * @param context the context
+     * @return the filtered value, inclusing null.
+     */
+    public static PropertyValue applyFilter(PropertyValue value, 
ConfigurationContext context) {
+        FilterContext filterContext = new FilterContext(value, context);
+        return filterValue(filterContext);
+    }
+
+    /**
+     * Filters all properties.
+     * @param rawProperties the unfiltered properties, not null.
+     * @param context the context
+     * @return the filtered value, inclusing null.
+     */
+    public static Map<String, PropertyValue> applyFilters(Map<String, 
PropertyValue> rawProperties, ConfigurationContext context) {
+        Map<String, PropertyValue> result = new HashMap<>();
         // Apply filters to values, prevent values filtered to null!
-        PropertyValue unfilteredValue = configData.get(key);
-        for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
-            boolean changed = false;
-            // Apply filters to values, prevent values filtered to null!
-            for (PropertyFilter filter : 
configurationContext.getPropertyFilters()) {
-                PropertyValue newValue = 
filter.filterProperty(unfilteredValue, new FilterContext(key, configData));
-                if (newValue != null && !newValue.equals(unfilteredValue)) {
-                    changed = true;
-                    if (LOG.isLoggable(Level.FINEST)) {
-                        LOG.finest("Filter - " + key + ": " + unfilteredValue 
+ " -> " + newValue + " by " + filter);
-                    }
-                } else if (unfilteredValue != null && 
!unfilteredValue.equals(newValue)) {
-                    changed = true;
-                    if (LOG.isLoggable(Level.FINEST)) {
-                        LOG.finest("Filter - " + key + ": " + unfilteredValue 
+ " -> " + newValue + " by " + filter);
-                    }
-                }
-                unfilteredValue = newValue;
-            }
-            if (!changed) {
-                LOG.finest("Finishing filter loop, no changes detected.");
-                break;
-            } else {
-                if (i == (MAX_FILTER_LOOPS - 1)) {
-                    if (LOG.isLoggable(Level.WARNING)) {
-                        LOG.warning("Maximal filter loop count reached, 
aborting filter evaluation after cycles: " + i);
-                    }
-                } else {
-                    LOG.finest("Repeating filter loop, changes detected.");
-                }
+        for (Map.Entry<String, PropertyValue> entry : 
rawProperties.entrySet()) {
+            FilterContext filterContext = new FilterContext(entry.getValue(), 
rawProperties, context);
+            PropertyValue filtered = filterValue(filterContext);
+            if(filtered!=null){
+                result.put(filtered.getKey(), filtered);
             }
         }
-        return unfilteredValue;
+        return result;
     }
 
-    public static Map<String, PropertyValue> applyFilters(Map<String, 
PropertyValue> inputMap, ConfigurationContext configurationContext) {
-        Map<String, PropertyValue> resultMap = new HashMap<>(inputMap);
-        // Apply filters to values, prevent values filtered to null!
-        for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
-            AtomicInteger changes = new AtomicInteger();
-            for (PropertyFilter filter : 
configurationContext.getPropertyFilters()) {
-                for (Map.Entry<String, PropertyValue> entry : 
inputMap.entrySet()) {
-                    final String k = entry.getKey();
-                    final PropertyValue v = entry.getValue();
+    /**
+     * Basic filter logic.
+     * @param context the filter context, not null.
+     * @return the filtered value.
+     */
+    private static PropertyValue filterValue(FilterContext context) {
+        PropertyValue inputValue = context.getProperty();
+        PropertyValue filteredValue = inputValue;
 
-                    PropertyValue newValue = filter.filterProperty(v, new 
FilterContext(k, inputMap));
-                    if (newValue != null && !newValue.equals(v)) {
-                        changes.incrementAndGet();
-                        LOG.finest("Filter - " + k + ": " + v + " -> " + 
newValue + " by " + filter);
-                    } else if (v != null && !v.equals(newValue)) {
-                        changes.incrementAndGet();
-                        LOG.finest("Filter - " + k + ": " + v + " -> " + 
newValue + " by " + filter);
-                    }
-                    // Remove null values
-                    if (null != newValue) {
-                        resultMap.put(k, newValue);
-                    }else{
-                        resultMap.remove(k);
-                    }
+        for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
+            int changes = 0;
+            for (PropertyFilter filter : 
context.getContext().getPropertyFilters()) {
+                filteredValue = filter.filterProperty(inputValue, context);
+                if (filteredValue != null && 
!filteredValue.equals(inputValue)) {
+                    changes++;
+                    LOG.finest("Filter - " + inputValue + " -> " + 
filteredValue + " by " + filter);
+                }
+                if(filteredValue==null){
+                    LOG.finest("Filter removed entry - " + inputValue + ": " + 
filter);
+                    break;
+                }else{
+                    inputValue = filteredValue;
                 }
             }
-            if (changes.get() == 0) {
+            if (changes == 0) {
                 LOG.finest("Finishing filter loop, no changes detected.");
                 break;
+            } else if (filteredValue == null) {
+                break;
             } else {
                 if (i == (MAX_FILTER_LOOPS - 1)) {
                     if (LOG.isLoggable(Level.WARNING)) {
                         LOG.warning("Maximal filter loop count reached, 
aborting filter evaluation after cycles: " + i);
                     }
                 } else {
-                    LOG.finest("Repeating filter loop, changes detected: " + 
changes.get());
+                    LOG.finest("Repeating filter loop, changes detected: " + 
changes);
                 }
-                changes.set(0);
             }
         }
-        return resultMap;
+        return filteredValue;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
----------------------------------------------------------------------
diff --git 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
index 98290b6..f4c37ac 100644
--- 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
+++ 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
@@ -71,10 +71,10 @@ public class PropertySourceComparator implements 
Comparator<PropertySource>, Ser
 //        PropertyValue ordinalValue = 
propertySource.get(PropertySource.TAMAYA_ORDINAL);
 //        if(ordinalValue!=null){
 //            try{
-//                return Integer.parseInt(ordinalValue.getValue().trim());
+//                return Integer.parseInt(ordinalValue.getProperty().trim());
 //            }catch(Exception e){
 //                LOG.finest("Failed to parse ordinal from " + 
PropertySource.TAMAYA_ORDINAL +
-//                        " in " + propertySource.getName()+": 
"+ordinalValue.getValue());
+//                        " in " + propertySource.getName()+": 
"+ordinalValue.getProperty());
 //            }
 //        }
 //        try {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
----------------------------------------------------------------------
diff --git 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
index cb08193..1f8cce9 100644
--- 
a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
+++ 
b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
@@ -57,7 +57,7 @@ public final class RegexPropertyFilter implements 
PropertyFilter{
     public PropertyValue filterProperty(PropertyValue valueToBeFiltered, 
FilterContext context) {
         if(includes!=null){
             for(String expression:includes){
-                if(context.getKey().matches(expression)){
+                if(context.getProperty().getKey().matches(expression)){
                     return valueToBeFiltered;
                 }
             }
@@ -65,7 +65,7 @@ public final class RegexPropertyFilter implements 
PropertyFilter{
         }
         if(excludes!=null){
             for(String expression:excludes){
-                if(context.getKey().matches(expression)){
+                if(context.getProperty().getKey().matches(expression)){
                     return null;
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01ba7463/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
----------------------------------------------------------------------
diff --git 
a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
 
b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
index 44364b8..0b616cd 100644
--- 
a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
+++ 
b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.spisupport;
 
+import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.FilterContext;
 import org.apache.tamaya.spi.PropertyValue;
 
@@ -31,27 +32,32 @@ import static org.junit.Assert.*;
  */
 public class RegexPropertyFilterTest {
 
+    private static PropertyValue prop1 = PropertyValue.of("test1", "test1", 
"test");
+    private static PropertyValue prop2 = PropertyValue.of("test2", "test2", 
"test");
+    private static PropertyValue prop3 = PropertyValue.of("test1.test3", 
"test.test3", "test");
+    private static ConfigurationContext configContext = new 
DefaultConfigurationContext();
+
     @org.junit.Test
     public void testFilterProperty() throws Exception {
         RegexPropertyFilter filter = new RegexPropertyFilter();
         filter.setIncludes("test1.*");
         Map<String,PropertyValue> map = new HashMap<>();
-        map.put("test1", PropertyValue.of("test1", "test1", "test"));
-        map.put("test2", PropertyValue.of("test2", "test2", "test"));
-        map.put("test1.test3", PropertyValue.of("test1.test3", "test.test3", 
"test"));
-        assertEquals(filter.filterProperty(PropertyValue.of("test1.", "test1", 
"test"), new FilterContext("test1.", map)).getValue(), "test1");
-        assertNull(filter.filterProperty(PropertyValue.of("test2", "test2", 
"test"), new FilterContext("test2.", map)));
+        map.put(prop1.getKey(), prop1);
+        map.put(prop2.getKey(), prop2);
+        map.put(prop3.getKey(), prop3);
+        assertEquals(filter.filterProperty(prop1, new FilterContext(prop1, 
configContext)), prop1);
+        assertNull(filter.filterProperty(prop2, new FilterContext(prop2, 
configContext)));
         assertEquals(filter.filterProperty(
-                PropertyValue.of("test1.test3", "testx.test3", "test"),
-                new FilterContext("test1.test3", map)).getValue(), 
"testx.test3");
+                prop3,
+                new FilterContext(prop3, map, configContext)), prop3);
         assertEquals(filter.filterProperty(
-                PropertyValue.of("test1.test3", "testx.test3", "test"),
-                new FilterContext("test1.test3", map)).getValue(), 
"testx.test3");
+                prop3,
+                new FilterContext(prop3, map, configContext)), prop3);
         filter = new RegexPropertyFilter();
         filter.setIncludes("test1.*");
-        assertNotNull(filter.filterProperty(PropertyValue.of("test1", "test1", 
"test"), new FilterContext("test1", map)));
-        assertNull(filter.filterProperty(PropertyValue.of("test2", "test2", 
"test"), new FilterContext("test2", map)));
-        assertNull(filter.filterProperty(PropertyValue.of("test.test3", 
"test1", "test"), new FilterContext("test.test3", map)));
+        assertNotNull(filter.filterProperty(prop1, new FilterContext(prop1, 
map, configContext)));
+        assertNull(filter.filterProperty(prop2, new FilterContext(prop2, map, 
configContext)));
+        assertNotNull(filter.filterProperty(prop3, new FilterContext(prop3, 
map, configContext)));
     }
 
     @org.junit.Test


Reply via email to