You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2017/11/14 09:25:42 UTC

[01/12] incubator-tamaya git commit: TAMAYA-274 Made isScannable a default method, fixed javadocs.

Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 10b960bb7 -> 545e1779b


TAMAYA-274 Made isScannable a default method, fixed javadocs.


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

Branch: refs/heads/master
Commit: 353817c872dc616fc1b6e3466f00476148c1769b
Parents: 10b960b
Author: Anatole Tresch <an...@apache.org>
Authored: Sun Nov 12 21:26:28 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Sun Nov 12 21:26:28 2017 +0100

----------------------------------------------------------------------
 .../api/src/main/java/org/apache/tamaya/TypeLiteral.java | 11 +++++------
 .../main/java/org/apache/tamaya/spi/PropertySource.java  |  4 +++-
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/353817c8/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java b/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java
index 74b6e18..f530a29 100644
--- a/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java
+++ b/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java
@@ -80,7 +80,7 @@ public class TypeLiteral<T> implements Serializable {
      *
      * @param clazz         the class to check, not  {@code null}.
      * @param interfaceType the interface type to be checked, not {@code null}.
-     * @return the generic type parameter, or null, if it cannot be evaluated.
+     * @return the generic type parameters, or an empty array, if it cannot be evaluated.
      */
     public static Type[] getGenericInterfaceTypeParameters(Class<?> clazz, Class<?> interfaceType) {
         Objects.requireNonNull(clazz, "Class parameter must be given.");
@@ -101,7 +101,7 @@ public class TypeLiteral<T> implements Serializable {
      * Method that checks the class's type for a generic interface implementation type.
      *
      * @param type         the type, not {@code null}.
-     * @return the generic type parameter of the given single type generic interfaceType, or null.
+     * @return the generic type parameter of the given single type generic interfaceType, or an empty array.
      */
     public static Type[] getTypeParameters(Type type) {
         Objects.requireNonNull(type, "Type must be given.");
@@ -126,14 +126,13 @@ public class TypeLiteral<T> implements Serializable {
 	public final Class<T> getRawType() {
         Class<T> rawType;
 
-        if (this.definedType instanceof Class) {
-            rawType = (Class<T>) this.definedType;
-        } else if (this.definedType instanceof ParameterizedType) {
+        if (this.definedType instanceof ParameterizedType) {
             ParameterizedType pt = (ParameterizedType) this.definedType;
             rawType = (Class<T>) pt.getRawType();
-
         } else if (this.definedType instanceof GenericArrayType) {
             rawType = (Class<T>) Object[].class;
+        } else if (this.definedType instanceof Class) {
+            rawType = (Class<T>) this.definedType;
         } else {
             throw new RuntimeException("Illegal type for the Type Literal Class");
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/353817c8/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
index 0f3ce45..864cd95 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
@@ -167,6 +167,8 @@ public interface PropertySource {
      * @return {@code true} if this PropertySource can be scanned for its list of properties,
      *         {@code false} if it cannot/should not be scanned.
      */
-    boolean isScannable();
+    default boolean isScannable(){
+        return true;
+    }
 
 }


[02/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/MapPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/MapPropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/MapPropertySourceTest.java
new file mode 100644
index 0000000..5624ed4
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/MapPropertySourceTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spisupport.propertysource.MapPropertySource;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MapPropertySourceTest {
+
+    private Map<String,String> sourceMap;
+    private Properties sourceProperties;
+
+    @Before
+    public void createMapAndProperties() throws Exception {
+        sourceMap = new HashMap<>();
+        sourceMap.put("a", "AAA");
+        sourceMap.put("b", "BBB");
+
+        sourceProperties = new Properties();
+        sourceProperties.setProperty("a", "AAA");
+        sourceProperties.setProperty("b", "BBB");
+    }
+
+    @Test
+    public void sourceWillProperlyInitializedWithMapWithoutPrefix() throws Exception {
+        MapPropertySource propertySource = new MapPropertySource("UT", sourceMap);
+
+        assertThat(propertySource.getProperties()).describedAs("Should contain exactly 2 properties.")
+                                                  .hasSize(2);
+        assertThat(propertySource.get("a")).isNotNull();
+        assertThat(propertySource.get("b")).isNotNull();
+    }
+
+    @Test
+    public void sourceWillProperlyInitializedWithMapWithPrefix() throws Exception {
+        MapPropertySource propertySource = new MapPropertySource("UT", sourceMap, "pre-");
+
+        assertThat(propertySource.getProperties()).describedAs("Should contain exactly 2 properties.")
+                                                  .hasSize(2);
+        assertThat(propertySource.get("pre-a")).isNotNull();
+        assertThat(propertySource.get("pre-b")).isNotNull();
+    }
+
+    @Test
+    public void sourceWillProperlyInitializedWithPropertiesWithPrefix() throws Exception {
+        MapPropertySource propertySource = new MapPropertySource("UT", sourceProperties, "pre-");
+
+        assertThat(propertySource.getProperties()).describedAs("Should contain exactly 2 properties.")
+                                                  .hasSize(2);
+        assertThat(propertySource.get("pre-a")).isNotNull();
+        assertThat(propertySource.get("pre-b")).isNotNull();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/PropertiesFilePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/PropertiesFilePropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/PropertiesFilePropertySourceTest.java
new file mode 100644
index 0000000..da51740
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/PropertiesFilePropertySourceTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spisupport.propertysource.SimplePropertySource;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PropertiesFilePropertySourceTest {
+
+    private final SimplePropertySource testfilePropertySource = new SimplePropertySource(Thread.currentThread()
+            .getContextClassLoader().getResource("testfile.properties"));
+    private final SimplePropertySource overrideOrdinalPropertySource = new SimplePropertySource(
+            Thread.currentThread().getContextClassLoader().getResource("overrideOrdinal.properties"));
+
+
+    @Test
+    public void testGetOrdinal() {
+        Assert.assertEquals(0, testfilePropertySource.getOrdinal());
+        Assert.assertEquals(Integer.parseInt(overrideOrdinalPropertySource.get(PropertySource.TAMAYA_ORDINAL)
+                .getValue()),
+                overrideOrdinalPropertySource.getOrdinal());
+    }
+
+
+    @Test
+    public void testGet() {
+        Assert.assertEquals("val3", testfilePropertySource.get("key3").getValue());
+        Assert.assertEquals("myval5", overrideOrdinalPropertySource.get("mykey5").getValue());
+        Assert.assertNull(testfilePropertySource.get("nonpresentkey"));
+    }
+
+
+    @Test
+    public void testGetProperties() throws Exception {
+        Assert.assertEquals(5, testfilePropertySource.getProperties().size());
+        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key1"));
+        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key2"));
+        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key3"));
+        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key4"));
+        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key5"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
new file mode 100644
index 0000000..288b8cd
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertyValue;
+import org.junit.Test;
+
+import java.net.URL;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.hasEntry;
+
+public class SimplePropertySourceTest {
+    @Test
+    public void successfulCreationWithPropertiesFromXMLPropertiesFile() {
+        URL resource = getClass().getResource("/valid-properties.xml");
+
+        SimplePropertySource source = new SimplePropertySource(resource);
+
+        assertThat(source, notNullValue());
+        assertThat(source.getProperties(), aMapWithSize(2)); // double the size for .source values.
+        assertThat(source.getProperties(), hasEntry("a", PropertyValue.of("a", "b", resource.toString())));
+        assertThat(source.getProperties(), hasEntry("b", PropertyValue.of("b", "1", resource.toString())));
+
+    }
+
+    @Test
+    public void failsToCreateFromNonXMLPropertiesXMLFile() {
+        URL resource = getClass().getResource("/non-xml-properties.xml");
+        ConfigException catchedException = null;
+
+        try {
+            new SimplePropertySource(resource);
+        } catch (ConfigException ce) {
+            catchedException = ce;
+        }
+
+        assertThat(catchedException.getMessage(), allOf(startsWith("Error loading properties from"),
+                                                        endsWith("non-xml-properties.xml")));
+    }
+
+    @Test
+    public void failsToCreateFromInvalidPropertiesXMLFile() {
+        URL resource = getClass().getResource("/invalid-properties.xml");
+        ConfigException catchedException = null;
+
+        try {
+            new SimplePropertySource(resource);
+        } catch (ConfigException ce) {
+            catchedException = ce;
+        }
+
+        assertThat(catchedException.getMessage(), allOf(startsWith("Error loading properties from"),
+                                                        endsWith("invalid-properties.xml")));
+    }
+
+
+    @Test
+    public void successfulCreationWithPropertiesFromSimplePropertiesFile() {
+        URL resource = getClass().getResource("/testfile.properties");
+
+        SimplePropertySource source = new SimplePropertySource(resource);
+
+        assertThat(source, notNullValue());
+        assertThat(source.getProperties(), aMapWithSize(5)); // double the size for .source values.
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySourceTest.java
new file mode 100644
index 0000000..e67630c
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySourceTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.Properties;
+
+public class SystemPropertySourceTest {
+
+    private final SystemPropertySource testPropertySource = new SystemPropertySource();
+
+
+    @Test
+    public void testGetOrdinal() throws Exception {
+
+        // test the default ordinal
+        Assert.assertEquals(SystemPropertySource.DEFAULT_ORDINAL, testPropertySource.getOrdinal());
+
+        // set the ordinal to 1001
+        System.setProperty(PropertySource.TAMAYA_ORDINAL, "1001");
+        Assert.assertEquals(1001, new SystemPropertySource().getOrdinal());
+        // currently its not possible to change ordinal at runtime
+
+        // reset it to not destroy other tests!!
+        System.clearProperty(PropertySource.TAMAYA_ORDINAL);
+    }
+
+    @Test
+    public void testGetName() throws Exception {
+        Assert.assertEquals("system-properties", testPropertySource.getName());
+    }
+
+    @Test
+    public void testGet() throws Exception {
+        String propertyKeyToCheck = System.getProperties().stringPropertyNames().iterator().next();
+
+        PropertyValue property = testPropertySource.get(propertyKeyToCheck);
+        Assert.assertNotNull("Property '" + propertyKeyToCheck + "' is not present in " +
+                SystemPropertySource.class.getSimpleName(), property);
+        Assert.assertEquals(System.getProperty(propertyKeyToCheck), property.getValue());
+    }
+
+    @Test
+    public void testGetProperties() throws Exception {
+        checkWithSystemProperties(testPropertySource.getProperties());
+
+        // modify system properties
+        System.setProperty("test", "myTestVal");
+
+        checkWithSystemProperties(testPropertySource.getProperties());
+
+        // cleanup
+        System.clearProperty("test");
+    }
+
+    private void checkWithSystemProperties(Map<String,PropertyValue> toCheck) {
+        Properties systemEntries = System.getProperties();
+        int num = 0;
+        for (PropertyValue propertySourceEntry : toCheck.values()) {
+            if(propertySourceEntry.getKey().startsWith("_")){
+                continue; // meta entry
+            }
+            num ++;
+            Assert.assertEquals("Entry values for key '" + propertySourceEntry.getKey() + "' do not match",
+                                systemEntries.getProperty(propertySourceEntry.getKey()), propertySourceEntry.getValue());
+        }
+        Assert.assertEquals("size of System.getProperties().entrySet() must be the same as SystemPropertySrouce.getProperties().entrySet()",
+                systemEntries.size(), num);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/TestPropertyDefaultSource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/TestPropertyDefaultSource.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/TestPropertyDefaultSource.java
new file mode 100644
index 0000000..b326abc
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/TestPropertyDefaultSource.java
@@ -0,0 +1,57 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spisupport.propertysource.BasePropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Test provider reading properties from classpath:cfg/defaults/**.properties.
+ */
+public class TestPropertyDefaultSource extends BasePropertySource{
+
+    private Map<String,PropertyValue> properties = new HashMap<>();
+
+    public TestPropertyDefaultSource() {
+        super(100);
+        properties.put("name",PropertyValue.of("name", "Anatole", "Test"));
+        properties.put("name2",PropertyValue.of("name2", "Sabine", "Test"));
+        properties = Collections.unmodifiableMap(properties);
+    }
+
+    @Override
+    public String getName() {
+        return "default-testdata-properties";
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public boolean isScannable() {
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/services/DefaultServiceContext.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/services/DefaultServiceContext.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/services/DefaultServiceContext.java
new file mode 100644
index 0000000..46d69da
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/services/DefaultServiceContext.java
@@ -0,0 +1,205 @@
+/*
+ * 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.services;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.ServiceContext;
+import org.apache.tamaya.spisupport.PriorityServiceComparator;
+
+import javax.annotation.Priority;
+import java.io.IOException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This class implements the (default) {@link ServiceContext} interface and hereby uses the JDK
+ * {@link ServiceLoader} to load the services required.
+ */
+public final class DefaultServiceContext implements ServiceContext {
+    private static final Logger LOG = Logger.getLogger(DefaultServiceContext.class.getName());
+    /**
+     * List current services loaded, per class.
+     */
+    private final ConcurrentHashMap<Class<?>, List<Object>> servicesLoaded = new ConcurrentHashMap<>();
+    /**
+     * Singletons.
+     */
+    private final Map<Class<?>, Object> singletons = new ConcurrentHashMap<>();
+    @SuppressWarnings("rawtypes")
+	private Map<Class, Class> factoryTypes = new ConcurrentHashMap<>();
+
+    @Override
+    public <T> T getService(Class<T> serviceType) {
+        Object cached = singletons.get(serviceType);
+        if (cached == null) {
+            cached = create(serviceType);
+            if(cached!=null) {
+                singletons.put(serviceType, cached);
+            }
+        }
+        return serviceType.cast(cached);
+    }
+
+    @Override
+    public <T> T create(Class<T> serviceType) {
+        @SuppressWarnings("unchecked")
+		Class<? extends T> implType = factoryTypes.get(serviceType);
+        if(implType==null) {
+            Collection<T> services = getServices(serviceType);
+            if (services.isEmpty()) {
+                return null;
+            } else {
+                return getServiceWithHighestPriority(services, serviceType);
+            }
+        }
+        try {
+            return implType.newInstance();
+        } catch (Exception e) {
+            LOG.log(Level.SEVERE, "Failed to create instance of " + implType.getName(), e);
+            return  null;
+        }
+    }
+
+    /**
+     * Loads and registers services.
+     *
+     * @param <T>         the concrete type.
+     * @param serviceType The service type.
+     * @return the items found, never {@code null}.
+     */
+    @Override
+    public <T> List<T> getServices(final Class<T> serviceType) {
+        @SuppressWarnings("unchecked")
+		List<T> found = (List<T>) servicesLoaded.get(serviceType);
+        if (found != null) {
+            return found;
+        }
+        List<T> services = new ArrayList<>();
+        try {
+            for (T t : ServiceLoader.load(serviceType)) {
+                services.add(t);
+            }
+            if(services.isEmpty()) {
+                for (T t : ServiceLoader.load(serviceType, serviceType.getClassLoader())) {
+                    services.add(t);
+                }
+            }
+            Collections.sort(services, PriorityServiceComparator.getInstance());
+            services = Collections.unmodifiableList(services);
+        } catch (ServiceConfigurationError e) {
+            LOG.log(Level.WARNING,
+                    "Error loading services current type " + serviceType, e);
+            if(services==null){
+                services = Collections.emptyList();
+            }
+        }
+        @SuppressWarnings("unchecked")
+		final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>) services));
+        return previousServices != null ? previousServices : services;
+    }
+
+    /**
+     * Checks the given instance for a @Priority annotation. If present the annotation's value is evaluated. If no such
+     * annotation is present, a default priority of {@code 1} is returned.
+     * @param o the instance, not {@code null}.
+     * @return a priority, by default 1.
+     */
+    public static int getPriority(Object o){
+        int prio = 1; //X TODO discuss default priority
+        Priority priority = o.getClass().getAnnotation(Priority.class);
+        if (priority != null) {
+            prio = priority.value();
+        }
+        return prio;
+    }
+
+    /**
+     * @param services to scan
+     * @param <T>      type of the service
+     *
+     * @return the service with the highest {@link Priority#value()}
+     *
+     * @throws ConfigException if there are multiple service implementations with the maximum priority
+     */
+    private <T> T getServiceWithHighestPriority(Collection<T> services, Class<T> serviceType) {
+        T highestService = null;
+        // we do not need the priority stuff if the list contains only one element
+        if (services.size() == 1) {
+            highestService = services.iterator().next();
+            this.factoryTypes.put(serviceType, highestService.getClass());
+            return highestService;
+        }
+
+        Integer highestPriority = null;
+        int highestPriorityServiceCount = 0;
+
+        for (T service : services) {
+            int prio = getPriority(service);
+            if (highestPriority == null || highestPriority < prio) {
+                highestService = service;
+                highestPriorityServiceCount = 1;
+                highestPriority = prio;
+            } else if (highestPriority == prio) {
+                highestPriorityServiceCount++;
+            }
+        }
+
+        if (highestPriorityServiceCount > 1) {
+            throw new ConfigException(MessageFormat.format("Found {0} implementations for Service {1} with Priority {2}: {3}",
+                                                           highestPriorityServiceCount,
+                                                           serviceType.getName(),
+                                                           highestPriority,
+                                                           services));
+        }
+        this.factoryTypes.put(serviceType, highestService.getClass());
+        return highestService;
+    }
+
+    @Override
+    public int ordinal() {
+        return 1;
+    }
+
+    @Override
+    public Enumeration<URL> getResources(String resource, ClassLoader cl) throws IOException {
+        if(cl==null){
+            cl = Thread.currentThread().getContextClassLoader();
+        }
+        if(cl==null){
+            cl = getClass().getClassLoader();
+        }
+        return cl.getResources(resource);
+    }
+
+    @Override
+    public URL getResource(String resource, ClassLoader cl) {
+        if(cl==null){
+            cl = Thread.currentThread().getContextClassLoader();
+        }
+        if(cl==null){
+            cl = getClass().getClassLoader();
+        }
+        return cl.getResource(resource);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
new file mode 100644
index 0000000..7c62bb2
--- /dev/null
+++ b/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+org.apache.tamaya.spisupport.CTestConverter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
new file mode 100644
index 0000000..135caa1
--- /dev/null
+++ b/code/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+org.apache.tamaya.spisupport.DefaultServiceContext

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/invalid-properties.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/invalid-properties.xml b/code/spi-support/src/test/resources/invalid-properties.xml
new file mode 100644
index 0000000..d8b10b7
--- /dev/null
+++ b/code/spi-support/src/test/resources/invalid-properties.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <entry key="a">
+    <entry key="b">1</entry>
+</properties>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/non-xml-properties.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/non-xml-properties.xml b/code/spi-support/src/test/resources/non-xml-properties.xml
new file mode 100644
index 0000000..8de819a
--- /dev/null
+++ b/code/spi-support/src/test/resources/non-xml-properties.xml
@@ -0,0 +1,18 @@
+<!--
+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.
+-->

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/overrideOrdinal.properties
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/overrideOrdinal.properties b/code/spi-support/src/test/resources/overrideOrdinal.properties
new file mode 100644
index 0000000..c68208a
--- /dev/null
+++ b/code/spi-support/src/test/resources/overrideOrdinal.properties
@@ -0,0 +1,25 @@
+# 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.
+
+#overrideValue ordinal
+tamaya.ordinal=16784
+
+mykey1=myval1
+mykey2=myval2
+mykey3=myval3
+mykey4=myval4
+mykey5=myval5
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/testfile.properties
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/testfile.properties b/code/spi-support/src/test/resources/testfile.properties
new file mode 100644
index 0000000..abd7ee8
--- /dev/null
+++ b/code/spi-support/src/test/resources/testfile.properties
@@ -0,0 +1,22 @@
+# 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.
+
+key1=val1
+key2=val2
+key3=val3
+key4=val4
+key5=val5
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/resources/valid-properties.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/valid-properties.xml b/code/spi-support/src/test/resources/valid-properties.xml
new file mode 100644
index 0000000..7eb51d9
--- /dev/null
+++ b/code/spi-support/src/test/resources/valid-properties.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <entry key="a">b</entry>
+    <entry key="b">1</entry>
+</properties>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
----------------------------------------------------------------------
diff --git a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
index b999cb9..aeb44ef 100644
--- a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
+++ b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/Main.java
@@ -40,8 +40,8 @@ import static java.lang.String.format;
  *  or {@code /META-INF/javaconfiguration.xml}.
  * </p>
  *
- * @see org.apache.tamaya.core.propertysource.EnvironmentPropertySource
- * @see org.apache.tamaya.core.propertysource.SystemPropertySource
+ * @see org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource
+ * @see org.apache.tamaya.spisupport.propertysource.SystemPropertySource
  */
 public class Main {
     /*

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
----------------------------------------------------------------------
diff --git a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
index f9fb853..c993eeb 100644
--- a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
+++ b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
@@ -19,7 +19,7 @@
 package org.apache.tamaya.examples.minimal;
 
 import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.internal.DefaultConfigurationProvider;
+import org.apache.tamaya.spisupport.DefaultConfigurationProvider;
 
 /**
  * Configuration provider that allows to set and reset a configuration

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySource.java b/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySource.java
index ebc054d..d21230e 100644
--- a/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySource.java
+++ b/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySource.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.examples.custompropertysource;
 
-import org.apache.tamaya.core.propertysource.BasePropertySource;
+import org.apache.tamaya.spisupport.propertysource.BasePropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 
 import java.io.IOException;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySourceProvider.java b/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySourceProvider.java
index 56fecf5..0573fbd 100644
--- a/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySourceProvider.java
+++ b/examples/02-custom-property-source/src/main/java/org/apache/tamaya/examples/custompropertysource/SimplePropertySourceProvider.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.examples.custompropertysource;
 
-import org.apache.tamaya.core.propertysource.SimplePropertySource;
+import org.apache.tamaya.spisupport.propertysource.SimplePropertySource;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertySourceProvider;
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/Display.java
----------------------------------------------------------------------
diff --git a/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/Display.java b/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/Display.java
index fb95a07..7ba8ad2 100644
--- a/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/Display.java
+++ b/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/Display.java
@@ -36,8 +36,8 @@ import javafx.scene.layout.VBox;
 import javafx.scene.paint.Color;
 import javafx.stage.Stage;
 import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
 import org.apache.tamaya.functions.ConfigurationFunctions;
 import org.apache.tamaya.hazelcast.HazelcastPropertySource;
 import org.apache.tamaya.inject.ConfigurationInjection;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/DisplayManager.java
----------------------------------------------------------------------
diff --git a/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/DisplayManager.java b/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/DisplayManager.java
index efd200b..c178cce 100644
--- a/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/DisplayManager.java
+++ b/examples/11-distributed/src/main/java/org/apache/tamaya/examples/distributed/DisplayManager.java
@@ -37,8 +37,8 @@ import javafx.scene.text.Font;
 import javafx.scene.text.FontWeight;
 import javafx.stage.Stage;
 import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
 import org.apache.tamaya.functions.ConfigurationFunctions;
 import org.apache.tamaya.hazelcast.HazelcastPropertySource;
 import org.apache.tamaya.inject.ConfigurationInjection;



[04/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
new file mode 100644
index 0000000..921cac6
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
@@ -0,0 +1,471 @@
+/*
+ * 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.ConfigException;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Manager that deals with {@link PropertyConverter} instances.
+ * This class is thread-safe.
+ */
+public class PropertyConverterManager {
+    /**
+     * The logger used.
+     */
+    private static final Logger LOG = Logger.getLogger(PropertyConverterManager.class.getName());
+    /**
+     * The registered converters.
+     */
+    private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = new ConcurrentHashMap<>();
+    /**
+     * The transitive converters.
+     */
+    private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> transitiveConverters = new ConcurrentHashMap<>();
+    /**
+     * The lock used.
+     */
+    private final ReadWriteLock lock = new ReentrantReadWriteLock();
+
+    private static final Comparator<Object> PRIORITY_COMPARATOR = new Comparator<Object>() {
+
+        @Override
+        public int compare(Object o1, Object o2) {
+            int prio = PriorityServiceComparator.getPriority(o1) - PriorityServiceComparator.getPriority(o2);
+            if (prio < 0) {
+                return 1;
+            } else if (prio > 0) {
+                return -1;
+            } else {
+                return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
+            }
+        }
+    };
+
+    /**
+     * Constructor.
+     */
+    public PropertyConverterManager() {
+        this(false);
+    }
+
+    public PropertyConverterManager(boolean init) {
+        if (init) {
+            initConverters();
+        }
+    }
+
+    /**
+     * Registers the default converters provided out of the box.
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    protected void initConverters() {
+        for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(PropertyConverter.class)) {
+            Type type = TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(), PropertyConverter.class)[0];
+            register(TypeLiteral.of(type), conv);
+        }
+    }
+
+    /**
+     * Registers a new converters instance.
+     *
+     * @param targetType the target type, not {@code null}.
+     * @param converter  the converters, not {@code null}.
+     * @param <T>        the type.
+     */
+    @SuppressWarnings("unchecked")
+    public <T> void register(TypeLiteral<T> targetType, PropertyConverter<T> converter) {
+        Objects.requireNonNull(converter);
+        Lock writeLock = lock.writeLock();
+        try {
+            writeLock.lock();
+			List<PropertyConverter<?>> converters = List.class.cast(this.converters.get(targetType));
+            if(converters!=null && converters.contains(converter)){
+                return;
+            }
+            List<PropertyConverter<?>> newConverters = new ArrayList<>();
+            if (converters != null) {
+                newConverters.addAll(converters);
+            }
+            if(!newConverters.contains(converter)) {
+                newConverters.add(converter);
+            }
+            Collections.sort(newConverters, PRIORITY_COMPARATOR);
+            this.converters.put(targetType, Collections.unmodifiableList(newConverters));
+            // evaluate transitive closure for all inherited supertypes and implemented interfaces
+            // direct implemented interfaces
+            for (Class<?> ifaceType : targetType.getRawType().getInterfaces()) {
+                converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
+                newConverters = new ArrayList<>();
+                if (converters != null) {
+                    newConverters.addAll(converters);
+                }
+                newConverters.add(converter);
+                Collections.sort(newConverters, PRIORITY_COMPARATOR);
+                this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
+            }
+            Class<?> superClass = targetType.getRawType().getSuperclass();
+            while (superClass != null && !superClass.equals(Object.class)) {
+                converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(superClass)));
+                newConverters = new ArrayList<>();
+                if (converters != null) {
+                    newConverters.addAll(converters);
+                }
+                newConverters.add(converter);
+                Collections.sort(newConverters, PRIORITY_COMPARATOR);
+                this.transitiveConverters.put(TypeLiteral.of(superClass), Collections.unmodifiableList(newConverters));
+                for (Class<?> ifaceType : superClass.getInterfaces()) {
+                    converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
+                    newConverters = new ArrayList<>();
+                    if (converters != null) {
+                        newConverters.addAll(converters);
+                    }
+                    newConverters.add(converter);
+                    Collections.sort(newConverters, PRIORITY_COMPARATOR);
+                    this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
+                }
+                superClass = superClass.getSuperclass();
+            }
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    /**
+     * Allows to evaluate if a given target type is supported.
+     *
+     * @param targetType the target type, not {@code null}.
+     * @return true, if a converters for the given type is registered, or a default one can be created.
+     */
+    public boolean isTargetTypeSupported(TypeLiteral<?> targetType) {
+        return converters.containsKey(targetType) || transitiveConverters.containsKey(targetType) || createDefaultPropertyConverter(targetType) != null;
+    }
+
+    /**
+     * Get a map of all property converters currently registered. This will not contain the converters that
+     * may be created, when an instance is adapted, which provides a String constructor or compatible
+     * factory methods taking a single String instance.
+     *
+     * @return the current map of instantiated and registered converters.
+     * @see #createDefaultPropertyConverter(org.apache.tamaya.TypeLiteral)
+     */
+    public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
+        Lock readLock = lock.readLock();
+        try {
+            readLock.lock();
+            return new HashMap<>(this.converters);
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    /**
+     * Get the list of all current registered converters for the given target type.
+     * If not converters are registered, they component tries to create and register a dynamic
+     * converters based on String constructor or static factory methods available.
+     * The converters provided are of the following type and returned in the following order:
+     * <ul>
+     * <li>Converters mapped explicitly to the required target type are returned first, ordered
+     * by decreasing priority. This means, if explicit converters are registered these are used
+     * primarily for converting a value.</li>
+     * <li>The target type of each explicitly registered converters also can be transitively mapped to
+     * 1) all directly implemented interfaces, 2) all its superclasses (except Object), 3) all the interfaces
+     * implemented by its superclasses. These groups of transitive converters is returned similarly in the
+     * order as mentioned, whereas also here a priority based decreasing ordering is applied.</li>
+     * <li>java.lang wrapper classes and native types are automatically mapped.</li>
+     * <li>If no explicit converters are registered, for Enum types a default implementation is provided that
+     * compares the configuration values with the different enum members defined (cases sensitive mapping).</li>
+     * </ul>
+     * <p>
+     * So given that list above directly registered mappings always are tried first, before any transitive mapping
+     * should be used. Also in all cases @Priority annotations are honored for ordering of the converters in place.
+     * Transitive conversion is supported for all directly implemented interfaces (including inherited ones) and
+     * the inheritance hierarchy (exception Object). Superinterfaces of implemented interfaces are ignored.
+     *
+     * @param targetType the target type, not {@code null}.
+     * @param <T>        the type class
+     * @return the ordered list of converters (may be empty for not convertible types).
+     * @see #createDefaultPropertyConverter(org.apache.tamaya.TypeLiteral)
+     */
+    public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
+        Lock readLock = lock.readLock();
+        List<PropertyConverter<T>> converterList = new ArrayList<>();
+        // direct mapped converters
+        try {
+            readLock.lock();
+            addConvertersToList(List.class.cast(this.converters.get(targetType)), converterList);
+            addConvertersToList(List.class.cast(this.transitiveConverters.get(targetType)), converterList);
+        } finally {
+            readLock.unlock();
+        }
+        // handling of java.lang wrapper classes
+        TypeLiteral<T> boxedType = mapBoxedType(targetType);
+        if (boxedType != null) {
+            try {
+                readLock.lock();
+                addConvertersToList(List.class.cast(this.converters.get(boxedType)), converterList);
+            } finally {
+                readLock.unlock();
+            }
+        }
+        if (converterList.isEmpty() && !TypeLiteral.of(String.class).equals(targetType)) {
+            // adding any converters created on the fly, e.g. for enum types.
+            PropertyConverter<T> defaultConverter = createDefaultPropertyConverter(targetType);
+            if (defaultConverter != null) {
+                register(targetType, defaultConverter);
+                try {
+                    readLock.lock();
+                    addConvertersToList(List.class.cast(this.converters.get(targetType)), converterList);
+                } finally {
+                    readLock.unlock();
+                }
+            }
+        }
+        // check for parametrized types, ignoring param type
+        // direct mapped converters
+        if(targetType.getType()!=null) {
+            try {
+                readLock.lock();
+                addConvertersToList(List.class.cast(this.converters.get(
+                        TypeLiteral.of(targetType.getRawType()))), converterList);
+            } finally {
+                readLock.unlock();
+            }
+        }
+        return converterList;
+    }
+
+    private <T> void addConvertersToList(Collection<PropertyConverter<T>> converters, List<PropertyConverter<T>> converterList) {
+        if (converters != null) {
+            for(PropertyConverter<T> conv:converters) {
+                if(!converterList.contains(conv)) {
+                    converterList.add(conv);
+                }
+            }
+        }
+    }
+
+    /**
+     * Maps native types to the corresponding boxed types.
+     *
+     * @param targetType the native type.
+     * @param <T>        the type
+     * @return the boxed type, or null.
+     */
+    @SuppressWarnings("unchecked")
+	private <T> TypeLiteral<T> mapBoxedType(TypeLiteral<T> targetType) {
+        Type parameterType = targetType.getType();
+        if (parameterType == int.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Integer.class));
+        }
+        if (parameterType == short.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Short.class));
+        }
+        if (parameterType == byte.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Byte.class));
+        }
+        if (parameterType == long.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Long.class));
+        }
+        if (parameterType == boolean.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
+        }
+        if (parameterType == char.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Character.class));
+        }
+        if (parameterType == float.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Float.class));
+        }
+        if (parameterType == double.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Double.class));
+        }
+        if (parameterType == int[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Integer[].class));
+        }
+        if (parameterType == short[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Short[].class));
+        }
+        if (parameterType == byte[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Byte[].class));
+        }
+        if (parameterType == long[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Long[].class));
+        }
+        if (parameterType == boolean.class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
+        }
+        if (parameterType == char[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Character[].class));
+        }
+        if (parameterType == float[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Float[].class));
+        }
+        if (parameterType == double[].class) {
+            return TypeLiteral.class.cast(TypeLiteral.of(Double[].class));
+        }
+        return null;
+    }
+
+    /**
+     * Creates a dynamic PropertyConverter for the given target type.
+     *
+     * @param targetType the target type
+     * @param <T>        the type class
+     * @return a new converters, or null.
+     */
+    protected <T> PropertyConverter<T> createDefaultPropertyConverter(final TypeLiteral<T> targetType) {
+        if (Enum.class.isAssignableFrom(targetType.getRawType())) {
+            return new EnumConverter<>(targetType.getRawType());
+        }
+        PropertyConverter<T> converter = null;
+        final Method factoryMethod = getFactoryMethod(targetType.getRawType(), "of", "valueOf", "instanceOf", "getInstance", "from", "fromString", "parse");
+        if (factoryMethod != null) {
+            converter = new DefaultPropertyConverter<>(factoryMethod, targetType.getRawType());
+        }
+        if (converter == null) {
+            final Constructor<T> constr;
+            try {
+                constr = targetType.getRawType().getDeclaredConstructor(String.class);
+            } catch (NoSuchMethodException e) {
+                LOG.log(Level.FINEST, "No matching constrctor for " + targetType, e);
+                return null;
+            }
+            converter = new PropertyConverter<T>() {
+                    @Override
+                    public T convert(String value, ConversionContext context) {
+                        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                            @Override
+                            public Object run() {
+                                AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                                    @Override
+                                    public Object run() {
+                                        constr.setAccessible(true);
+                                        return null;
+                                    }
+                                });
+                                return null;
+                            }
+                        });
+                        try {
+                            return constr.newInstance(value);
+                        } catch (Exception e) {
+                            LOG.log(Level.SEVERE, "Error creating new PropertyConverter instance " + targetType, e);
+                        }
+                        return null;
+                    }
+                };
+        }
+        return converter;
+    }
+
+    /**
+     * Tries to evaluate a factory method that can be used to create an instance based on a String.
+     *
+     * @param type        the target type
+     * @param methodNames the possible static method names
+     * @return the first method found, or null.
+     */
+    private Method getFactoryMethod(Class<?> type, String... methodNames) {
+        Method m;
+        for (String name : methodNames) {
+            try {
+                m = type.getDeclaredMethod(name, String.class);
+                return m;
+            } catch (NoSuchMethodException | RuntimeException e) {
+                LOG.finest("No such factory method found on type: " + type.getName() + ", methodName: " + name);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof PropertyConverterManager)) {
+            return false;
+        }
+        PropertyConverterManager that = (PropertyConverterManager) o;
+        return converters.equals(that.converters);
+
+    }
+
+    @Override
+    public int hashCode() {
+        return converters.hashCode();
+    }
+
+    /**
+     * Default converters imüöementation perfoming several lookups for String converion
+     * option.
+     * @param <T>
+     */
+    private static class DefaultPropertyConverter<T> implements PropertyConverter<T> {
+
+        private final Method factoryMethod;
+        private final Class<T> targetType;
+
+        DefaultPropertyConverter(Method factoryMethod, Class<T> targetType){
+            this.factoryMethod = Objects.requireNonNull(factoryMethod);
+            this.targetType =  Objects.requireNonNull(targetType);
+        }
+
+        @Override
+        public T convert(String value, ConversionContext context) {
+            context.addSupportedFormats(getClass(), "<String -> "+factoryMethod.toGenericString());
+
+            if (!Modifier.isStatic(factoryMethod.getModifiers())) {
+                throw new ConfigException(factoryMethod.toGenericString() +
+                        " is not a static method. Only static " +
+                        "methods can be used as factory methods.");
+            }
+            try {
+                AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                    @Override
+                    public Object run() {
+                        factoryMethod.setAccessible(true);
+                        return null;
+                    }
+                });
+                Object invoke = factoryMethod.invoke(null, value);
+                return targetType.cast(invoke);
+            } catch (Exception e) {
+                throw new ConfigException("Failed to decode '" + value + "'", e);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterComparator.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterComparator.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterComparator.java
new file mode 100644
index 0000000..20eef63
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFilterComparator.java
@@ -0,0 +1,72 @@
+/*
+ * 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.PropertyFilter;
+
+import javax.annotation.Priority;
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * Comparator for PropertyFilters based on their priority annotations.
+ */
+public final class PropertyFilterComparator implements Comparator<PropertyFilter>, Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final PropertyFilterComparator INSTANCE = new PropertyFilterComparator();
+
+    /**
+     * Get the shared instance of the comparator.
+     * @return the shared instance, never null.
+     */
+    public static PropertyFilterComparator getInstance(){
+        return INSTANCE;
+    }
+
+    private PropertyFilterComparator(){}
+
+    /**
+     * Compare 2 filters for ordering the filter chain.
+     *
+     * @param filter1 the first filter
+     * @param filter2 the second filter
+     * @return the comparison result
+     */
+    private int comparePropertyFilters(PropertyFilter filter1, PropertyFilter filter2) {
+        Priority prio1 = filter1.getClass().getAnnotation(Priority.class);
+        Priority prio2 = filter2.getClass().getAnnotation(Priority.class);
+        int ord1 = prio1 != null ? prio1.value() : 0;
+        int ord2 = prio2 != null ? prio2.value() : 0;
+
+        if (ord1 < ord2) {
+            return -1;
+        } else if (ord1 > ord2) {
+            return 1;
+        } else {
+            return filter1.getClass().getName().compareTo(filter2.getClass().getName());
+        }
+    }
+
+    @Override
+    public int compare(PropertyFilter filter1, PropertyFilter filter2) {
+        return comparePropertyFilters(filter1, filter2);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
new file mode 100644
index 0000000..20f1aaf
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
@@ -0,0 +1,124 @@
+/*
+ * 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 PropertyFiltering{
+    /**
+     * The logger.
+     */
+    private static final Logger LOG = Logger.getLogger(PropertyFiltering.class.getName());
+    /**
+     * The maximal number of filter cycles performed before aborting.
+     */
+    private static final int MAX_FILTER_LOOPS = 10;
+
+    /**
+     * Private singleton constructor.
+     */
+    private PropertyFiltering(){}
+
+    /**
+     * Filters a single value.
+     * @param value the raw value, not {@code null}.
+     * @param context the context
+     * @return the filtered value, including {@code 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 {@code 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!
+        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 result;
+    }
+
+    /**
+     * Basic filter logic.
+     * @param context the filter context, not {@code null}.
+     * @return the filtered value.
+     */
+    private static PropertyValue filterValue(FilterContext context) {
+        PropertyValue inputValue = context.getProperty();
+        PropertyValue filteredValue = inputValue;
+
+        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 == 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);
+                }
+            }
+        }
+        return filteredValue;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
new file mode 100644
index 0000000..d572335
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
@@ -0,0 +1,122 @@
+/*
+ * 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.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import javax.annotation.Priority;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Comparator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Comparator for ordering of PropertySources based on their ordinal method and class name.
+ */
+public class PropertySourceComparator implements Comparator<PropertySource>, Serializable {
+    /** serial version UID. */
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = Logger.getLogger(PropertySourceComparator.class.getName());
+
+    private static final PropertySourceComparator INSTANCE = new PropertySourceComparator();
+
+    private String alternativeOrdinalKey;
+
+    /** Singleton constructor. */
+    private PropertySourceComparator(){}
+
+    /**
+     * Get the shared instance of the comparator.
+     * @return the shared instance, never null.
+     */
+    public static PropertySourceComparator getInstance(){
+        return INSTANCE;
+    }
+
+
+    /**
+     * Order property source reversely, the most important comes first.
+     *
+     * @param source1 the first PropertySource
+     * @param source2 the second PropertySource
+     * @return the comparison result.
+     */
+    private int comparePropertySources(PropertySource source1, PropertySource source2) {
+        if (getOrdinal(source1) < getOrdinal(source2)) {
+            return -1;
+        } else if (getOrdinal(source1) > getOrdinal(source2)) {
+            return 1;
+        } else {
+            return source1.getClass().getName().compareTo(source2.getClass().getName());
+        }
+    }
+
+    /**
+     * Evaluates an ordinal value from a {@link PropertySource}, Hereby the ordinal of type {@code int}
+     * is evaluated as follows:
+     * <ol>
+     *     <li>It evaluates the {@code String} value for {@link PropertySource#TAMAYA_ORDINAL} and tries
+     *     to convert it to an {@code int} value, using {@link Integer#parseInt(String)}.</li>
+     *     <li>It tries to find and evaluate a method {@code int getOrdinal()}.</li>
+     *     <li>It tries to find and evaluate a static field {@code int ORDINAL}.</li>
+     *     <li>It tries to find and evaluate a class level {@link Priority} annotation.</li>
+     *     <li>It uses the default priority ({@code 0}.</li>
+     * </ol>
+     * @param propertySource the property source, not {@code null}.
+     * @return the ordinal value to compare the property source.
+     */
+    public static int getOrdinal(PropertySource propertySource) {
+        return getOrdinal(propertySource, null);
+    }
+
+    public static int getOrdinal(PropertySource propertySource, String alternativeOrdinalKey) {
+        if(alternativeOrdinalKey!=null) {
+            PropertyValue ordinalValue = propertySource.get(alternativeOrdinalKey);
+            if (ordinalValue != null) {
+                try {
+                    return Integer.parseInt(ordinalValue.getValue().trim());
+                } catch (Exception e) {
+                    LOG.finest("Failed to parse ordinal from " + alternativeOrdinalKey +
+                            " in " + propertySource.getName() + ": " + ordinalValue.getValue());
+                }
+            }
+        }
+        return propertySource.getOrdinal();
+    }
+
+    /**
+     * Overrides/adds the key to evaluate/override a property sources ordinal.
+     * @param ordinalKey sets the alternative ordinal key, if null default
+     *                   behaviour will be active.
+     * @return the instance for chaining.
+     */
+    public PropertySourceComparator setOrdinalKey(String ordinalKey) {
+        this.alternativeOrdinalKey = ordinalKey;
+        return this;
+    }
+
+    @Override
+    public int compare(PropertySource source1, PropertySource source2) {
+        return comparePropertySources(source1, source2);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ReflectionUtil.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ReflectionUtil.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ReflectionUtil.java
new file mode 100644
index 0000000..390c8d8
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ReflectionUtil.java
@@ -0,0 +1,42 @@
+/*
+ * 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 java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+
+/**
+ * Small utility class used by other parts.
+ */
+public final class ReflectionUtil {
+
+    private ReflectionUtil(){}
+
+    public static ParameterizedType getParametrizedType(Class<?> clazz) {
+        Type[] genericTypes = clazz.getGenericInterfaces();
+        for (Type type : genericTypes) {
+            if (type instanceof ParameterizedType) {
+                return (ParameterizedType) type;
+            }
+
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
new file mode 100644
index 0000000..1f8cce9
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
@@ -0,0 +1,84 @@
+/*
+ * 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.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Predicate filtering using a regex expression operating on the key. It allows either
+ * to define the target keys to be selected (includes), or to be excluded (excludes).
+ */
+public final class RegexPropertyFilter implements PropertyFilter{
+    /** The expression used to include entries that match. */
+    private List<String> includes;
+    /** The expression used to exclude entries that match. */
+    private List<String> excludes;
+
+    /**
+     * Sets the regex expression to be applied on the key to filter the corresponding entry
+     * if matching.
+     * @param expressions the regular expression for inclusion, not null.
+     */
+    public void setIncludes(String... expressions){
+        this.includes = Arrays.asList(expressions);
+    }
+
+    /**
+     * Sets the regex expression to be applied on the key to remove the corresponding entries
+     * if matching.
+     * @param expressions the regular expressions for exclusion, not null.
+     */
+    public void setExcludes(String... expressions){
+        this.excludes= Arrays.asList(expressions);
+    }
+
+    @Override
+    public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) {
+        if(includes!=null){
+            for(String expression:includes){
+                if(context.getProperty().getKey().matches(expression)){
+                    return valueToBeFiltered;
+                }
+            }
+            return null;
+        }
+        if(excludes!=null){
+            for(String expression:excludes){
+                if(context.getProperty().getKey().matches(expression)){
+                    return null;
+                }
+            }
+        }
+        return valueToBeFiltered;
+    }
+
+    @Override
+    public String toString() {
+        return "RegexPropertyFilter{" +
+                "includes='" + includes + '\'' +
+                "excludes='" + excludes + '\'' +
+                '}';
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java
new file mode 100644
index 0000000..54481ac
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java
@@ -0,0 +1,173 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueBuilder;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Abstract {@link org.apache.tamaya.spi.PropertySource} that allows to set a default ordinal that will be used, if no
+ * ordinal is provided with the config.
+ */
+public abstract class BasePropertySource implements PropertySource{
+    /** default ordinal that will be used, if no ordinal is provided with the config. */
+    private int defaultOrdinal;
+    /** Used if the ordinal has been set explicitly. */
+    private volatile Integer ordinal;
+    /** The name of the property source. */
+    private String name;
+
+    /**
+     * Constructor.
+     * @param name the (unique) property source name, not {@code null}.
+     */
+    protected BasePropertySource(String name){
+        this.name = Objects.requireNonNull(name);
+        this.defaultOrdinal = 0;
+    }
+
+    /**
+     * Constructor.
+     * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config.
+     */
+    protected BasePropertySource(int defaultOrdinal){
+        this.name = getClass().getSimpleName();
+        this.defaultOrdinal = defaultOrdinal;
+    }
+
+    /**
+     * Constructor.
+     * @param name the (unique) property source name, not {@code null}.
+     * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config.
+     */
+    protected BasePropertySource(String name, int defaultOrdinal){
+        this.name = Objects.requireNonNull(name);
+        this.defaultOrdinal = defaultOrdinal;
+    }
+
+
+    /**
+     * Constructor, using a default ordinal of 0.
+     */
+    protected BasePropertySource(){
+        this(0);
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the property source's (unique) name.
+     * @param name the name, not {@code null}.
+     */
+    public void setName(String name){
+        this.name = Objects.requireNonNull(name);
+    }
+
+    /**
+     * Allows to set the ordinal of this property source explcitly. This will override any evaluated
+     * ordinal, or default ordinal. To reset an explcit ordinal call {@code setOrdinal(null);}.
+     * @param ordinal the explicit ordinal, or {@code null}.
+     */
+    public void setOrdinal(Integer ordinal){
+        this.ordinal = ordinal;
+    }
+
+    /**
+     * Allows to set the ordinal of this property source explcitly. This will override any evaluated
+     * ordinal, or default ordinal. To reset an explcit ordinal call {@code setOrdinal(null);}.
+     * @param defaultOrdinal the default ordinal, or {@code null}.
+     */
+    public void setDefaultOrdinal(Integer defaultOrdinal){
+        this.defaultOrdinal = defaultOrdinal;
+    }
+
+    public int getOrdinal() {
+        Integer ordinal = this.ordinal;
+        if(ordinal!=null){
+            Logger.getLogger(getClass().getName()).finest(
+                    "Using explicit ordinal '"+ordinal+"' for property source: " + getName());
+            return ordinal;
+        }
+        PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
+        if(configuredOrdinal!=null){
+            try {
+                return Integer.parseInt(configuredOrdinal.getValue());
+            } catch (Exception e) {
+                Logger.getLogger(getClass().getName()).log(Level.WARNING,
+                        "Configured ordinal is not an int number: " + configuredOrdinal, e);
+            }
+        }
+        return getDefaultOrdinal();
+    }
+
+    /**
+     * Returns the  default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
+     * @return the  default ordinal used, by default 0.
+     */
+    public int getDefaultOrdinal(){
+        return defaultOrdinal;
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        Map<String,PropertyValue> properties = getProperties();
+        PropertyValue val = properties.get(key);
+        if(val==null){
+            return null;
+        }
+        return val;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        BasePropertySource that = (BasePropertySource) o;
+
+        return name.equals(that.name);
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + "{" +
+                toStringValues() +
+                '}';
+    }
+
+    protected String toStringValues() {
+        return  "  defaultOrdinal=" + defaultOrdinal + '\n' +
+                "  ordinal=" + ordinal  + '\n' +
+                "  name='" + name + '\''  + '\n';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySource.java
new file mode 100644
index 0000000..fbea188
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySource.java
@@ -0,0 +1,231 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.*;
+
+/**
+ * A Buildable property source.
+ */
+public class BuildablePropertySource implements PropertySource{
+
+    private int ordinal;
+    private String name = "PropertySource-"+UUID.randomUUID().toString();
+    private Map<String,PropertyValue> properties = new HashMap<>();
+
+    @Override
+    public int getOrdinal() {
+        return ordinal;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        return properties.get(key);
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        return Collections.unmodifiableMap(properties);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        BuildablePropertySource that = (BuildablePropertySource) o;
+
+        return name.equals(that.name);
+    }
+
+    @Override
+    public boolean isScannable() {
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return "BuildablePropertySource{" +
+                "ordinal=" + ordinal +
+                ", name='" + name + '\'' +
+                ", properties=" + properties +
+                '}';
+    }
+
+    /**
+     * Builder builder.
+     *
+     * @return the builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+
+    /**
+     * The type Builder.
+     */
+    public static final class Builder {
+        private int ordinal;
+        private String source = "<on-the-fly-build>";
+        private String name = "PropertySource-"+ UUID.randomUUID().toString();
+        private Map<String,PropertyValue> properties = new HashMap<>();
+
+        private Builder() {
+        }
+
+        /**
+         * With ordinal builder.
+         *
+         * @param ordinal the ordinal
+         * @return the builder
+         */
+        public Builder withOrdinal(int ordinal) {
+            this.ordinal = ordinal;
+            return this;
+        }
+
+        /**
+         * With source builder.
+         *
+         * @param source the source
+         * @return the builder
+         */
+        public Builder withSource(String source) {
+            this.source = Objects.requireNonNull(source);
+            return this;
+        }
+
+        /**
+         * With name builder.
+         *
+         * @param name the name
+         * @return the builder
+         */
+        public Builder withName(String name) {
+            this.name = Objects.requireNonNull(name);
+            return this;
+        }
+
+        /**
+         * With simple property builder.
+         *
+         * @param key   the key
+         * @param value the value
+         * @return the builder
+         */
+        public Builder withSimpleProperty(String key, String value) {
+            return withProperties(PropertyValue.of(key, value, this.source));
+        }
+
+        /**
+         * With simple property builder.
+         *
+         * @param key    the key
+         * @param value  the value
+         * @param source the source
+         * @return the builder
+         */
+        public Builder withSimpleProperty(String key, String value, String source) {
+            return withProperties(PropertyValue.of(key, value, source));
+        }
+
+        /**
+         * With properties builder.
+         *
+         * @param values the values
+         * @return the builder
+         */
+        public Builder withProperties(PropertyValue... values) {
+            for(PropertyValue val:values){
+                this.properties.put(val.getKey(), val);
+            }
+            return this;
+        }
+
+        /**
+         * With properties builder.
+         *
+         * @param properties the properties
+         * @return the builder
+         */
+        public Builder withProperties(Map<String, PropertyValue> properties) {
+            this.properties =  Objects.requireNonNull(properties);
+            return this;
+        }
+
+        /**
+         * With properties builder.
+         *
+         * @param properties the properties
+         * @param source     the source
+         * @return the builder
+         */
+        public Builder withProperties(Map<String, String> properties, String source) {
+            this.properties.putAll(PropertyValue.map(properties, source));
+            return this;
+        }
+
+        /**
+         * With simple properties builder.
+         *
+         * @param properties the properties
+         * @return the builder
+         */
+        public Builder withSimpleProperties(Map<String, String> properties) {
+            this.properties.putAll(PropertyValue.map(properties, this.source));
+            return this;
+        }
+
+        /**
+         * But builder.
+         *
+         * @return the builder
+         */
+        public Builder but() {
+            return builder().withOrdinal(ordinal).withName(name).withProperties(properties);
+        }
+
+        /**
+         * Build buildable property source.
+         *
+         * @return the buildable property source
+         */
+        public BuildablePropertySource build() {
+            BuildablePropertySource buildablePropertySource = new BuildablePropertySource();
+            buildablePropertySource.name = this.name;
+            buildablePropertySource.properties = this.properties;
+            buildablePropertySource.ordinal = this.ordinal;
+            return buildablePropertySource;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySourceProvider.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySourceProvider.java
new file mode 100644
index 0000000..1becb50
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BuildablePropertySourceProvider.java
@@ -0,0 +1,114 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+
+import java.util.*;
+
+/**
+ * A Buildable property source.
+ */
+public class BuildablePropertySourceProvider implements PropertySourceProvider{
+
+    private List<PropertySource> sources = new ArrayList<>();
+
+    @Override
+    public Collection<PropertySource> getPropertySources() {
+        return Collections.unmodifiableCollection(sources);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        BuildablePropertySourceProvider that = (BuildablePropertySourceProvider) o;
+
+        return sources.equals(that.sources);
+    }
+
+    @Override
+    public int hashCode() {
+        return sources.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return "BuildablePropertySourceProvider{" +
+                "sources=" + sources +
+                '}';
+    }
+
+    /**
+     * Builder builder.
+     *
+     * @return the builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+
+
+
+    /**
+     * The type Builder.
+     */
+    public static final class Builder {
+        private List<PropertySource> sources = new ArrayList<>();
+
+        private Builder() {
+        }
+
+        /**
+         * With propertySources.
+         *
+         * @param propertySources the propertySources
+         * @return the builder
+         */
+        public Builder withPropertySourcs(PropertySource... propertySources) {
+            this.sources.addAll(Arrays.asList(propertySources));
+            return this;
+        }
+
+        /**
+         * With property sources builder.
+         *
+         * @param sources the property sources
+         * @return the builder
+         */
+        public Builder withPropertySourcs(Collection<PropertySource> sources) {
+            this.sources.addAll(sources);
+            return this;
+        }
+
+        /**
+         * Build buildable property source.
+         *
+         * @return the buildable property source
+         */
+        public BuildablePropertySourceProvider build() {
+            BuildablePropertySourceProvider buildablePropertySource = new BuildablePropertySourceProvider();
+            buildablePropertySource.sources.addAll(this.sources);
+            return buildablePropertySource;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySource.java
new file mode 100644
index 0000000..a83722f
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySource.java
@@ -0,0 +1,137 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.*;
+
+/**
+ * PropertySource that allows to add the programs main arguments as configuration entries. Unix syntax using '--' and
+ * '-' params is supported.
+ */
+public class CLIPropertySource extends BasePropertySource {
+
+    /** The original main arguments. */
+    private static String[] args = new String[0];
+
+    /** The map of parsed main arguments. */
+    private static Map<String,PropertyValue> mainArgs;
+
+    /** Initializes the initial state. */
+    static{
+        initMainArgs(args);
+    }
+
+    /**
+     * Creates a new instance.
+     */
+    public CLIPropertySource(){
+        this((String[])null);
+    }
+
+    /**
+     * Creates a new instance, allows optionally to pass the main arguments.
+     * @param args the args, or null.
+     */
+    public CLIPropertySource(String... args){
+        super("CLI");
+        if(args!=null){
+            initMainArgs(args);
+        }
+    }
+
+    /**
+     * Creates a new instance, allows optionally to pass the main arguments.
+     * @param args the args, or null.
+     * @param ordinal the ordinal to be applied.
+     */
+    public CLIPropertySource(int ordinal, String... args){
+        if(args!=null){
+            initMainArgs(args);
+        }
+        setOrdinal(ordinal);
+    }
+
+
+
+    /**
+     * Configure the main arguments, hereby parsing and mapping the main arguments into
+     * configuration propertiesi as key-value pairs.
+     * @param args the main arguments, not null.
+     */
+    public static void initMainArgs(String... args){
+        CLIPropertySource.args = Objects.requireNonNull(args);
+        // TODO is there a way to figure out the args?
+        String argsProp = System.getProperty("main.args");
+        if(argsProp!=null){
+            CLIPropertySource.args = argsProp.split("\\s");
+        }
+        Map<String,String> result = null;
+        if(CLIPropertySource.args==null){
+            result = Collections.emptyMap();
+        }else{
+            result = new HashMap<>();
+            String prefix = System.getProperty("main.args.prefix");
+            if(prefix==null){
+                prefix="";
+            }
+            String key = null;
+            for(String arg:CLIPropertySource.args){
+                if(arg.startsWith("--")){
+                    arg = arg.substring(2);
+                    int index = arg.indexOf("=");
+                    if(index>0){
+                        key = arg.substring(0,index).trim();
+                        result.put(prefix+key, arg.substring(index+1).trim());
+                        key = null;
+                    }else{
+                        result.put(prefix+arg, arg);
+                    }
+                }else if(arg.startsWith("-")){
+                    key = arg.substring(1);
+                }else{
+                    if(key!=null){
+                        result.put(prefix+key, arg);
+                        key = null;
+                    }else{
+                        result.put(prefix+arg, arg);
+                    }
+                }
+            }
+        }
+        Map<String,PropertyValue> finalProps = new HashMap<>();
+        for(Map.Entry<String,String> en:result.entrySet()) {
+            finalProps.put(en.getKey(),
+                    PropertyValue.of(en.getKey(), en.getValue(), "main-args"));
+        }
+        CLIPropertySource.mainArgs = Collections.unmodifiableMap(finalProps);
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        return Collections.unmodifiableMap(mainArgs);
+    }
+
+    @Override
+    protected String toStringValues() {
+        return  super.toStringValues() +
+                "  args=" + Arrays.toString(args) + '\n';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySource.java
new file mode 100644
index 0000000..bb9f6b8
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySource.java
@@ -0,0 +1,287 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * <p>{@link PropertySource} to access environment variables via Tamaya
+ * which are set via {@code export VARIABLE=value} on UNIX systems or
+ * {@code set VARIABLE=value} on Windows systems.</p>
+ *
+ * <p>Using the {@linkplain EnvironmentPropertySource} without any
+ * additional configuration gives access to all existing environment
+ * variables available to the Java process Tamaya is running in.</p>
+ *
+ * <h1>Simple usage example</h1>
+ *
+ * <pre>
+ * $ export OPS_MODE=production
+ * $ export COLOR=false
+ * $ java -jar application.jar
+ * </pre>
+ *
+ * <p>To access {@code OPS_MODE} and {@code COLOR} with the following code
+ * fragment could be used:</p>
+ *
+ * <pre>
+ * PropertySource ps = new EnvironmentPropertySource();
+ * PropertyValue opsMode = ps.get("OPS_MODE");
+ * PropertyValue color = ps.get("COLOR");
+ * </pre>
+ *
+ * <h1>Application specific environmet variables with prefix</h1>
+ *
+ * <p>Given the case where to instances of the same application are running on
+ * a single machine but need different values for the environment variable
+ * {@code CUSTOMER}. The {@linkplain EnvironmentPropertySource} allows you
+ * to prefix the environment variable with an application specific prefix
+ * and to access it by the non-prefixed variable name.</p>
+ *
+ * <pre>
+ * $ export CUSTOMER=none
+ * $ export a81.CUSTOMER=moon
+ * $ export b78.CUSTOMER=luna
+ * </pre>
+ *
+ * <p>Given an environment with these tree variables the application running
+ * for the customer called Moon could be started with the following command:</p>
+ *
+ * <pre>
+ * $ java -Dtamaya.envprops.prefix=a81 -jar application.jar
+ * </pre>
+ *
+ * <p>The application specific value can now be accessed from the code of the
+ * application like this:</p>
+ *
+ * <pre>
+ * PropertySource ps = new EnvironmentPropertySource();
+ * PropertyValue pv = ps.get("CUSTOMER");
+ * System.out.println(pv.getValue());
+ * </pre>
+ *
+ * <p>The output of application would be {@code moon}.</p>
+ *
+ * <h1>Disabling the access to environment variables</h1>
+ *
+ * <p>The access to environment variables could be simply
+ * disabled by the setting the systemproperty {@code tamaya.envprops.disable}
+ * or {@code tamaya.defaults.disable} to {@code true}.</p>
+ */
+public class EnvironmentPropertySource extends BasePropertySource {
+    private static final String TAMAYA_ENVPROPS_PREFIX = "tamaya.envprops.prefix";
+    private static final String TAMAYA_ENVPROPS_DISABLE = "tamaya.envprops.disable";
+    private static final String TAMAYA_DEFAULT_DISABLE = "tamaya.defaults.disable";
+
+    /**
+     * Default ordinal for {@link org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource}
+     */
+    public static final int DEFAULT_ORDINAL = 300;
+
+    /**
+     * Prefix that allows environment properties to virtually be mapped on specified sub section.
+     */
+    private String prefix;
+
+    /**
+     * If true, this property source does not return any properties. This is useful since this
+     * property source is applied by default, but can be switched off by setting the
+     * {@code tamaya.envprops.disable} system/environment property to {@code true}.
+     */
+    private boolean disabled = false;
+
+    private SystemPropertiesProvider propertiesProvider = new SystemPropertiesProvider();
+
+    /**
+     * Creates a new instance. Also initializes the {@code prefix} and {@code disabled} properties
+     * from the system-/ environment properties:
+     * <pre>
+     *     tamaya.envprops.prefix
+     *     tamaya.envprops.disable
+     * </pre>
+     */
+    public EnvironmentPropertySource(){
+        initFromSystemProperties();
+    }
+
+    /**
+     * Initializes the {@code prefix} and {@code disabled} properties from the system-/
+     * environment properties:
+     * <pre>
+     *     tamaya.envprops.prefix
+     *     tamaya.envprops.disable
+     * </pre>
+     */
+    private void initFromSystemProperties() {
+        String value = System.getProperty("tamaya.envprops.prefix");
+        if(value==null){
+            prefix = System.getenv("tamaya.envprops.prefix");
+        }
+        value = System.getProperty("tamaya.envprops.disable");
+        if(value==null){
+            value = System.getenv("tamaya.envprops.disable");
+        }
+        if(value==null){
+            value = System.getProperty("tamaya.defaults.disable");
+        }
+        if(value==null){
+            value = System.getenv("tamaya.defaults.disable");
+        }
+        if(value!=null && !value.isEmpty()) {
+            this.disabled = Boolean.parseBoolean(value);
+        }
+    }
+
+    /**
+     * Creates a new instance using a fixed ordinal value.
+     * @param ordinal the ordinal number.
+     */
+    public EnvironmentPropertySource(int ordinal){
+        this(null, ordinal);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the prefix to be used, or null.
+     * @param ordinal the ordinal to be used.
+     */
+    public EnvironmentPropertySource(String prefix, int ordinal){
+        super("environment-properties");
+        this.prefix = prefix;
+        setOrdinal(ordinal);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the prefix to be used, or null.
+     */
+    public EnvironmentPropertySource(String prefix){
+        this.prefix = prefix;
+    }
+
+    @Override
+    public int getDefaultOrdinal() {
+        return DEFAULT_ORDINAL;
+    }
+
+    @Override
+    public String getName() {
+        if (isDisabled()) {
+            return "environment-properties(disabled)";
+        }
+        return "environment-properties";
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        if (isDisabled()) {
+            return null;
+        }
+
+        String effectiveKey = hasPrefix() ? getPrefix() + "." + key
+                                          : key;
+
+        String value = getPropertiesProvider().getenv(effectiveKey);
+
+        return PropertyValue.of(key, value, getName());
+    }
+
+    private boolean hasPrefix() {
+        return null != prefix;
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        if(disabled){
+            return Collections.emptyMap();
+        }
+        String prefix = this.prefix;
+        if(prefix==null) {
+            Map<String, PropertyValue> entries = new HashMap<>(System.getenv().size());
+            for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
+                entries.put(entry.getKey(), PropertyValue.of(entry.getKey(), entry.getValue(), getName()));
+            }
+            return entries;
+        }else{
+            Map<String, PropertyValue> entries = new HashMap<>(System.getenv().size());
+            for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
+                entries.put(prefix + entry.getKey(), PropertyValue.of(prefix + entry.getKey(), entry.getValue(), getName()));
+            }
+            return entries;
+        }
+    }
+
+
+    @Override
+    protected String toStringValues() {
+        return  super.toStringValues() +
+                "  prefix=" + prefix + '\n' +
+                "  disabled=" + disabled + '\n';
+    }
+
+    void setPropertiesProvider(SystemPropertiesProvider spp) {
+        propertiesProvider = spp;
+        initFromSystemProperties();
+    }
+
+    SystemPropertiesProvider getPropertiesProvider() {
+        return propertiesProvider;
+    }
+
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public boolean isDisabled() {
+        return disabled;
+    }
+
+    /**
+     * <p>Provides access to the system properties used to configure
+     * {@linkplain EnvironmentPropertySource}.</p>
+     *
+     * <p>This implementation delegates all property lookups
+     * to {@linkplain System#getProperty(String)}.</p>
+     */
+    static class SystemPropertiesProvider {
+        String getEnvPropsPrefix() {
+            return System.getenv(TAMAYA_ENVPROPS_PREFIX);
+        }
+
+        String getEnvPropsDisable() {
+            return System.getenv(TAMAYA_ENVPROPS_DISABLE);
+        }
+
+        String getDefaultsDisable() {
+            return System.getenv(TAMAYA_DEFAULT_DISABLE);
+        }
+
+        String getenv(String name) {
+            return System.getenv(name);
+        }
+
+        Map<String, String> getenv() {
+            return System.getenv();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationPropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationPropertySource.java
new file mode 100644
index 0000000..92f520e
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationPropertySource.java
@@ -0,0 +1,134 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+
+import static java.lang.String.format;
+import static java.lang.Thread.currentThread;
+
+/**
+ * Provider which reads all {@value DEFAULT_SIMPLE_PROPERTIES_FILE_NAME} and
+ * {@value DEFAULT_XML_PROPERTIES_FILE_NAME} files found in the
+ * classpath. By setting
+ * {@code tamaya.defaultprops.disable} or {@code tamaya.defaults.disable}
+ * as system or environment property this feature can be disabled.
+ */
+public class JavaConfigurationPropertySource extends BasePropertySource {
+    /**
+     * Default location in the classpath, where Tamaya looks for simple line based configuration by default.
+     */
+    public static final String DEFAULT_SIMPLE_PROPERTIES_FILE_NAME="META-INF/javaconfiguration.properties";
+
+    /**
+     * Default location in the classpath, where Tamaya looks for XML based configuration by default.
+     */
+    public static final String DEFAULT_XML_PROPERTIES_FILE_NAME = "META-INF/javaconfiguration.xml";
+
+    private static final int DEFAULT_ORDINAL = 900;
+
+    private boolean enabled = evaluateEnabled();
+
+    public JavaConfigurationPropertySource(){
+        super("resource:META-INF/javaconfiguration.*", DEFAULT_ORDINAL);
+    }
+
+    private boolean evaluateEnabled() {
+        String value = System.getProperty("tamaya.defaultprops.disable");
+        if(value==null){
+            value = System.getenv("tamaya.defaultprops.disable");
+        }
+        if(value==null){
+            value = System.getProperty("tamaya.defaults.disable");
+        }
+        if(value==null){
+            value = System.getenv("tamaya.defaults.disable");
+        }
+        if(value==null){
+            return true;
+        }
+        return value.isEmpty() || !Boolean.parseBoolean(value);
+    }
+
+    private List<PropertySource> getPropertySources() {
+        List<PropertySource> propertySources = new ArrayList<>();
+        propertySources.addAll(loadPropertySourcesByName(DEFAULT_SIMPLE_PROPERTIES_FILE_NAME));
+        propertySources.addAll(loadPropertySourcesByName(DEFAULT_XML_PROPERTIES_FILE_NAME));
+        Collections.sort(propertySources, PropertySourceComparator.getInstance());
+        return propertySources;
+    }
+
+    private Collection<? extends PropertySource> loadPropertySourcesByName(String filename) {
+        List<PropertySource> propertySources = new ArrayList<>();
+        Enumeration<URL> propertyLocations;
+        try {
+            propertyLocations = ServiceContextManager.getServiceContext()
+                    .getResources(filename, currentThread().getContextClassLoader());
+        } catch (IOException e) {
+            String msg = format("Error while searching for %s", filename);
+
+            throw new ConfigException(msg, e);
+        }
+
+        while (propertyLocations.hasMoreElements()) {
+            URL currentUrl = propertyLocations.nextElement();
+            SimplePropertySource sps = new SimplePropertySource(currentUrl);
+
+            propertySources.add(sps);
+        }
+
+        return propertySources;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean enabled){
+        this.enabled = enabled;
+    }
+
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        if (!isEnabled()) {
+            return Collections.emptyMap();
+        }
+        Map<String,PropertyValue> result = new HashMap<>();
+        for(PropertySource ps:getPropertySources()){
+            result.putAll(ps.getProperties());
+        }
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "JavaConfigurationPropertySource{" +
+                "enabled=" + enabled +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/MapPropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/MapPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/MapPropertySource.java
new file mode 100644
index 0000000..0cabb35
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/MapPropertySource.java
@@ -0,0 +1,102 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Simple PropertySource implementation that just takes a Map and an (optional) priority.
+ * Optionally the entries passed can be mapped to a different rootContext.
+ */
+public class MapPropertySource extends BasePropertySource {
+
+    /**
+     * The current properties.
+     */
+    private final Map<String, PropertyValue> props = new HashMap<>();
+
+    /**
+     * Creates a new instance, hereby using the default mechanism for evaluating the property source's
+     * priority.
+     *
+     * @param name unique name of this source.
+     * @param props the properties
+     */
+    public MapPropertySource(String name, Map<String, String> props) {
+        this(name, props, null);
+    }
+
+    /**
+     * Creates a new instance, hereby using the default mechanism for evaluating the property source's
+     * priority, but applying a custom mapping {@code prefix} to the entries provided.
+     *
+     * @param name        unique name of this source.
+     * @param props       the properties
+     * @param prefix      the prefix context mapping, or null (for no mapping).
+     */
+    public MapPropertySource(String name, Map<String, String> props, String prefix) {
+        super(name);
+        if (prefix == null) {
+            for (Map.Entry<String, String> en : props.entrySet()) {
+                this.props.put(en.getKey(),
+                        PropertyValue.of(en.getKey(), en.getValue(), name));
+            }
+        } else {
+            for (Map.Entry<String, String> en : props.entrySet()) {
+                this.props.put(prefix + en.getKey(),
+                        PropertyValue.of(prefix + en.getKey(), en.getValue(), name));
+            }
+        }
+    }
+
+    /**
+     * Creates a new instance, hereby using the default mechanism for evaluating the property source's
+     * priority, but applying a custom mapping {@code rootContext} to the entries provided.
+     *
+     * @param name unique name of this source.
+     * @param props       the properties
+     * @param prefix      the prefix context mapping, or null (for no mapping).
+     */
+    public MapPropertySource(String name, Properties props, String prefix) {
+        this(name, getMap(props), prefix);
+    }
+
+    /**
+     * Simple method to convert Properties into a Map instance.
+     * @param props the properties, not null.
+     * @return the corresponding Map instance.
+     */
+    public static Map<String, String> getMap(Properties props) {
+        Map<String, String> result = new HashMap<>();
+        for (Map.Entry en : props.entrySet()) {
+            result.put(en.getKey().toString(), en.getValue().toString());
+        }
+        return result;
+    }
+
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        return Collections.unmodifiableMap(this.props);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
new file mode 100644
index 0000000..27b6e4b
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
@@ -0,0 +1,109 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Simple PropertySource, with a fixed ordinal that reads a .properties file from a given URL.
+ */
+public class PropertiesResourcePropertySource extends MapPropertySource {
+    /** The logger used. */
+    private static final Logger LOGGER = Logger.getLogger(PropertiesResourcePropertySource.class.getName());
+
+    /**
+     * Creates a new instance.
+     * @param url the resource URL, not null.
+     */
+    public PropertiesResourcePropertySource(URL url){
+        this(url, null);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the (optional) prefix context for mapping (prefixing) the properties loaded.
+     * @param url the resource URL, not null.
+     */
+    public PropertiesResourcePropertySource(URL url, String prefix){
+        super(url.toExternalForm(), loadProps(url), prefix);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the (optional) prefix context for mapping (prefixing) the properties loaded.
+     * @param path the resource path, not null.
+     */
+    public PropertiesResourcePropertySource(String path, String prefix){
+        super(path, loadProps(path, null), prefix);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the (optional) prefix context for mapping (prefixing) the properties loaded.
+     * @param path the resource path, not null.
+     */
+    public PropertiesResourcePropertySource(String path, String prefix, ClassLoader cl){
+        super(path, loadProps(path, cl), prefix);
+    }
+
+    /**
+     * Loads the properties using the JDK's Property loading mechanism.
+     * @param path the resource classpath, not null.
+     * @return the loaded properties.
+     */
+    private static Map<String, String> loadProps(String path, ClassLoader cl) {
+        if(cl==null){
+            cl = PropertiesResourcePropertySource.class.getClassLoader();
+        }
+        URL url = ServiceContextManager.getServiceContext().getResource(path, cl);
+        return loadProps(url);
+    }
+
+    /**
+     * Loads the properties using the JDK's Property loading mechanism.
+     * @param url the resource URL, not null.
+     * @return the loaded properties.
+     */
+    private static Map<String, String> loadProps(URL url) {
+        Map<String,String> result = new HashMap<>();
+        if(url!=null) {
+            try (InputStream is = url.openStream()) {
+                Properties props = new Properties();
+                props.load(is);
+                for (Map.Entry en : props.entrySet()) {
+                    result.put(en.getKey().toString(), en.getValue().toString());
+                }
+            } catch (Exception e) {
+                LOGGER.log(Level.WARNING, "Failed to read properties from " + url, e);
+            }
+        }else{
+            LOGGER.log(Level.WARNING, "No properties found at " + url);
+        }
+        return result;
+    }
+
+}



[03/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
new file mode 100644
index 0000000..070a564
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
@@ -0,0 +1,284 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.logging.Logger;
+
+/**
+ * Simple implementation of a {@link org.apache.tamaya.spi.PropertySource} for
+ * simple property files and XML property files.
+ */
+public class SimplePropertySource extends BasePropertySource {
+
+    private static final Logger LOG = Logger.getLogger(SimplePropertySource.class.getName());
+
+    /**
+     * The current properties.
+     */
+    private Map<String, PropertyValue> properties = new HashMap<>();
+
+    /**
+     * Creates a new Properties based PropertySource based on the given URL.
+     *
+     * @param propertiesLocation the URL encoded location, not null.
+     */
+    public SimplePropertySource(File propertiesLocation) {
+        super(propertiesLocation.toString(), 0);
+        try {
+            this.properties = load(propertiesLocation.toURI().toURL());
+        } catch (IOException e) {
+            throw new ConfigException("Failed to load properties from " + propertiesLocation, e);
+        }
+    }
+
+    /**
+     * Creates a new Properties based PropertySource based on the given URL.
+     *
+     * @param propertiesLocation the URL encoded location, not null.
+     */
+    public SimplePropertySource(URL propertiesLocation) {
+        super(propertiesLocation.toString(), 0);
+        this.properties = load(Objects.requireNonNull(propertiesLocation));
+    }
+
+    /**
+     * Creates a new Properties based PropertySource.
+     *
+     * @param name the property source name, not null.
+     * @param properties the properties, not null
+     * @param defaultOrdinal the default ordinal
+     */
+    public SimplePropertySource(String name, Map<String, String> properties, int defaultOrdinal){
+        super(name, defaultOrdinal);
+        for(Map.Entry<String,String> en: properties.entrySet()) {
+            this.properties.put(en.getKey(), PropertyValue.of(en.getKey(), en.getValue(), name));
+        }
+    }
+
+    /**
+     * Creates a new Properties based PropertySource based on the given properties map.
+     *
+     * @param name       the name, not null.
+     * @param properties the properties, not null.
+     */
+    public SimplePropertySource(String name, Map<String, String> properties) {
+        this(name, properties, 0);
+    }
+
+    /**
+     * Creates a new Properties based PropertySource based on the given URL.
+     *
+     * @param name               The property source name
+     * @param propertiesLocation the URL encoded location, not null.
+     */
+    public SimplePropertySource(String name, URL propertiesLocation) {
+        super(name, 0);
+        this.properties = load(propertiesLocation);
+    }
+
+    private SimplePropertySource(Builder builder) {
+        properties = builder.properties;
+        if(builder.defaultOrdinal!=null){
+            setDefaultOrdinal(builder.defaultOrdinal);
+        }
+        if(builder.ordinal!=null){
+            setOrdinal(builder.ordinal);
+        }
+        setName(builder.name);
+    }
+
+    public static Builder newBuilder() {
+        return new Builder();
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        return this.properties;
+    }
+
+    /**
+     * loads the Properties from the given URL
+     *
+     * @param propertiesFile {@link URL} to load Properties from
+     * @return loaded {@link Properties}
+     * @throws IllegalStateException in case of an error while reading properties-file
+     */
+    private static Map<String, PropertyValue> load(URL propertiesFile) {
+        boolean isXML = isXMLPropertieFiles(propertiesFile);
+
+        Map<String, PropertyValue> properties = new HashMap<>();
+        try (InputStream stream = propertiesFile.openStream()) {
+            Properties props = new Properties();
+            if (stream != null) {
+                if (isXML) {
+                    props.loadFromXML(stream);
+                } else {
+                    props.load(stream);
+                }
+            }
+            String source = propertiesFile.toString();
+            for (String key : props.stringPropertyNames()) {
+                properties.put(key, PropertyValue.of(key, props.getProperty(key), source));
+            }
+        } catch (IOException e) {
+            throw new ConfigException("Error loading properties from " + propertiesFile, e);
+        }
+
+        return properties;
+    }
+
+    private static boolean isXMLPropertieFiles(URL url) {
+        return url.getFile().endsWith(".xml");
+    }
+
+
+    /**
+     * {@code SimplePropertySource} builder static inner class.
+     */
+    public static final class Builder {
+        private String name;
+        private Integer defaultOrdinal;
+        private Integer ordinal;
+        private Map<String, PropertyValue> properties = new HashMap<>();
+
+        private Builder() {
+        }
+
+        /**
+         * Sets the {@code name} to a new UUID and returns a reference to this Builder so that the methods
+         * can be chained together.
+         *
+         * @return a reference to this Builder
+         */
+        public Builder withUuidName() {
+            this.name = UUID.randomUUID().toString();
+            return this;
+        }
+
+        /**
+         * Sets the {@code name} and returns a reference to this Builder so that the methods
+         * can be chained together.
+         *
+         * @param val the {@code name} to set, not null.
+         * @return a reference to this Builder
+         */
+        public Builder withName(String val) {
+            this.name = Objects.requireNonNull(name);
+            return this;
+        }
+
+        /**
+         * Sets the {@code ordinal} and returns a reference to this Builder so that the methods
+         * can be chained together.
+         *
+         * @param val the {@code ordinal} to set
+         * @return a reference to this Builder
+         */
+        public Builder withOrdinal(int val) {
+            this.ordinal = val;
+            return this;
+        }
+
+        /**
+         * Sets the {@code defaultOrdinal} and returns a reference to this Builder so that the methods
+         * can be chained together.
+         *
+         * @param val the {@code defaultOrdinal} to set
+         * @return a reference to this Builder
+         */
+        public Builder withDefaultOrdinal(int val) {
+            this.defaultOrdinal = val;
+            return this;
+        }
+
+        /**
+         * Reads the {@code properties} from the given resource and returns a reference
+         * to this Builder so that the methods can be chained together.
+         *
+         * @param resource the {@code resource} to read
+         * @return a reference to this Builder
+         */
+        public Builder withProperties(URL resource) {
+            this.properties.putAll(load(resource));
+            return this;
+        }
+
+        /**
+         * Reads the {@code properties} from the given resource and returns a reference
+         * to this Builder so that the methods can be chained together.
+         *
+         * @param file the {@code file} to read from (xml or properties format).
+         * @return a reference to this Builder
+         */
+        public Builder withProperties(File file) {
+            try {
+                this.properties.putAll(load(file.toURI().toURL()));
+            } catch (MalformedURLException e) {
+                throw new IllegalArgumentException("Failed to read file: " + file, e);
+            }
+            return this;
+        }
+
+        /**
+         * Sets the {@code properties} and returns a reference to this Builder so that the methods can be chained together.
+         *
+         * @param val the {@code properties} to set
+         * @return a reference to this Builder
+         */
+        public Builder withProperties(Map<String, String> val) {
+            for(Map.Entry<String,String> en: val.entrySet()) {
+                this.properties.put(en.getKey(), PropertyValue.of(en.getKey(), en.getValue(), name));
+            }
+            return this;
+        }
+
+        /**
+         * Sets the {@code properties} and returns a reference to this Builder so that the methods can be chained together.
+         *
+         * @param val the {@code properties} to set
+         * @return a reference to this Builder
+         */
+        public Builder withProperty(String key, String val) {
+            this.properties.put(key, PropertyValue.of(key, val, name));
+            return this;
+        }
+
+        /**
+         * Returns a {@code SimplePropertySource} built from the parameters previously set.
+         *
+         * @return a {@code SimplePropertySource} built with parameters of this {@code SimplePropertySource.Builder}
+         */
+        public SimplePropertySource build() {
+            return new SimplePropertySource(this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
new file mode 100644
index 0000000..cfc60bb
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
@@ -0,0 +1,199 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * This {@link org.apache.tamaya.spi.PropertySource} manages the system properties. You can disable this feature by
+ * setting {@code tamaya.envprops.disable} or {@code tamaya.defaults.disable}.
+ */
+public class SystemPropertySource extends BasePropertySource {
+
+    /**
+     * default ordinal used.
+     */
+    public static final int DEFAULT_ORDINAL = 1000;
+
+    private volatile Map<String,PropertyValue> cachedProperties;
+
+    /**
+     * previous System.getProperties().hashCode()
+     * so we can check if we need to reload
+     */
+    private volatile int previousHash;
+
+    /**
+     * Prefix that allows system properties to virtually be mapped on specified sub section.
+     */
+    private String prefix;
+
+    /**
+     * If true, this property source does not return any properties. This is useful since this
+     * property source is applied by default, but can be switched off by setting the
+     * {@code tamaya.envprops.disable} system/environment property to {@code true}.
+     */
+    private boolean disabled = false;
+
+    /**
+     * Creates a new instance. Also initializes the {@code prefix} and {@code disabled} properties
+     * from the system-/ environment properties:
+     * <pre>
+     *     tamaya.envprops.prefix
+     *     tamaya.envprops.disable
+     * </pre>
+     */
+    public SystemPropertySource(){
+        super("system-properties", DEFAULT_ORDINAL);
+        initFromSystemProperties();
+        if(!disabled){
+            cachedProperties = Collections.unmodifiableMap(loadProperties());
+        }
+    }
+
+    /**
+     * Initializes the {@code prefix} and {@code disabled} properties from the system-/
+     * environment properties:
+     * <pre>
+     *     tamaya.envprops.prefix
+     *     tamaya.envprops.disable
+     * </pre>
+     */
+    private void initFromSystemProperties() {
+        String value = System.getProperty("tamaya.sysprops.prefix");
+        if(value==null){
+            prefix = System.getenv("tamaya.sysprops.prefix");
+        }
+        value = System.getProperty("tamaya.sysprops.disable");
+        if(value==null){
+            value = System.getenv("tamaya.sysprops.disable");
+        }
+        if(value==null){
+            value = System.getProperty("tamaya.defaults.disable");
+        }
+        if(value==null){
+            value = System.getenv("tamaya.defaults.disable");
+        }
+        if(value!=null && !value.isEmpty()) {
+            this.disabled = Boolean.parseBoolean(value);
+        }
+    }
+
+    /**
+     * Creates a new instance using a fixed ordinal value.
+     * @param ordinal the ordinal number.
+     */
+    public SystemPropertySource(int ordinal){
+        this(null, ordinal);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the prefix to be used, or null.
+     * @param ordinal the ordinal to be used.
+     */
+    public SystemPropertySource(String prefix, int ordinal){
+        this.prefix = prefix;
+        setOrdinal(ordinal);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param prefix the prefix to be used, or null.
+     */
+    public SystemPropertySource(String prefix){
+        this.prefix = prefix;
+    }
+
+
+    private Map<String, PropertyValue> loadProperties() {
+        Properties sysProps = System.getProperties();
+        previousHash = System.getProperties().hashCode();
+        final String prefix = this.prefix;
+        Map<String, PropertyValue> entries = new HashMap<>();
+        for (Map.Entry<Object,Object> entry : sysProps.entrySet()) {
+            if(entry.getKey() instanceof String && entry.getValue() instanceof String) {
+                if (prefix == null) {
+                    entries.put((String) entry.getKey(),
+                            PropertyValue.of((String) entry.getKey(),
+                                    (String) entry.getValue(),
+                                    getName()));
+                } else {
+                    entries.put(prefix + entry.getKey(),
+                            PropertyValue.of(prefix + entry.getKey(),
+                                    (String) entry.getValue(),
+                                    getName()));
+                }
+            }
+        }
+        return entries;
+    }
+
+    @Override
+    public String getName() {
+        if(disabled){
+            return super.getName() + "(disabled)";
+        }
+        return super.getName();
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        if(disabled){
+            return null;
+        }
+        String prefix = this.prefix;
+        if(prefix==null) {
+            return PropertyValue.of(key, System.getProperty(key), getName());
+        }
+        return PropertyValue.of(key, System.getProperty(key.substring(prefix.length())), getName());
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        if(disabled){
+            return Collections.emptyMap();
+        }
+        // only need to reload and fill our map if something has changed
+        // synchronization was removed, Instance was marked as volatile. In the worst case it
+        // is reloaded twice, but the values will be the same.
+        if (previousHash != System.getProperties().hashCode()) {
+            Map<String, PropertyValue> properties = loadProperties();
+            this.cachedProperties = Collections.unmodifiableMap(properties);
+        }
+        return this.cachedProperties;
+    }
+
+    @Override
+    public boolean isScannable() {
+        return true;
+    }
+
+    @Override
+    protected String toStringValues() {
+        return  super.toStringValues() +
+                "  prefix=" + prefix + '\n' +
+                "  disabled=" + disabled + '\n';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/WrappedPropertySource.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/WrappedPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/WrappedPropertySource.java
new file mode 100644
index 0000000..feaaf7b
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/WrappedPropertySource.java
@@ -0,0 +1,126 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Property source effectively managed by the configuration context, allowing resetting of ordinal and its
+ * delegate (e.g. in case of refresh).
+ */
+class WrappedPropertySource implements PropertySource{
+
+    private Integer ordinal;
+    private PropertySource delegate;
+    private long loaded = System.currentTimeMillis();
+
+    private WrappedPropertySource(PropertySource delegate) {
+        this(delegate, null);
+    }
+
+    private WrappedPropertySource(PropertySource delegate, Integer ordinal) {
+        this.delegate = Objects.requireNonNull(delegate);
+        this.ordinal = ordinal;
+    }
+
+    public static WrappedPropertySource of(PropertySource ps) {
+        if(ps instanceof  WrappedPropertySource){
+            return (WrappedPropertySource)ps;
+        }
+        return new WrappedPropertySource(ps);
+    }
+
+    public static WrappedPropertySource of(PropertySource ps, Integer ordinal) {
+        if(ps instanceof  WrappedPropertySource){
+            return new WrappedPropertySource(((WrappedPropertySource)ps).getDelegate(), ordinal);
+        }
+        return new WrappedPropertySource(ps, ordinal);
+    }
+
+    public int getOrdinal() {
+        if(this.ordinal!=null){
+            return this.ordinal;
+        }
+        return PropertySourceComparator.getOrdinal(delegate);
+    }
+
+    public void setOrdinal(Integer ordinal) {
+        this.ordinal = ordinal;
+    }
+
+    public void setDelegate(PropertySource delegate) {
+        this.delegate = Objects.requireNonNull(delegate);
+        this.loaded = System.currentTimeMillis();
+    }
+
+    @Override
+    public String getName() {
+        return delegate.getName();
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        return delegate.get(key);
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        return delegate.getProperties();
+    }
+
+    @Override
+    public boolean isScannable() {
+        return delegate.isScannable();
+    }
+
+    public PropertySource getDelegate() {
+        return delegate;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof WrappedPropertySource)) return false;
+
+        WrappedPropertySource that = (WrappedPropertySource) o;
+
+        return getDelegate().getName().equals(that.getDelegate().getName());
+    }
+
+    @Override
+    public int hashCode() {
+        return getDelegate().getName().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return "WrappedPropertySource{" +
+                "name=" + getName() +
+                ", ordinal=" + getOrdinal() +
+                ", scannable=" + isScannable() +
+                ", loadedAt=" + loaded +
+                ", delegate-class=" + delegate.getClass().getName() +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/package-info.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/package-info.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/package-info.java
new file mode 100644
index 0000000..21e5aec
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * Contains internal implementations artifacts registered as services.
+ */
+package org.apache.tamaya.spisupport.propertysource;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/A.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/A.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/A.java
new file mode 100644
index 0000000..4101f1e
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/A.java
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Test class for testing transitively evaluated property converters.
+ */
+class A implements AutoCloseable{
+    @Override
+    public void close() throws Exception {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/B.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/B.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/B.java
new file mode 100644
index 0000000..584b923
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/B.java
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Test class for testing transitively evaluated property converters.
+ */
+public class B extends A implements Runnable{
+    @Override
+    public void run() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java
new file mode 100644
index 0000000..5f95859
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceProviderTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.spisupport.propertysource.BuildablePropertySource;
+import org.apache.tamaya.spisupport.propertysource.BuildablePropertySourceProvider;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class BuildablePropertySourceProviderTest {
+
+    @Test
+    public void getPropertySources() throws Exception {
+        BuildablePropertySource ps = BuildablePropertySource.builder()
+                .withName("test1").build();
+        BuildablePropertySourceProvider prov = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps).build();
+        assertNotNull(prov);
+        assertEquals(prov.getPropertySources().iterator().next(), ps);
+    }
+
+    @Test
+    public void equals() throws Exception {
+        BuildablePropertySource ps = BuildablePropertySource.builder()
+                .withName("test1").build();
+        BuildablePropertySourceProvider prov1 = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps).build();
+        BuildablePropertySourceProvider prov2 = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps).build();
+        assertEquals(prov1, prov2);
+        BuildablePropertySource ps2 = BuildablePropertySource.builder()
+                .withName("test12").build();
+        prov2 = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps2).build();
+        assertNotEquals(prov1, prov2);
+    }
+
+    @Test
+    public void testHashCode() throws Exception {
+        BuildablePropertySource ps = BuildablePropertySource.builder()
+                .withName("test1").build();
+        BuildablePropertySourceProvider prov1 = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps).build();
+        BuildablePropertySourceProvider prov2 = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps).build();
+        assertEquals(prov1.hashCode(), prov2.hashCode());
+        BuildablePropertySource ps2 = BuildablePropertySource.builder()
+                .withName("test12").build();
+        prov2 = BuildablePropertySourceProvider.builder()
+                .withPropertySourcs(ps2).build();
+        assertNotEquals(prov1.hashCode(), prov2.hashCode());
+    }
+
+
+    @Test
+    public void builder() throws Exception {
+        assertNotNull(BuildablePropertySource.builder());
+        assertNotEquals(BuildablePropertySource.builder(), BuildablePropertySource.builder());
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java
new file mode 100644
index 0000000..b91cb59
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/BuildablePropertySourceTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.spisupport.propertysource.BuildablePropertySource;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class BuildablePropertySourceTest {
+    @Test
+    public void getOrdinal() throws Exception {
+        BuildablePropertySource ps1 = BuildablePropertySource.builder()
+                .withOrdinal(55).build();
+        assertEquals(55, ps1.getOrdinal());
+    }
+
+    @Test
+    public void getName() throws Exception {
+        BuildablePropertySource ps1 = BuildablePropertySource.builder()
+                .withName("test1").build();
+        assertEquals("test1", ps1.getName());
+        ps1 = BuildablePropertySource.builder().build();
+        assertNotNull(ps1.getName());
+    }
+
+    @Test
+    public void get() throws Exception {
+        BuildablePropertySource ps1 = BuildablePropertySource.builder()
+                .withSimpleProperty("a", "b").build();
+        assertEquals("b", ps1.get("a").getValue());
+    }
+
+    @Test
+    public void getProperties() throws Exception {
+        BuildablePropertySource ps1 = BuildablePropertySource.builder()
+                .withSimpleProperty("a", "b").build();
+        assertNotNull(ps1.getProperties());
+        assertEquals(1, ps1.getProperties().size());
+        assertEquals("b", ps1.getProperties().get("a").getValue());
+    }
+
+    @Test
+    public void equals() throws Exception {
+        BuildablePropertySource ps1 = BuildablePropertySource.builder()
+                .withName("test1").build();
+        BuildablePropertySource ps2 = BuildablePropertySource.builder()
+                .withName("test1").build();
+        assertEquals(ps1, ps2);
+        ps2 = BuildablePropertySource.builder()
+                .withName("test2").build();
+        assertNotEquals(ps1, ps2);
+    }
+
+    @Test
+    public void testHashCode() throws Exception {
+        BuildablePropertySource ps1 = BuildablePropertySource.builder()
+                .withName("test1").build();
+        BuildablePropertySource ps2 = BuildablePropertySource.builder()
+                .withName("test1").build();
+        assertEquals(ps1.hashCode(), ps2.hashCode());
+        ps2 = BuildablePropertySource.builder()
+                .withName("test2").build();
+        assertNotEquals(ps1.hashCode(), ps2.hashCode());
+    }
+
+    @Test
+    public void builder() throws Exception {
+        assertNotNull(BuildablePropertySource.builder());
+        assertNotEquals(BuildablePropertySource.builder(), BuildablePropertySource.builder());
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java
new file mode 100644
index 0000000..da581e6
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java
@@ -0,0 +1,56 @@
+/*
+ * 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 java.io.IOException;
+import java.nio.CharBuffer;
+
+/**
+ * Test class for testing transitively evaluated property converters.
+ */
+public class C extends B implements Readable{
+
+    private final String inValue;
+
+    public C(String inValue){
+        this.inValue = inValue;
+    }
+
+    @Override
+    public int read(CharBuffer cb) throws IOException {
+        return 0;
+    }
+
+    /**
+     * Returns the input value, set on creation. Used for test assertion.
+     * @return the in value.
+     */
+    public String getInValue() {
+        return inValue;
+    }
+
+    @Override
+    public String toString() {
+        return "C{" +
+                "inValue='" + inValue + '\'' +
+                '}';
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
new file mode 100644
index 0000000..dce8121
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+/**
+ * Created by Anatole on 13.06.2015.
+ */
+public class CTestConverter implements PropertyConverter<C>{
+    @Override
+    public C convert(String value, ConversionContext context) {
+        return new C(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
new file mode 100644
index 0000000..6e3dc5b
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
@@ -0,0 +1,201 @@
+/*
+ * 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.TypeLiteral;
+import org.apache.tamaya.spi.*;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class DefaultConfigurationTest {
+
+    /**
+     * Tests for get(String)
+     */
+    @Test(expected = NullPointerException.class)
+    public void getDoesNotAcceptNull() {
+        DefaultConfiguration c =  new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.get(null);
+    }
+
+    /**
+     * Tests for get(String, Class)
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	@Test(expected = NullPointerException.class)
+    public void getDoesNotAcceptNullForClassTargetType() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.get("a", (Class) null);
+    }
+
+    /**
+     * Tests for get(String, TypeLiteral)
+     */
+    @Test(expected = NullPointerException.class)
+    public void getDoesNotAcceptNullForTypeLiteralTargetType() {
+        DefaultConfiguration c =  new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.get("a", (TypeLiteral<?>)null);
+    }
+
+    /**
+     * Tests for getOrDefault(String, Class, String)
+     */
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsKeyForThreeParameterVariant() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault(null, String.class, "ok");
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsDefaultValueForThreeParameterVariant() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault("a", String.class, null);
+    }
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+	@Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsTargetTypeForThreeParameterVariant() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault("a", (Class)null, "b");
+    }
+
+    /**
+     * Tests for getOrDefault(String, TypeLiteral, String)
+     */
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsKeyForThreeParameterVariantSecondIsTypeLiteral() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault(null, TypeLiteral.of(String.class), "ok");
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsDefaultValueForThreeParameterVariantSecondIsTypeLiteral() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault("a", TypeLiteral.of(String.class), null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsTargetTypeForThreeParameterVariantSecondIsTypeLiteral() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault("a", (TypeLiteral<String>) null, "b");
+    }
+
+    /**
+     * Tests for getOrDefault(String, String)
+     */
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsKeyForTwoParameterVariantDefaultValueIsSecond() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault(null, "ok");
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void getOrDefaultDoesNotAcceptNullAsDefaultValueForTwoParameterVariantDefaultValueIsSecond() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.getOrDefault("a", null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void with_Null() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.with(null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void query_Null() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+
+        c.query(null);
+    }
+
+    @Test
+    public void with() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+        assertEquals(c.with(config -> config), c);
+    }
+
+    @Test
+    public void query() {
+        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
+        assertEquals(c.query(config -> "testQ"), "testQ");
+    }
+
+    public static class DummyConfigurationContext implements ConfigurationContext {
+        @Override
+        public void addPropertySources(PropertySource... propertySources) {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public List<PropertySource> getPropertySources() {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public PropertySource getPropertySource(String name) {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public <T> void addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T> propertyConverter) {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> type) {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public List<PropertyFilter> getPropertyFilters() {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy() {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+
+        @Override
+        public ConfigurationContextBuilder toBuilder() {
+            throw new RuntimeException("Method should be never called in this test");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContext.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContext.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContext.java
new file mode 100644
index 0000000..c5286e0
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContext.java
@@ -0,0 +1,78 @@
+/*
+ * 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.TypeLiteral;
+import org.apache.tamaya.spi.*;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class EmptyConfigurationContext implements ConfigurationContext{
+
+    private static final ConfigurationContext INSTANCE = new EmptyConfigurationContext();
+
+    @Override
+    public void addPropertySources(PropertySource... propertySources) {
+    }
+
+    @Override
+    public List<PropertySource> getPropertySources() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public PropertySource getPropertySource(String name) {
+        return null;
+    }
+
+    @Override
+    public <T> void addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T> propertyConverter) {
+    }
+
+    @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_POLICY;
+    }
+
+    @Override
+    public ConfigurationContextBuilder toBuilder() {
+        return EmptyConfigurationContextBuilder.instance();
+    }
+
+    public static ConfigurationContext instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContextBuilder.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContextBuilder.java
new file mode 100644
index 0000000..4f17d9a
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EmptyConfigurationContextBuilder.java
@@ -0,0 +1,174 @@
+/*
+ * 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 com.sun.org.apache.bcel.internal.generic.INSTANCEOF;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.*;
+
+import java.util.*;
+
+public class EmptyConfigurationContextBuilder implements ConfigurationContextBuilder{
+
+    private static final ConfigurationContextBuilder INSTANCE = new EmptyConfigurationContextBuilder();
+
+    @Override
+    public ConfigurationContextBuilder setContext(ConfigurationContext context) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertySources(PropertySource... propertySources) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertySources(Collection<PropertySource> propertySources) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addDefaultPropertySources() {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertySources(PropertySource... propertySources) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertySources(Collection<PropertySource> propertySources) {
+        return this;
+    }
+
+    @Override
+    public List<PropertySource> getPropertySources() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public List<PropertyFilter> getPropertyFilters() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter() {
+        return Collections.emptyMap();
+    }
+
+    @Override
+    public ConfigurationContextBuilder increasePriority(PropertySource propertySource) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder decreasePriority(PropertySource propertySource) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder highestPriority(PropertySource propertySource) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder lowestPriority(PropertySource propertySource) {
+        return null;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addDefaultPropertyFilters() {
+        return null;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters) {
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> typeToConvert, PropertyConverter<T>... propertyConverters) {
+        return null;
+    }
+
+    @Override
+    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> typeToConvert, Collection<PropertyConverter<T>> propertyConverters) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addDefaultPropertyConverters() {
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert, PropertyConverter<T>... propertyConverters) {
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert, Collection<PropertyConverter<T>> propertyConverters) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder sortPropertySources(Comparator<PropertySource> comparator) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy) {
+        return this;
+    }
+
+    @Override
+    public ConfigurationContext build() {
+        return EmptyConfigurationContext.instance();
+    }
+
+    public static ConfigurationContextBuilder instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java
new file mode 100644
index 0000000..b8e5555
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.spisupport.propertysource.SystemPropertySource;
+import org.junit.Test;
+
+import javax.annotation.Priority;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 12.09.16.
+ */
+public class PriorityServiceComparatorTest {
+
+    @Test
+    public void compare() throws Exception {
+        assertTrue(PriorityServiceComparator.getInstance().compare("a", "b")==0);
+        assertTrue(PriorityServiceComparator.getInstance().compare(getClass(), getClass())==0);
+        assertTrue(PriorityServiceComparator.getInstance().compare(new A(), new SystemPropertySource())==-1);
+        assertTrue(PriorityServiceComparator.getInstance().compare(new SystemPropertySource(), new A())==1);
+    }
+
+    @Priority(100)
+    private static final class A{}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
new file mode 100644
index 0000000..b91e6e4
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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.ConfigurationProvider;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.TypeLiteral;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+
+public class PropertyConverterManagerTest {
+
+    private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder(
+            "someKey", TypeLiteral.of(Object.class)).build();
+
+    @Test
+    public void customTypeWithFactoryMethodOfIsRecognizedAsSupported() {
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+
+        assertThat(manager.isTargetTypeSupported(TypeLiteral.of(MyType.class)),
+                   is(true));
+    }
+
+    @Test
+    public void factoryMethodOfIsUsedAsConverter() {
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+
+        List<PropertyConverter<MyType>> converters = manager.getPropertyConverters(
+                (TypeLiteral)TypeLiteral.of(MyType.class));
+
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<MyType> converter = converters.get(0);
+
+        Object result = converter.convert("IN", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(MyType.class));
+        assertThat(((MyType)result).getValue(), equalTo("IN"));
+    }
+
+    @Test
+    public void testDirectConverterMapping(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<C>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(C.class)));
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<C> converter = converters.get(0);
+        C result = converter.convert("testDirectConverterMapping", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(C.class));
+        assertThat((result).getInValue(), equalTo("testDirectConverterMapping"));
+    }
+
+    @Test
+    public void testDirectSuperclassConverterMapping(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<B>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+        assertThat(converters, hasSize(1));
+        converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<B> converter = converters.get(0);
+        B result = converter.convert("testDirectSuperclassConverterMapping", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(C.class));
+        assertThat(((C)result).getInValue(), equalTo("testDirectSuperclassConverterMapping"));
+    }
+
+    @Test
+    public void testMultipleConverterLoad(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<B>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+        assertThat(converters, hasSize(1));
+        manager = new PropertyConverterManager(true);
+        converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+        assertThat(converters, hasSize(1));
+    }
+
+    @Test
+    public void testTransitiveSuperclassConverterMapping(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<A>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(A.class)));
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<A> converter = converters.get(0);
+        A result = converter.convert("testTransitiveSuperclassConverterMapping", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(C.class));
+        assertThat(((C)result).getInValue(), equalTo("testTransitiveSuperclassConverterMapping"));
+    }
+
+    @Test
+    public void testDirectInterfaceMapping(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<Readable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(Readable.class)));
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<Readable> converter = converters.get(0);
+        Readable result = converter.convert("testDirectInterfaceMapping", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(C.class));
+        assertThat(((C)result).getInValue(), equalTo("testDirectInterfaceMapping"));
+    }
+
+    @Test
+    public void testTransitiveInterfaceMapping1(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<Runnable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(Runnable.class)));
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<Runnable> converter = converters.get(0);
+        Runnable result = converter.convert("testTransitiveInterfaceMapping1", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(C.class));
+        assertThat(((C)result).getInValue(), equalTo("testTransitiveInterfaceMapping1"));
+    }
+
+    @Test
+    public void testTransitiveInterfaceMapping2(){
+        PropertyConverterManager manager = new PropertyConverterManager(true);
+        List<PropertyConverter<AutoCloseable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(AutoCloseable.class)));
+        assertThat(converters, hasSize(1));
+
+        PropertyConverter<AutoCloseable> converter = converters.get(0);
+        AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2", DUMMY_CONTEXT);
+
+        assertThat(result, notNullValue());
+        assertThat(result, instanceOf(C.class));
+        assertThat(((C)result).getInValue(), equalTo("testTransitiveInterfaceMapping2"));
+    }
+
+    public static class MyType {
+        private final String typeValue;
+
+        private MyType(String value) {
+            typeValue = value;
+        }
+
+        public static MyType of(String source) {
+            return new MyType(source);
+        }
+
+        public String getValue() {
+            return typeValue;
+        }
+
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
new file mode 100644
index 0000000..9a212f7
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertyFilterComparator;
+import org.junit.Test;
+
+import javax.annotation.Priority;
+
+import java.util.Comparator;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PropertyFilterComparatorTest {
+
+    @Test
+    public void comparationOfFiltersWithSamePriorityIsCorrect() {
+        Comparator<PropertyFilter> comparator = PropertyFilterComparator.getInstance();
+
+        int result = comparator.compare(new PropertyFilterA(), new PropertyFilterA());
+
+        assertThat(result).isEqualTo(0);
+    }
+
+    @Test
+    public void comparationOfFiltersFirstHigherThenSecondWorksCorrectly() {
+        Comparator<PropertyFilter> comparator = PropertyFilterComparator.getInstance();
+
+        int result = comparator.compare(new PropertyFilterB(), new PropertyFilterA());
+
+        assertThat(result).isGreaterThan(0);
+    }
+
+    @Test
+    public void comparationOfFiltersSecondHigherThenFirstWorksCorrectly() {
+        Comparator<PropertyFilter> comparator = PropertyFilterComparator.getInstance();
+
+        int result = comparator.compare(new PropertyFilterA(), new PropertyFilterB());
+
+        assertThat(result).isLessThan(0);
+    }
+
+
+    @Priority(1)
+    private static class PropertyFilterA  implements PropertyFilter {
+        public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
+            throw new RuntimeException("Not implemented or look at me!");
+        }
+    }
+
+    @Priority(2)
+    private static class PropertyFilterB  implements PropertyFilter {
+        public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
+            throw new RuntimeException("Not implemented or look at me!");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
new file mode 100644
index 0000000..2822cb6
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.PropertyValue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link RegexPropertyFilter}. Created by anatole on 11.02.16.
+ */
+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 = EmptyConfigurationContext.instance();
+
+    @org.junit.Test
+    public void testFilterProperty() throws Exception {
+        RegexPropertyFilter filter = new RegexPropertyFilter();
+        filter.setIncludes("test1.*");
+        Map<String,PropertyValue> map = new HashMap<>();
+        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(
+                prop3,
+                new FilterContext(prop3, map, configContext)), prop3);
+        assertEquals(filter.filterProperty(
+                prop3,
+                new FilterContext(prop3, map, configContext)), prop3);
+        filter = new RegexPropertyFilter();
+        filter.setIncludes("test1.*");
+        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
+    public void testToString() throws Exception {
+        RegexPropertyFilter filter = new RegexPropertyFilter();
+        filter.setIncludes("test\\..*");
+        assertTrue(filter.toString().contains("test\\..*"));
+        assertTrue(filter.toString().contains("RegexPropertyFilter"));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/BasePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/BasePropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/BasePropertySourceTest.java
new file mode 100644
index 0000000..eb549a4
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/BasePropertySourceTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.*;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class BasePropertySourceTest {
+
+    @Test
+    public void isAlwaysScanable() {
+        BasePropertySource bs = new BasePropertySource() {
+            @Override
+            public Map<String, PropertyValue> getProperties() {
+                return Collections.emptyMap();
+            }
+        };
+
+        assertThat(bs.isScannable()).isTrue();
+    }
+
+    @Test
+    public void givenOrdinalOverwritesGivenDefaulOrdinal() {
+        BasePropertySource bs = new BasePropertySource() {
+            @Override
+            public Map<String, PropertyValue> getProperties() {
+                return Collections.emptyMap();
+            }
+        };
+
+        bs.setDefaultOrdinal(10);
+
+        assertThat(bs.getDefaultOrdinal()).isEqualTo(10);
+        assertThat(bs.getOrdinal()).isEqualTo(10);
+
+        bs.setOrdinal(20);
+
+        assertThat(bs.getOrdinal()).isEqualTo(20);
+    }
+
+    @Test
+    public void testGetOrdinal() {
+
+        PropertySource defaultPropertySource = new BasePropertySource(56) {
+
+            @Override
+            public String getName() {
+                return "testWithDefault";
+            }
+
+            @Override
+            public PropertyValue get(String key) {
+                return null;
+            }
+
+            @Override
+            public Map<String, PropertyValue> getProperties() {
+                return Collections.emptyMap();
+            }
+        };
+
+        Assert.assertEquals(56, PropertySourceComparator.getOrdinal(defaultPropertySource));
+        Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
+
+        // propertySource with invalid ordinal
+        Assert.assertEquals(1, new OverriddenInvalidOrdinalPropertySource().getOrdinal());
+    }
+
+    @Test
+    public void testGet() {
+        Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
+    }
+
+    private static class OverriddenOrdinalPropertySource extends BasePropertySource {
+
+        private OverriddenOrdinalPropertySource() {
+            super(250);
+        }
+
+        @Override
+        public String getName() {
+            return "overriddenOrdinal";
+        }
+
+        @Override
+        public Map<String, PropertyValue> getProperties() {
+            Map<String,PropertyValue> result = new HashMap<>(1);
+            result.put(PropertySource.TAMAYA_ORDINAL, PropertyValue.of(PropertySource.TAMAYA_ORDINAL, "1000", getName()));
+            return result;
+        }
+    }
+
+    private static class OverriddenInvalidOrdinalPropertySource extends BasePropertySource {
+
+        private OverriddenInvalidOrdinalPropertySource() {
+            super(1);
+        }
+
+        @Override
+        public String getName() {
+            return "overriddenInvalidOrdinal";
+        }
+
+        @Override
+        public Map<String, PropertyValue> getProperties() {
+            Map<String,PropertyValue> result = new HashMap<>(1);
+            result.put(PropertySource.TAMAYA_ORDINAL, PropertyValue.of(PropertySource.TAMAYA_ORDINAL, "invalid", getName()));
+            return result;
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySourceTest.java
new file mode 100644
index 0000000..4507772
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/CLIPropertySourceTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spisupport.propertysource.CLIPropertySource;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for PropertySource for reading main arguments as configuration.
+ */
+public class CLIPropertySourceTest {
+
+    @Test
+    public void setCLIProps() throws Exception {
+        System.clearProperty("main.args");
+        CLIPropertySource ps = new CLIPropertySource();
+        assertTrue(ps.getProperties().isEmpty());
+        CLIPropertySource.initMainArgs("-a", "b");
+        assertFalse(ps.getProperties().isEmpty());
+        assertEquals(ps.getProperties().get("a").getValue(), "b");
+        CLIPropertySource.initMainArgs("--c");
+        assertFalse(ps.getProperties().isEmpty());
+        assertEquals(ps.getProperties().get("c").getValue(), "c");
+        CLIPropertySource.initMainArgs("sss");
+        assertFalse(ps.getProperties().isEmpty());
+        assertEquals(ps.getProperties().get("sss").getValue(), "sss");
+        CLIPropertySource.initMainArgs("-a", "b", "--c", "sss", "--val=vvv");
+        assertFalse(ps.getProperties().isEmpty());
+        assertEquals(ps.getProperties().get("a").getValue(), "b");
+        assertEquals(ps.getProperties().get("c").getValue(), "c");
+        assertEquals(ps.getProperties().get("sss").getValue(), "sss");
+    // getProperties() throws Exception {
+        System.setProperty("main.args", "-a b\t--c sss  ");
+        ps = new CLIPropertySource();
+        assertFalse(ps.getProperties().isEmpty());
+        System.clearProperty("main.args");
+        assertEquals(ps.getProperties().get("a").getValue(), "b");
+        assertEquals(ps.getProperties().get("c").getValue(), "c");
+        assertEquals(ps.getProperties().get("sss").getValue(), "sss");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
new file mode 100644
index 0000000..3453caa
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spisupport.EnumConverter;
+import org.junit.Test;
+
+import java.math.RoundingMode;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Test class testing the {@link EnumConverter} class.
+ */
+public class EnumConverterTest {
+
+    private final EnumConverter testConverter = new EnumConverter(RoundingMode.class);
+
+    private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder("someKey", TypeLiteral.of(Enum.class)).build();
+
+    @Test
+    public void testConvert() {
+        assertEquals(testConverter.convert(RoundingMode.CEILING.toString(),
+                DUMMY_CONTEXT), RoundingMode.CEILING);
+    }
+
+    @Test
+    public void testConvert_LowerCase() {
+        assertEquals(testConverter.convert("ceiling", DUMMY_CONTEXT), RoundingMode.CEILING);
+    }
+
+    @Test
+    public void testConvert_MixedCase()  {
+        assertEquals(testConverter.convert("CeiLinG", DUMMY_CONTEXT), RoundingMode.CEILING);
+    }
+
+    @Test
+    public void testConvert_OtherValue() {
+        assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySourceTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySourceTest.java
new file mode 100644
index 0000000..1e6c958
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnvironmentPropertySourceTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link EnvironmentPropertySource}.
+ */
+public class EnvironmentPropertySourceTest {
+
+    private final EnvironmentPropertySource envPropertySource = new EnvironmentPropertySource();
+
+    @Test
+    public void testGetOrdinal() throws Exception {
+        assertEquals(EnvironmentPropertySource.DEFAULT_ORDINAL, envPropertySource.getOrdinal());
+    }
+
+    @Test
+    public void testGetName() throws Exception {
+        assertEquals("environment-properties", envPropertySource.getName());
+    }
+
+    @Test
+    public void testGet() throws Exception {
+        for (Map.Entry<String, String> envEntry : System.getenv().entrySet()) {
+            assertEquals(envPropertySource.get(envEntry.getKey()).getValue(), envEntry.getValue());
+        }
+    }
+
+    @Test
+    public void testGetProperties() throws Exception {
+        Map<String, PropertyValue> props = envPropertySource.getProperties();
+        for(Map.Entry<String,PropertyValue> en: props.entrySet()){
+            if(!en.getKey().startsWith("_")){
+                assertEquals(System.getenv(en.getKey()), en.getValue().getValue());
+            }
+        }
+    }
+
+    @Test
+    public void testIsScannable() throws Exception {
+        assertTrue(envPropertySource.isScannable());
+    }
+}
\ No newline at end of file



[12/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.


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

Branch: refs/heads/master
Commit: 545e1779bd77057e8cf0617acb1638ee4576c9f3
Parents: aa6dbe6
Author: Anatole Tresch <an...@apache.org>
Authored: Tue Nov 14 10:25:18 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Tue Nov 14 10:25:18 2017 +0100

----------------------------------------------------------------------
 code/api/pom.xml                                |   2 +-
 .../org/apache/tamaya/core/OSGIActivator.java   |   4 +-
 .../core/internal/CoreConfigurationContext.java |  52 +++
 .../CoreConfigurationContextBuilder.java        |  93 ++++
 .../internal/DefaultConfigurationContext.java   | 291 ------------
 .../DefaultConfigurationContextBuilder.java     | 461 -------------------
 .../internal/DefaultConfigurationProvider.java  |   4 +-
 ...pache.tamaya.spi.ConfigurationContextBuilder |   2 +-
 .../core/ConfigurationContextBuilderTest.java   |   8 +-
 .../CoreConfigurationContextBuilderTest.java    | 200 ++++++++
 .../internal/CoreConfigurationContextTest.java  | 176 +++++++
 .../DefaultConfigurationContextBuilderTest.java | 200 --------
 .../DefaultConfigurationContextTest.java        | 176 -------
 .../DefaultConfigurationProviderTest.java       |   2 +-
 code/spi-support/pom.xml                        |   2 +-
 .../spisupport/DefaultConfigurationContext.java | 277 +++++++++++
 .../DefaultConfigurationContextBuilder.java     | 437 ++++++++++++++++++
 .../examples/minimal/TestConfigProvider.java    |  30 +-
 18 files changed, 1274 insertions(+), 1143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/api/pom.xml
----------------------------------------------------------------------
diff --git a/code/api/pom.xml b/code/api/pom.xml
index 99f08dd..581e18d 100644
--- a/code/api/pom.xml
+++ b/code/api/pom.xml
@@ -26,7 +26,7 @@ under the License.
     </parent>
 
     <artifactId>tamaya-api</artifactId>
-    <name>Apache Tamaya API</name>
+    <name>Apache Tamaya Core API</name>
     <packaging>jar</packaging>
 
     <description>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java b/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
index 09bf384..3ddaf69 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
@@ -24,7 +24,7 @@ import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.core.internal.*;
 import org.apache.tamaya.spi.ServiceContextManager;
 import org.apache.tamaya.spisupport.DefaultConfiguration;
-import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder;
+import org.apache.tamaya.core.internal.CoreConfigurationContextBuilder;
 import org.apache.tamaya.spisupport.PropertyFilterComparator;
 import org.apache.tamaya.spisupport.PropertySourceComparator;
 import org.osgi.framework.BundleActivator;
@@ -50,7 +50,7 @@ public class OSGIActivator implements BundleActivator {
         LOG.info("Registered Tamaya OSGI ServiceContext...");
         ConfigurationProvider.setConfiguration(
                 new DefaultConfiguration(
-                       new DefaultConfigurationContextBuilder()
+                       new CoreConfigurationContextBuilder()
                         .addDefaultPropertyConverters()
                         .addDefaultPropertyFilters()
                         .addDefaultPropertySources()

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContext.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContext.java
new file mode 100644
index 0000000..dd31b91
--- /dev/null
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContext.java
@@ -0,0 +1,52 @@
+/*
+ * 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.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.core.internal.converters.*;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spisupport.DefaultConfigurationContext;
+import org.apache.tamaya.spisupport.DefaultConfigurationContextBuilder;
+
+import java.io.File;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.Currency;
+
+/**
+ * Default implementation of {@link ConfigurationContextBuilder}.
+ */
+public final class CoreConfigurationContext extends DefaultConfigurationContext {
+
+    /**
+     * Creates a new builder instance.
+     */
+    public CoreConfigurationContext(CoreConfigurationContextBuilder builder) {
+        super(builder);
+    }
+
+    @Override
+    public ConfigurationContextBuilder toBuilder() {
+        return new CoreConfigurationContextBuilder(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilder.java
new file mode 100644
index 0000000..d440a88
--- /dev/null
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilder.java
@@ -0,0 +1,93 @@
+/*
+ * 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.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.core.internal.converters.*;
+import org.apache.tamaya.spisupport.DefaultConfigurationContextBuilder;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
+import org.apache.tamaya.spisupport.propertysource.CLIPropertySource;
+import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource;
+import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
+
+import java.io.File;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.*;
+import java.util.logging.Logger;
+
+/**
+ * Default implementation of {@link ConfigurationContextBuilder}.
+ */
+public final class CoreConfigurationContextBuilder extends DefaultConfigurationContextBuilder {
+
+    /**
+     * Creates a new builder instance.
+     */
+    public CoreConfigurationContextBuilder() {
+    }
+
+    /**
+     * Creates a new builder instance initializing it with the given context.
+     * @param context the context to be used, not null.
+     */
+    public CoreConfigurationContextBuilder(ConfigurationContext context) {
+        super(context);
+    }
+
+    @SuppressWarnings("unchecked")
+	protected void addCorePropertyConverters() {
+        addPropertyConverters(TypeLiteral.<BigDecimal>of(BigDecimal.class), new BigDecimalConverter());
+        addPropertyConverters(TypeLiteral.<BigInteger>of(BigInteger.class), new BigIntegerConverter());
+        addPropertyConverters(TypeLiteral.<Boolean>of(Boolean.class), new BooleanConverter());
+        addPropertyConverters(TypeLiteral.<Byte>of(Byte.class), new ByteConverter());
+        addPropertyConverters(TypeLiteral.<Character>of(Character.class), new CharConverter());
+        addPropertyConverters(TypeLiteral.<Class<?>>of(Class.class), new ClassConverter());
+        addPropertyConverters(TypeLiteral.<Currency>of(Currency.class), new CurrencyConverter());
+        addPropertyConverters(TypeLiteral.<Double>of(Double.class), new DoubleConverter());
+        addPropertyConverters(TypeLiteral.<File>of(File.class), new FileConverter());
+        addPropertyConverters(TypeLiteral.<Float>of(Float.class), new FloatConverter());
+        addPropertyConverters(TypeLiteral.<Integer>of(Integer.class), new IntegerConverter());
+        addPropertyConverters(TypeLiteral.<Long>of(Long.class), new LongConverter());
+        addPropertyConverters(TypeLiteral.<Number>of(Number.class), new NumberConverter());
+        addPropertyConverters(TypeLiteral.<Path>of(Path.class), new PathConverter());
+        addPropertyConverters(TypeLiteral.<Short>of(Short.class), new ShortConverter());
+        addPropertyConverters(TypeLiteral.<URI>of(URI.class), new URIConverter());
+        addPropertyConverters(TypeLiteral.<URL>of(URL.class), new URLConverter());
+    }
+
+    @Override
+    public ConfigurationContext build() {
+        return new CoreConfigurationContext(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
deleted file mode 100644
index 95ebbca..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
+++ /dev/null
@@ -1,291 +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.core.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.spisupport.PropertyConverterManager;
-import org.apache.tamaya.spisupport.PropertySourceComparator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Default implementation of a simple ConfigurationContext.
- */
-public class DefaultConfigurationContext implements ConfigurationContext {
-
-    /** The logger used. */
-    private final static Logger LOG = Logger.getLogger(DefaultConfigurationContext.class.getName());
-
-    /**
-     * Subcomponent handling {@link org.apache.tamaya.spi.PropertyConverter} instances.
-     */
-    private final PropertyConverterManager propertyConverterManager = new PropertyConverterManager();
-
-    /**
-     * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertySource} instances.
-     */
-    private List<PropertySource> immutablePropertySources;
-
-    /**
-     * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertyFilter} instances.
-     */
-    private List<PropertyFilter> immutablePropertyFilters;
-
-    /**
-     * The overriding policy used when combining PropertySources registered to evalute the final configuration
-     * values.
-     */
-    private PropertyValueCombinationPolicy propertyValueCombinationPolicy;
-
-    /**
-     * Lock for internal synchronization.
-     */
-    private final ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
-
-    @SuppressWarnings("unchecked")
-	DefaultConfigurationContext(DefaultConfigurationContextBuilder builder) {
-        List<PropertySource> propertySources = new ArrayList<>();
-        // first we load all PropertySources which got registered via java.util.ServiceLoader
-        propertySources.addAll(builder.propertySources);
-        // now sort them according to their ordinal values
-        immutablePropertySources = Collections.unmodifiableList(propertySources);
-
-        // as next step we pick up the PropertyFilters pretty much the same way
-        List<PropertyFilter> propertyFilters = new ArrayList<>(builder.getPropertyFilters());
-        immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
-
-        // Finally add the converters
-        for(Map.Entry<TypeLiteral<?>, Collection<PropertyConverter<?>>> en:builder.getPropertyConverter().entrySet()) {
-            for (@SuppressWarnings("rawtypes") PropertyConverter converter : en.getValue()) {
-                this.propertyConverterManager.register(en.getKey(), converter);
-            }
-        }
-        LOG.info("Registered " + propertyConverterManager.getPropertyConverters().size() + " property converters: " +
-                propertyConverterManager.getPropertyConverters());
-
-        propertyValueCombinationPolicy = builder.combinationPolicy;
-        if(propertyValueCombinationPolicy==null){
-            propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
-        }
-        if(propertyValueCombinationPolicy==null){
-            propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
-        }
-        LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
-    }
-
-
-    @Deprecated
-    @Override
-    public void addPropertySources(PropertySource... propertySourcesToAdd) {
-        Lock writeLock = propertySourceLock.writeLock();
-        try {
-            writeLock.lock();
-            List<PropertySource> newPropertySources = new ArrayList<>(this.immutablePropertySources);
-            newPropertySources.addAll(Arrays.asList(propertySourcesToAdd));
-            Collections.sort(newPropertySources, PropertySourceComparator.getInstance());
-
-            this.immutablePropertySources = Collections.unmodifiableList(newPropertySources);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (!(o instanceof DefaultConfigurationContext)){
-            return false;
-        }
-
-        DefaultConfigurationContext that = (DefaultConfigurationContext) o;
-
-        if (!propertyConverterManager.equals(that.propertyConverterManager)) {
-            return false;
-        }
-        if (!immutablePropertySources.equals(that.immutablePropertySources)) {
-            return false;
-        }
-        if (!immutablePropertyFilters.equals(that.immutablePropertyFilters)) {
-            return false;
-        }
-        return getPropertyValueCombinationPolicy().equals(that.getPropertyValueCombinationPolicy());
-
-    }
-
-    @Override
-    public int hashCode() {
-        int result = propertyConverterManager.hashCode();
-        result = 31 * result + immutablePropertySources.hashCode();
-        result = 31 * result + immutablePropertyFilters.hashCode();
-        result = 31 * result + getPropertyValueCombinationPolicy().hashCode();
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder b = new StringBuilder("ConfigurationContext{\n");
-        b.append("  Property Sources\n");
-        b.append("  ----------------\n");
-        if(immutablePropertySources.isEmpty()){
-            b.append("  No property sources loaded.\n\n");
-        }else {
-            b.append("  CLASS                         NAME                                                                  ORDINAL SCANNABLE SIZE    STATE     ERROR\n\n");
-            for (PropertySource ps : immutablePropertySources) {
-                b.append("  ");
-                appendFormatted(b, ps.getClass().getSimpleName(), 30);
-                appendFormatted(b, ps.getName(), 70);
-                appendFormatted(b, String.valueOf(PropertySourceComparator.getOrdinal(ps)), 8);
-                appendFormatted(b, String.valueOf(ps.isScannable()), 10);
-                if (ps.isScannable()) {
-                    appendFormatted(b, String.valueOf(ps.getProperties().size()), 8);
-                } else {
-                    appendFormatted(b, "-", 8);
-                }
-                PropertyValue state = ps.get("_state");
-                if(state==null){
-                    appendFormatted(b, "OK", 10);
-                }else {
-                    appendFormatted(b, state.getValue(), 10);
-                    if("ERROR".equals(state.getValue())){
-                        PropertyValue val = ps.get("_exception");
-                        if(val!=null) {
-                            appendFormatted(b, val.getValue(), 30);
-                        }
-                    }
-                }
-                b.append('\n');
-            }
-            b.append("\n");
-        }
-        b.append("  Property Filters\n");
-        b.append("  ----------------\n");
-        if(immutablePropertyFilters.isEmpty()){
-            b.append("  No property filters loaded.\n\n");
-        }else {
-            b.append("  CLASS                         INFO\n\n");
-            for (PropertyFilter filter : getPropertyFilters()) {
-                b.append("  ");
-                appendFormatted(b, filter.getClass().getSimpleName(), 30);
-                b.append(removeNewLines(filter.toString()));
-                b.append('\n');
-            }
-            b.append("\n\n");
-        }
-        b.append("  Property Converters\n");
-        b.append("  -------------------\n");
-        b.append("  CLASS                         TYPE                          INFO\n\n");
-        for(Map.Entry<TypeLiteral<?>, List<PropertyConverter<?>>> converterEntry:getPropertyConverters().entrySet()){
-            for(PropertyConverter converter: converterEntry.getValue()){
-                b.append("  ");
-                appendFormatted(b, converter.getClass().getSimpleName(), 30);
-                appendFormatted(b, converterEntry.getKey().getRawType().getSimpleName(), 30);
-                b.append(removeNewLines(converter.toString()));
-                b.append('\n');
-            }
-        }
-        b.append("\n\n");
-        b.append("  PropertyValueCombinationPolicy: " + getPropertyValueCombinationPolicy().getClass().getName()).append('\n');
-        b.append('}');
-        return b.toString();
-    }
-
-    private void appendFormatted(StringBuilder b, String text, int length) {
-        int padding;
-        if(text.length() <= (length)){
-            b.append(text);
-            padding = length - text.length();
-        }else{
-            b.append(text.substring(0, length-1));
-            padding = 1;
-        }
-        for(int i=0;i<padding;i++){
-            b.append(' ');
-        }
-    }
-
-    private String removeNewLines(String s) {
-        return s.replace('\n', ' ').replace('\r', ' ');
-    }
-
-
-    @Override
-    public List<PropertySource> getPropertySources() {
-        return immutablePropertySources;
-    }
-
-    @Override
-    public PropertySource getPropertySource(String name) {
-        for(PropertySource ps:getPropertySources()){
-            if(name.equals(ps.getName())){
-                return ps;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
-        propertyConverterManager.register(typeToConvert, propertyConverter);
-        LOG.info("Added PropertyConverter: " + propertyConverter.getClass().getName());
-    }
-
-    @Override
-    public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
-        return propertyConverterManager.getPropertyConverters();
-    }
-
-    @Override
-    public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
-        return propertyConverterManager.getPropertyConverters(targetType);
-    }
-
-    @Override
-    public List<PropertyFilter> getPropertyFilters() {
-        return immutablePropertyFilters;
-    }
-
-    @Override
-    public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy(){
-        return propertyValueCombinationPolicy;
-    }
-
-    @Override
-    public ConfigurationContextBuilder toBuilder() {
-        return new DefaultConfigurationContextBuilder(this);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
deleted file mode 100644
index 8268f64..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
+++ /dev/null
@@ -1,461 +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.core.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.core.internal.converters.*;
-import org.apache.tamaya.spisupport.PropertySourceComparator;
-import org.apache.tamaya.spisupport.propertysource.CLIPropertySource;
-import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
-import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource;
-import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
-
-import java.io.File;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.net.URL;
-import java.nio.file.Path;
-import java.util.*;
-import java.util.logging.Logger;
-
-/**
- * Default implementation of {@link ConfigurationContextBuilder}.
- */
-public class DefaultConfigurationContextBuilder implements ConfigurationContextBuilder {
-
-    private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextBuilder.class.getName());
-
-    List<PropertyFilter> propertyFilters = new ArrayList<>();
-    List<PropertySource> propertySources = new ArrayList<>();
-    PropertyValueCombinationPolicy combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
-    Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> propertyConverters = new HashMap<>();
-
-    /**
-     * Flag if the config has already been built.
-     * Configuration can be built only once
-     */
-    private boolean built;
-
-
-
-    /**
-     * Creates a new builder instance.
-     */
-    public DefaultConfigurationContextBuilder() {
-    }
-
-    /**
-     * Creates a new builder instance initializing it with the given context.
-     * @param context the context to be used, not null.
-     */
-    public DefaultConfigurationContextBuilder(ConfigurationContext context) {
-        this.propertyConverters.putAll(context.getPropertyConverters());
-        this.propertyFilters.addAll(context.getPropertyFilters());
-        for(PropertySource ps:context.getPropertySources()) {
-            addPropertySources(ps);
-        }
-        this.combinationPolicy = context.getPropertyValueCombinationPolicy();
-    }
-
-    /**
-     * Allows to set configuration context during unit tests.
-     */
-    ConfigurationContextBuilder setConfigurationContext(ConfigurationContext configurationContext) {
-        checkBuilderState();
-        //noinspection deprecation
-        this.propertyFilters.clear();
-        this.propertyFilters.addAll(configurationContext.getPropertyFilters());
-        this.propertySources.clear();
-        for(PropertySource ps:configurationContext.getPropertySources()) {
-            addPropertySources(ps);
-        }
-        this.propertyConverters.clear();
-        this.propertyConverters.putAll(configurationContext.getPropertyConverters());
-        this.combinationPolicy = configurationContext.getPropertyValueCombinationPolicy();
-        return this;
-    }
-
-
-    @Override
-    public ConfigurationContextBuilder setContext(ConfigurationContext context) {
-        checkBuilderState();
-        this.propertyConverters.putAll(context.getPropertyConverters());
-        for(PropertySource ps:context.getPropertySources()){
-            this.propertySources.add(ps);
-        }
-        this.propertyFilters.addAll(context.getPropertyFilters());
-        this.combinationPolicy = context.getPropertyValueCombinationPolicy();
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder addPropertySources(PropertySource... sources){
-        return addPropertySources(Arrays.asList(sources));
-    }
-
-    @Override
-    public ConfigurationContextBuilder addPropertySources(Collection<PropertySource> sources){
-        checkBuilderState();
-        for(PropertySource source:sources) {
-            if (!this.propertySources.contains(source)) {
-                this.propertySources.add(source);
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder addDefaultPropertySources() {
-        checkBuilderState();
-        List<PropertySource> propertySources = new ArrayList<>();
-        addCorePropertyResources(propertySources);
-        for(PropertySource ps: ServiceContextManager.getServiceContext().getServices(PropertySource.class)) {
-            if(!propertySources.contains(ps)){
-                propertySources.add(ps);
-            }
-        }
-        for(PropertySourceProvider provider:
-                ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class)){
-                propertySources.addAll(provider.getPropertySources());
-        }
-        Collections.sort(propertySources, PropertySourceComparator.getInstance());
-        return addPropertySources(propertySources);
-    }
-
-    private void addCorePropertyResources(List<PropertySource> propertySources) {
-        for(PropertySource ps: new PropertySource[]{
-                new EnvironmentPropertySource(),
-                new JavaConfigurationPropertySource(),
-                new CLIPropertySource(),
-                new SystemPropertySource()
-        }){
-            if(!propertySources.contains(ps)){
-                propertySources.add(ps);
-            }
-        }
-    }
-
-    @Override
-    public ConfigurationContextBuilder addDefaultPropertyFilters() {
-        checkBuilderState();
-        for(PropertyFilter pf:ServiceContextManager.getServiceContext().getServices(PropertyFilter.class)){
-            addPropertyFilters(pf);
-        }
-        return this;
-    }
-
-    public DefaultConfigurationContextBuilder addDefaultPropertyConverters() {
-        checkBuilderState();
-        addCorePropertyConverters();
-        for(Map.Entry<TypeLiteral, Collection<PropertyConverter>> en:getDefaultPropertyConverters().entrySet()){
-            for(PropertyConverter pc: en.getValue()) {
-                addPropertyConverters(en.getKey(), pc);
-            }
-        }
-        return this;
-    }
-
-    @SuppressWarnings("unchecked")
-	protected void addCorePropertyConverters() {
-        addPropertyConverters(TypeLiteral.<BigDecimal>of(BigDecimal.class), new BigDecimalConverter());
-        addPropertyConverters(TypeLiteral.<BigInteger>of(BigInteger.class), new BigIntegerConverter());
-        addPropertyConverters(TypeLiteral.<Boolean>of(Boolean.class), new BooleanConverter());
-        addPropertyConverters(TypeLiteral.<Byte>of(Byte.class), new ByteConverter());
-        addPropertyConverters(TypeLiteral.<Character>of(Character.class), new CharConverter());
-        addPropertyConverters(TypeLiteral.<Class<?>>of(Class.class), new ClassConverter());
-        addPropertyConverters(TypeLiteral.<Currency>of(Currency.class), new CurrencyConverter());
-        addPropertyConverters(TypeLiteral.<Double>of(Double.class), new DoubleConverter());
-        addPropertyConverters(TypeLiteral.<File>of(File.class), new FileConverter());
-        addPropertyConverters(TypeLiteral.<Float>of(Float.class), new FloatConverter());
-        addPropertyConverters(TypeLiteral.<Integer>of(Integer.class), new IntegerConverter());
-        addPropertyConverters(TypeLiteral.<Long>of(Long.class), new LongConverter());
-        addPropertyConverters(TypeLiteral.<Number>of(Number.class), new NumberConverter());
-        addPropertyConverters(TypeLiteral.<Path>of(Path.class), new PathConverter());
-        addPropertyConverters(TypeLiteral.<Short>of(Short.class), new ShortConverter());
-        addPropertyConverters(TypeLiteral.<URI>of(URI.class), new URIConverter());
-        addPropertyConverters(TypeLiteral.<URL>of(URL.class), new URLConverter());
-    }
-
-    @Override
-    public ConfigurationContextBuilder removePropertySources(PropertySource... propertySources) {
-        return removePropertySources(Arrays.asList(propertySources));
-    }
-
-    @Override
-    public ConfigurationContextBuilder removePropertySources(Collection<PropertySource> propertySources) {
-        checkBuilderState();
-        this.propertySources.removeAll(propertySources);
-        return this;
-    }
-
-    private PropertySource getPropertySource(String name) {
-        for(PropertySource ps:propertySources){
-            if(ps.getName().equals(name)){
-                return ps;
-            }
-        }
-        throw new IllegalArgumentException("No such PropertySource: "+name);
-    }
-
-    @Override
-    public List<PropertySource> getPropertySources() {
-        return this.propertySources;
-    }
-
-    @Override
-    public ConfigurationContextBuilder increasePriority(PropertySource propertySource) {
-        checkBuilderState();
-        int index = propertySources.indexOf(propertySource);
-        if(index<0){
-            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
-        }
-        if(index<(propertySources.size()-1)){
-            propertySources.remove(propertySource);
-            propertySources.add(index+1, propertySource);
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder decreasePriority(PropertySource propertySource) {
-        checkBuilderState();
-        int index = propertySources.indexOf(propertySource);
-        if(index<0){
-            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
-        }
-        if(index>0){
-            propertySources.remove(propertySource);
-            propertySources.add(index-1, propertySource);
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder highestPriority(PropertySource propertySource) {
-        checkBuilderState();
-        int index = propertySources.indexOf(propertySource);
-        if(index<0){
-            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
-        }
-        if(index<(propertySources.size()-1)){
-            propertySources.remove(propertySource);
-            propertySources.add(propertySource);
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder lowestPriority(PropertySource propertySource) {
-        checkBuilderState();
-        int index = propertySources.indexOf(propertySource);
-        if(index<0){
-            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
-        }
-        if(index>0){
-            propertySources.remove(propertySource);
-            propertySources.add(0, propertySource);
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters){
-        return addPropertyFilters(Arrays.asList(filters));
-    }
-
-    @Override
-    public ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters){
-        checkBuilderState();
-        for(PropertyFilter f:filters) {
-            if (!this.propertyFilters.contains(f)) {
-                this.propertyFilters.add(f);
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters) {
-        return removePropertyFilters(Arrays.asList(filters));
-    }
-
-    @Override
-    public ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters) {
-        checkBuilderState();
-        this.propertyFilters.removeAll(filters);
-        return this;
-    }
-
-
-    @Override
-    public <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
-                                                                    @SuppressWarnings("unchecked") PropertyConverter<T>... converters) {
-        return removePropertyConverters(typeToConvert, Arrays.asList(converters));
-    }
-
-    @Override
-    public <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
-                                                                    Collection<PropertyConverter<T>> converters) {
-        Collection<PropertyConverter<?>> subConverters = this.propertyConverters.get(typeToConvert);
-        if(subConverters!=null) {
-            subConverters.removeAll(converters);
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert) {
-        this.propertyConverters.remove(typeToConvert);
-        return this;
-    }
-
-
-    @Override
-    public ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy combinationPolicy){
-        checkBuilderState();
-        this.combinationPolicy = Objects.requireNonNull(combinationPolicy);
-        return this;
-    }
-
-
-    @Override
-    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> type, PropertyConverter<T>... propertyConverters){
-        checkBuilderState();
-        Objects.requireNonNull(type);
-        Objects.requireNonNull(propertyConverters);
-        Collection<PropertyConverter<?>> converters = this.propertyConverters.get(type);
-        if(converters==null){
-            converters = new ArrayList<>();
-            this.propertyConverters.put(type, converters);
-        }
-        for(PropertyConverter<T> propertyConverter:propertyConverters) {
-            if (!converters.contains(propertyConverter)) {
-                converters.add(propertyConverter);
-            } else {
-                LOG.warning("Converter ignored, already registered: " + propertyConverter);
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> type, Collection<PropertyConverter<T>> propertyConverters){
-        checkBuilderState();
-        Objects.requireNonNull(type);
-        Objects.requireNonNull(propertyConverters);
-        Collection<PropertyConverter<?>> converters = this.propertyConverters.get(type);
-        if(converters==null){
-            converters = new ArrayList<>();
-            this.propertyConverters.put(type, converters);
-        }
-        for(PropertyConverter<T> propertyConverter:propertyConverters) {
-            if (!converters.contains(propertyConverter)) {
-                converters.add(propertyConverter);
-            } else {
-                LOG.warning("Converter ignored, already registered: " + propertyConverter);
-            }
-        }
-        return this;
-    }
-
-    protected ConfigurationContextBuilder loadDefaults() {
-        checkBuilderState();
-        this.combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
-        addDefaultPropertySources();
-        addDefaultPropertyFilters();
-        addDefaultPropertyConverters();
-        return this;
-    }
-
-
-    private Map<TypeLiteral, Collection<PropertyConverter>> getDefaultPropertyConverters() {
-        Map<TypeLiteral, Collection<PropertyConverter>> result = new HashMap<>();
-        for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(
-                PropertyConverter.class)) {
-            for(Type type:conv.getClass().getGenericInterfaces()){
-                if(type instanceof ParameterizedType){
-                    ParameterizedType pt = (ParameterizedType)type;
-                    if(PropertyConverter.class.equals(((ParameterizedType) type).getRawType())){
-                        TypeLiteral target = TypeLiteral.of(pt.getActualTypeArguments()[0]);
-                        Collection<PropertyConverter> convList = result.get(target);
-                        if (convList == null) {
-                            convList = new ArrayList<>();
-                            result.put(target, convList);
-                        }
-                        convList.add(conv);
-                    }
-                }
-            }
-        }
-        return result;
-    }
-
-
-    /**
-     * Builds a new configuration based on the configuration of this builder instance.
-     *
-     * @return a new {@link org.apache.tamaya.Configuration configuration instance},
-     *         never {@code null}.
-     */
-    @Override
-    public ConfigurationContext build() {
-        checkBuilderState();
-        built = true;
-        return new DefaultConfigurationContext(this);
-    }
-
-    @Override
-    public ConfigurationContextBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator) {
-        Collections.sort(propertyFilters, comparator);
-        return this;
-    }
-
-    @Override
-    public ConfigurationContextBuilder sortPropertySources(Comparator<PropertySource> comparator) {
-        Collections.sort(propertySources, comparator);
-        return this;
-    }
-
-    private void checkBuilderState() {
-        if (built) {
-            throw new IllegalStateException("Configuration has already been build.");
-        }
-    }
-
-    @Override
-    public List<PropertyFilter> getPropertyFilters() {
-        return propertyFilters;
-    }
-
-    @Override
-    public Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter() {
-        return Collections.unmodifiableMap(this.propertyConverters);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
index dd73889..f37d4c3 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
@@ -35,7 +35,7 @@ import java.util.Objects;
 @Component(service = ConfigurationProviderSpi.class)
 public class DefaultConfigurationProvider implements ConfigurationProviderSpi {
 
-    ConfigurationContext context = new DefaultConfigurationContextBuilder()
+    ConfigurationContext context = new CoreConfigurationContextBuilder()
             .addDefaultPropertyConverters()
             .addDefaultPropertyFilters()
             .addDefaultPropertySources()
@@ -62,7 +62,7 @@ public class DefaultConfigurationProvider implements ConfigurationProviderSpi {
 
     @Override
     public ConfigurationContextBuilder getConfigurationContextBuilder() {
-        return new DefaultConfigurationContextBuilder();
+        return new CoreConfigurationContextBuilder();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationContextBuilder
----------------------------------------------------------------------
diff --git a/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationContextBuilder b/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationContextBuilder
index 4efa42e..700b2b5 100644
--- a/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationContextBuilder
+++ b/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationContextBuilder
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder
\ No newline at end of file
+org.apache.tamaya.core.internal.CoreConfigurationContextBuilder
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
index 2c8f627..5fb65ff 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.core;
 import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.TypeLiteral;
 import org.apache.tamaya.spi.*;
-import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder;
+import org.apache.tamaya.core.internal.CoreConfigurationContextBuilder;
 import org.junit.Test;
 
 import java.util.Arrays;
@@ -30,7 +30,7 @@ import java.util.Comparator;
 import static org.junit.Assert.*;
 
 /**
- * Tests for {@link DefaultConfigurationContextBuilder} by atsticks on 06.09.16.
+ * Tests for {@link CoreConfigurationContextBuilder} by atsticks on 06.09.16.
  */
 public class ConfigurationContextBuilderTest {
 
@@ -47,7 +47,7 @@ public class ConfigurationContextBuilderTest {
     @Test
     public void addPropertySources_Array() throws Exception {
         PropertySource testPS2 = new TestPropertySource("addPropertySources_Array", 1);
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
                 .addPropertySources(testPropertySource, testPS2);
         ConfigurationContext ctx = b.build();
         assertEquals(2, ctx.getPropertySources().size());
@@ -68,7 +68,7 @@ public class ConfigurationContextBuilderTest {
     @Test
     public void addPropertySources_Collection() throws Exception {
         PropertySource testPS2 = new TestPropertySource("addPropertySources_Collection", 1);
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
                 .addPropertySources(Arrays.asList(new PropertySource[]{testPropertySource, testPS2}));
         ConfigurationContext ctx = b.build();
         assertEquals(2, ctx.getPropertySources().size());

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilderTest.java
new file mode 100644
index 0000000..8458366
--- /dev/null
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextBuilderTest.java
@@ -0,0 +1,200 @@
+/*
+ * 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.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.*;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link CoreConfigurationContextBuilder} by atsticks on 06.09.16.
+ */
+public class CoreConfigurationContextBuilderTest {
+
+    private TestPropertySource testPropertySource = new TestPropertySource(){};
+
+    @Test
+    public void setContext() throws Exception {
+        ConfigurationContext context = ConfigurationProvider.getConfiguration().getContext();
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .setContext(context);
+        assertEquals(context, b.build());
+    }
+
+    @Test
+    public void addPropertySources_Array() throws Exception {
+        PropertySource testPS2 = new TestPropertySource("addPropertySources_Array_2");
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .addPropertySources(testPropertySource, testPS2);
+        ConfigurationContext ctx = b.build();
+        assertEquals(2, ctx.getPropertySources().size());
+        assertTrue(ctx.getPropertySources().contains(testPropertySource));
+        assertTrue(ctx.getPropertySources().contains(testPS2));
+    }
+
+    @Test
+    public void removePropertySources_Array() throws Exception {
+        PropertySource testPS2 = new TestPropertySource("addPropertySources_Array_2");
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .addPropertySources(testPropertySource, testPS2);
+        ConfigurationContext ctx = b.build();
+        assertEquals(2, ctx.getPropertySources().size());
+        assertTrue(ctx.getPropertySources().contains(testPropertySource));
+        assertTrue(ctx.getPropertySources().contains(testPS2));
+        b = new CoreConfigurationContextBuilder()
+                .addPropertySources(testPropertySource, testPS2);
+        b.removePropertySources(testPropertySource);
+        ctx = b.build();
+        assertEquals(1, ctx.getPropertySources().size());
+        assertFalse(ctx.getPropertySources().contains(testPropertySource));
+        assertTrue(ctx.getPropertySources().contains(testPS2));
+    }
+
+    @Test
+    public void addPropertyFilters_Array() throws Exception {
+        PropertyFilter filter1 = (value, context) -> value;
+        PropertyFilter filter2 = (value, context) -> value;
+        CoreConfigurationContextBuilder b = new CoreConfigurationContextBuilder();
+        b.addPropertyFilters(filter1, filter2);
+        ConfigurationContext ctx = b.build();
+        assertTrue(ctx.getPropertyFilters().contains(filter1));
+        assertTrue(ctx.getPropertyFilters().contains(filter2));
+        assertEquals(2, ctx.getPropertyFilters().size());
+        b = new CoreConfigurationContextBuilder();
+        b.addPropertyFilters(filter1, filter2);
+        b.addPropertyFilters(filter1, filter2);
+        assertEquals(2, ctx.getPropertyFilters().size());
+    }
+
+    @Test
+    public void removePropertyFilters_Array() throws Exception {
+        PropertyFilter filter1 = (value, context) -> value;
+        PropertyFilter filter2 = (value, context) -> value;
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .addPropertyFilters(filter1, filter2);
+        ConfigurationContext ctx = b.build();
+        assertTrue(ctx.getPropertyFilters().contains(filter1));
+        assertTrue(ctx.getPropertyFilters().contains(filter2));
+        assertEquals(2, ctx.getPropertyFilters().size());
+        b = new CoreConfigurationContextBuilder()
+                .addPropertyFilters(filter1, filter2);
+        b.removePropertyFilters(filter1);
+        ctx = b.build();
+        assertEquals(1, ctx.getPropertyFilters().size());
+        assertFalse(ctx.getPropertyFilters().contains(filter1));
+        assertTrue(ctx.getPropertyFilters().contains(filter2));
+    }
+
+    @Test
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    public void addPropertyConverter() throws Exception {
+		PropertyConverter converter = (value, context) -> value.toLowerCase();
+		ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .addPropertyConverters(TypeLiteral.of(String.class), converter);
+        ConfigurationContext ctx = b.build();
+        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter));
+        assertEquals(1, ctx.getPropertyConverters().size());
+        b = new CoreConfigurationContextBuilder()
+                .addPropertyConverters(TypeLiteral.of(String.class), converter);
+        b.addPropertyConverters(TypeLiteral.of(String.class), converter);
+        assertEquals(1, ctx.getPropertyConverters().size());
+    }
+
+    @Test
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    public void removePropertyConverters_Array() throws Exception {
+        PropertyConverter converter = (value, context) -> value.toLowerCase();
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .addPropertyConverters(TypeLiteral.of(String.class), converter);
+        ConfigurationContext ctx = b.build();
+        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter));
+        assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size());
+        b = new CoreConfigurationContextBuilder()
+                .addPropertyConverters(TypeLiteral.of(String.class), converter);
+        b.removePropertyConverters(TypeLiteral.of(String.class), converter);
+        ctx = b.build();
+        assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter));
+        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty());
+    }
+
+    @Test
+    public void setPropertyValueCombinationPolicy() throws Exception {
+        PropertyValueCombinationPolicy combPol = (currentValue, key, propertySource) -> currentValue;
+        ConfigurationContextBuilder b = new CoreConfigurationContextBuilder()
+                .setPropertyValueCombinationPolicy(combPol);
+        ConfigurationContext ctx = b.build();
+        assertEquals(ctx.getPropertyValueCombinationPolicy(), combPol);
+    }
+
+    @Test
+    public void build() throws Exception {
+        assertNotNull(new CoreConfigurationContextBuilder().build());
+    }
+
+    @Test
+    public void bla() throws Exception {
+        ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
+        builder.addDefaultPropertyConverters();
+    }
+
+    private static class TestPropertySource implements PropertySource{
+
+        private String id;
+
+        public TestPropertySource(){
+            this(null);
+        }
+
+        public TestPropertySource(String id){
+            this.id = id;
+        }
+
+        @Override
+        public int getOrdinal() {
+            return 200;
+        }
+
+        @Override
+        public String getName() {
+            return id!=null?id:"TestPropertySource";
+        }
+
+        @Override
+        public PropertyValue get(String key) {
+            return PropertyValue.of(key, key + "Value", getName());
+        }
+
+        @Override
+        public Map<String, PropertyValue> getProperties() {
+            return Collections.emptyMap();
+        }
+
+        @Override
+        public boolean isScannable() {
+            return false;
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextTest.java
new file mode 100644
index 0000000..1c10124
--- /dev/null
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationContextTest.java
@@ -0,0 +1,176 @@
+/*
+ * 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.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.core.testdata.TestPropertyDefaultSource;
+import org.apache.tamaya.spi.*;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Simple tests for {@link CoreConfigurationContext} by atsticks on 16.08.16.
+ */
+public class CoreConfigurationContextTest {
+
+    @Test
+    public void addPropertySources() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        TestPropertyDefaultSource def = new TestPropertyDefaultSource();
+        assertFalse(ctx.getPropertySources().contains(def));
+        ctx.addPropertySources(def);
+        assertTrue(ctx.getPropertySources().contains(def));
+    }
+
+    @Test
+    public void testToString() throws Exception {
+        String toString = ConfigurationProvider.getConfiguration().getContext().toString();
+    }
+
+    @Test
+    public void getPropertySources() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        assertNotNull(ctx.getPropertySources());
+        assertEquals(ctx.getPropertySources().size(), 0);
+        ctx = new CoreConfigurationContextBuilder().addDefaultPropertySources().build();
+        assertNotNull(ctx.getPropertySources());
+        assertEquals(7, ctx.getPropertySources().size());
+    }
+
+    @Test
+    public void getPropertySource() throws Exception {
+        TestPropertyDefaultSource ps = new TestPropertyDefaultSource();
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder()
+                .addPropertySources(ps).build();
+        assertNotNull(ctx.getPropertySources());
+        assertEquals(ctx.getPropertySources().size(), 1);
+        assertNotNull(((CoreConfigurationContext)ctx).getPropertySource(ps.getName()));
+        assertEquals(ps.getName(), ((CoreConfigurationContext)ctx).getPropertySource(ps.getName()).getName());
+        assertNull(((CoreConfigurationContext)ctx).getPropertySource("huhu"));
+
+    }
+
+    @Test
+    public void testHashCode() throws Exception {
+        TestPropertyDefaultSource ps = new TestPropertyDefaultSource();
+        ConfigurationContext ctx1 = new CoreConfigurationContextBuilder()
+                .addPropertySources(ps).build();
+        ConfigurationContext ctx2 = new CoreConfigurationContextBuilder()
+                .addPropertySources(ps).build();
+        assertEquals(ctx1.hashCode(), ctx2.hashCode());
+        ctx2 = new CoreConfigurationContextBuilder()
+                .build();
+        assertNotEquals(ctx1.hashCode(), ctx2.hashCode());
+
+    }
+
+    @Test
+    public void addPropertyConverter() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        PropertyConverter testConverter = new PropertyConverter() {
+            @Override
+            public Object convert(String value, ConversionContext context) {
+                return "";
+            }
+        };
+        assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
+        ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
+        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
+    }
+
+    @Test
+    public void getPropertyConverters() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        PropertyConverter testConverter = new PropertyConverter() {
+            @Override
+            public Object convert(String value, ConversionContext context) {
+                return "";
+            }
+        };
+        ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
+        assertNotNull(ctx.getPropertyConverters());
+        assertTrue(ctx.getPropertyConverters().containsKey(TypeLiteral.of(String.class)));
+        assertTrue(ctx.getPropertyConverters().get(TypeLiteral.of(String.class)).contains(testConverter));
+        testConverter = new PropertyConverter() {
+            @Override
+            public Object convert(String value, ConversionContext context) {
+                return Integer.valueOf(5);
+            }
+        };
+        ctx.addPropertyConverter(TypeLiteral.of(Integer.class), testConverter);
+        assertTrue(ctx.getPropertyConverters().containsKey(TypeLiteral.of(Integer.class)));
+        assertTrue(ctx.getPropertyConverters().get(TypeLiteral.of(Integer.class)).contains(testConverter));
+    }
+
+    @Test
+    public void getPropertyConverters1() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        PropertyConverter testConverter = new PropertyConverter() {
+            @Override
+            public Object convert(String value, ConversionContext context) {
+                return "";
+            }
+        };
+        assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(String.class)));
+        assertEquals(ctx.getPropertyConverters(TypeLiteral.of(String.class)).size(),0);
+        ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
+        assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(String.class)));
+        assertEquals(ctx.getPropertyConverters(TypeLiteral.of(String.class)).size(),1);
+        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
+
+    }
+
+    @Test
+    public void getPropertyFilters() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        PropertyFilter testFilter = new PropertyFilter() {
+
+            @Override
+            public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
+                return value;
+            }
+        };
+        assertNotNull(ctx.getPropertyFilters());
+        assertFalse(ctx.getPropertyFilters().contains(testFilter));
+        ctx = ctx.toBuilder().addPropertyFilters(testFilter).build();
+        assertTrue(ctx.getPropertyFilters().contains(testFilter));
+    }
+
+    @Test
+    public void getPropertyValueCombinationPolicy() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        assertNotNull(ctx.getPropertyValueCombinationPolicy());
+        assertEquals(ctx.getPropertyValueCombinationPolicy(),
+                PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY);
+    }
+
+    @Test
+    public void toBuilder() throws Exception {
+        assertNotNull(new CoreConfigurationContextBuilder().build().toBuilder());
+    }
+
+    @Test
+    public void testRoundTrip() throws Exception {
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
+        assertEquals(ctx.toBuilder().build(), ctx);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
deleted file mode 100644
index dc301ff..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
+++ /dev/null
@@ -1,200 +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.core.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.*;
-import org.junit.Test;
-
-import java.util.Collections;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link DefaultConfigurationContextBuilder} by atsticks on 06.09.16.
- */
-public class DefaultConfigurationContextBuilderTest {
-
-    private TestPropertySource testPropertySource = new TestPropertySource(){};
-
-    @Test
-    public void setContext() throws Exception {
-        ConfigurationContext context = ConfigurationProvider.getConfiguration().getContext();
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .setContext(context);
-        assertEquals(context, b.build());
-    }
-
-    @Test
-    public void addPropertySources_Array() throws Exception {
-        PropertySource testPS2 = new TestPropertySource("addPropertySources_Array_2");
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .addPropertySources(testPropertySource, testPS2);
-        ConfigurationContext ctx = b.build();
-        assertEquals(2, ctx.getPropertySources().size());
-        assertTrue(ctx.getPropertySources().contains(testPropertySource));
-        assertTrue(ctx.getPropertySources().contains(testPS2));
-    }
-
-    @Test
-    public void removePropertySources_Array() throws Exception {
-        PropertySource testPS2 = new TestPropertySource("addPropertySources_Array_2");
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .addPropertySources(testPropertySource, testPS2);
-        ConfigurationContext ctx = b.build();
-        assertEquals(2, ctx.getPropertySources().size());
-        assertTrue(ctx.getPropertySources().contains(testPropertySource));
-        assertTrue(ctx.getPropertySources().contains(testPS2));
-        b = new DefaultConfigurationContextBuilder()
-                .addPropertySources(testPropertySource, testPS2);
-        b.removePropertySources(testPropertySource);
-        ctx = b.build();
-        assertEquals(1, ctx.getPropertySources().size());
-        assertFalse(ctx.getPropertySources().contains(testPropertySource));
-        assertTrue(ctx.getPropertySources().contains(testPS2));
-    }
-
-    @Test
-    public void addPropertyFilters_Array() throws Exception {
-        PropertyFilter filter1 = (value, context) -> value;
-        PropertyFilter filter2 = (value, context) -> value;
-        DefaultConfigurationContextBuilder b = new DefaultConfigurationContextBuilder();
-        b.addPropertyFilters(filter1, filter2);
-        ConfigurationContext ctx = b.build();
-        assertTrue(ctx.getPropertyFilters().contains(filter1));
-        assertTrue(ctx.getPropertyFilters().contains(filter2));
-        assertEquals(2, ctx.getPropertyFilters().size());
-        b = new DefaultConfigurationContextBuilder();
-        b.addPropertyFilters(filter1, filter2);
-        b.addPropertyFilters(filter1, filter2);
-        assertEquals(2, ctx.getPropertyFilters().size());
-    }
-
-    @Test
-    public void removePropertyFilters_Array() throws Exception {
-        PropertyFilter filter1 = (value, context) -> value;
-        PropertyFilter filter2 = (value, context) -> value;
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .addPropertyFilters(filter1, filter2);
-        ConfigurationContext ctx = b.build();
-        assertTrue(ctx.getPropertyFilters().contains(filter1));
-        assertTrue(ctx.getPropertyFilters().contains(filter2));
-        assertEquals(2, ctx.getPropertyFilters().size());
-        b = new DefaultConfigurationContextBuilder()
-                .addPropertyFilters(filter1, filter2);
-        b.removePropertyFilters(filter1);
-        ctx = b.build();
-        assertEquals(1, ctx.getPropertyFilters().size());
-        assertFalse(ctx.getPropertyFilters().contains(filter1));
-        assertTrue(ctx.getPropertyFilters().contains(filter2));
-    }
-
-    @Test
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public void addPropertyConverter() throws Exception {
-		PropertyConverter converter = (value, context) -> value.toLowerCase();
-		ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .addPropertyConverters(TypeLiteral.of(String.class), converter);
-        ConfigurationContext ctx = b.build();
-        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter));
-        assertEquals(1, ctx.getPropertyConverters().size());
-        b = new DefaultConfigurationContextBuilder()
-                .addPropertyConverters(TypeLiteral.of(String.class), converter);
-        b.addPropertyConverters(TypeLiteral.of(String.class), converter);
-        assertEquals(1, ctx.getPropertyConverters().size());
-    }
-
-    @Test
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public void removePropertyConverters_Array() throws Exception {
-        PropertyConverter converter = (value, context) -> value.toLowerCase();
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .addPropertyConverters(TypeLiteral.of(String.class), converter);
-        ConfigurationContext ctx = b.build();
-        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter));
-        assertEquals(1, ctx.getPropertyConverters(TypeLiteral.of(String.class)).size());
-        b = new DefaultConfigurationContextBuilder()
-                .addPropertyConverters(TypeLiteral.of(String.class), converter);
-        b.removePropertyConverters(TypeLiteral.of(String.class), converter);
-        ctx = b.build();
-        assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter));
-        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).isEmpty());
-    }
-
-    @Test
-    public void setPropertyValueCombinationPolicy() throws Exception {
-        PropertyValueCombinationPolicy combPol = (currentValue, key, propertySource) -> currentValue;
-        ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
-                .setPropertyValueCombinationPolicy(combPol);
-        ConfigurationContext ctx = b.build();
-        assertEquals(ctx.getPropertyValueCombinationPolicy(), combPol);
-    }
-
-    @Test
-    public void build() throws Exception {
-        assertNotNull(new DefaultConfigurationContextBuilder().build());
-    }
-
-    @Test
-    public void bla() throws Exception {
-        ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
-        builder.addDefaultPropertyConverters();
-    }
-
-    private static class TestPropertySource implements PropertySource{
-
-        private String id;
-
-        public TestPropertySource(){
-            this(null);
-        }
-
-        public TestPropertySource(String id){
-            this.id = id;
-        }
-
-        @Override
-        public int getOrdinal() {
-            return 200;
-        }
-
-        @Override
-        public String getName() {
-            return id!=null?id:"TestPropertySource";
-        }
-
-        @Override
-        public PropertyValue get(String key) {
-            return PropertyValue.of(key, key + "Value", getName());
-        }
-
-        @Override
-        public Map<String, PropertyValue> getProperties() {
-            return Collections.emptyMap();
-        }
-
-        @Override
-        public boolean isScannable() {
-            return false;
-        }
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
deleted file mode 100644
index 38412f3..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
+++ /dev/null
@@ -1,176 +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.core.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.testdata.TestPropertyDefaultSource;
-import org.apache.tamaya.spi.*;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Simple tests for {@link DefaultConfigurationContext} by atsticks on 16.08.16.
- */
-public class DefaultConfigurationContextTest {
-
-    @Test
-    public void addPropertySources() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        TestPropertyDefaultSource def = new TestPropertyDefaultSource();
-        assertFalse(ctx.getPropertySources().contains(def));
-        ctx.addPropertySources(def);
-        assertTrue(ctx.getPropertySources().contains(def));
-    }
-
-    @Test
-    public void testToString() throws Exception {
-        String toString = ConfigurationProvider.getConfiguration().getContext().toString();
-    }
-
-    @Test
-    public void getPropertySources() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        assertNotNull(ctx.getPropertySources());
-        assertEquals(ctx.getPropertySources().size(), 0);
-        ctx = new DefaultConfigurationContextBuilder().addDefaultPropertySources().build();
-        assertNotNull(ctx.getPropertySources());
-        assertEquals(7, ctx.getPropertySources().size());
-    }
-
-    @Test
-    public void getPropertySource() throws Exception {
-        TestPropertyDefaultSource ps = new TestPropertyDefaultSource();
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder()
-                .addPropertySources(ps).build();
-        assertNotNull(ctx.getPropertySources());
-        assertEquals(ctx.getPropertySources().size(), 1);
-        assertNotNull(((DefaultConfigurationContext)ctx).getPropertySource(ps.getName()));
-        assertEquals(ps.getName(), ((DefaultConfigurationContext)ctx).getPropertySource(ps.getName()).getName());
-        assertNull(((DefaultConfigurationContext)ctx).getPropertySource("huhu"));
-
-    }
-
-    @Test
-    public void testHashCode() throws Exception {
-        TestPropertyDefaultSource ps = new TestPropertyDefaultSource();
-        ConfigurationContext ctx1 = new DefaultConfigurationContextBuilder()
-                .addPropertySources(ps).build();
-        ConfigurationContext ctx2 = new DefaultConfigurationContextBuilder()
-                .addPropertySources(ps).build();
-        assertEquals(ctx1.hashCode(), ctx2.hashCode());
-        ctx2 = new DefaultConfigurationContextBuilder()
-                .build();
-        assertNotEquals(ctx1.hashCode(), ctx2.hashCode());
-
-    }
-
-    @Test
-    public void addPropertyConverter() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        PropertyConverter testConverter = new PropertyConverter() {
-            @Override
-            public Object convert(String value, ConversionContext context) {
-                return "";
-            }
-        };
-        assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
-        ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
-        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
-    }
-
-    @Test
-    public void getPropertyConverters() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        PropertyConverter testConverter = new PropertyConverter() {
-            @Override
-            public Object convert(String value, ConversionContext context) {
-                return "";
-            }
-        };
-        ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
-        assertNotNull(ctx.getPropertyConverters());
-        assertTrue(ctx.getPropertyConverters().containsKey(TypeLiteral.of(String.class)));
-        assertTrue(ctx.getPropertyConverters().get(TypeLiteral.of(String.class)).contains(testConverter));
-        testConverter = new PropertyConverter() {
-            @Override
-            public Object convert(String value, ConversionContext context) {
-                return Integer.valueOf(5);
-            }
-        };
-        ctx.addPropertyConverter(TypeLiteral.of(Integer.class), testConverter);
-        assertTrue(ctx.getPropertyConverters().containsKey(TypeLiteral.of(Integer.class)));
-        assertTrue(ctx.getPropertyConverters().get(TypeLiteral.of(Integer.class)).contains(testConverter));
-    }
-
-    @Test
-    public void getPropertyConverters1() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        PropertyConverter testConverter = new PropertyConverter() {
-            @Override
-            public Object convert(String value, ConversionContext context) {
-                return "";
-            }
-        };
-        assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(String.class)));
-        assertEquals(ctx.getPropertyConverters(TypeLiteral.of(String.class)).size(),0);
-        ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
-        assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(String.class)));
-        assertEquals(ctx.getPropertyConverters(TypeLiteral.of(String.class)).size(),1);
-        assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
-
-    }
-
-    @Test
-    public void getPropertyFilters() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        PropertyFilter testFilter = new PropertyFilter() {
-
-            @Override
-            public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
-                return value;
-            }
-        };
-        assertNotNull(ctx.getPropertyFilters());
-        assertFalse(ctx.getPropertyFilters().contains(testFilter));
-        ctx = ctx.toBuilder().addPropertyFilters(testFilter).build();
-        assertTrue(ctx.getPropertyFilters().contains(testFilter));
-    }
-
-    @Test
-    public void getPropertyValueCombinationPolicy() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        assertNotNull(ctx.getPropertyValueCombinationPolicy());
-        assertEquals(ctx.getPropertyValueCombinationPolicy(),
-                PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY);
-    }
-
-    @Test
-    public void toBuilder() throws Exception {
-        assertNotNull(new DefaultConfigurationContextBuilder().build().toBuilder());
-    }
-
-    @Test
-    public void testRoundTrip() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
-        assertEquals(ctx.toBuilder().build(), ctx);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationProviderTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationProviderTest.java
index ce5d046..9ba3c80 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationProviderTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationProviderTest.java
@@ -40,7 +40,7 @@ public class DefaultConfigurationProviderTest {
 
     @Test
     public void createConfiguration() throws Exception {
-        ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+        ConfigurationContext ctx = new CoreConfigurationContextBuilder().build();
         assertNotNull(new DefaultConfigurationProvider().createConfiguration(ctx));
         assertEquals(ctx,
                 new DefaultConfigurationProvider().createConfiguration(ctx).getContext());

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/spi-support/pom.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/pom.xml b/code/spi-support/pom.xml
index e602199..1221fd3 100644
--- a/code/spi-support/pom.xml
+++ b/code/spi-support/pom.xml
@@ -28,7 +28,7 @@ under the License.
     </parent>
 
     <artifactId>tamaya-spisupport</artifactId>
-    <name>Apache Tamaya Common Support Classes</name>
+    <name>Apache Tamaya Core SPI Support</name>
     <description>Apache Tamaya Support Classes useful when implementing the Tamaya SPI or code independent of the core RI
         implementation.</description>
     <packaging>jar</packaging>


[10/12] incubator-tamaya git commit: TAMAYA-318 Fixed issue registering default converters with invalid target type.

Posted by an...@apache.org.
TAMAYA-318 Fixed issue registering default converters with invalid target type.


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

Branch: refs/heads/master
Commit: aa6dbe62dfad0490506e5c9eacb87e962939ff14
Parents: 878b236
Author: Anatole Tresch <an...@apache.org>
Authored: Tue Nov 14 08:47:57 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Tue Nov 14 08:47:57 2017 +0100

----------------------------------------------------------------------
 .../DefaultConfigurationContextBuilder.java     | 21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/aa6dbe62/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
index 4cad87d..8268f64 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
@@ -35,6 +35,8 @@ import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySour
 import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
 
 import java.io.File;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.URI;
@@ -397,13 +399,20 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         Map<TypeLiteral, Collection<PropertyConverter>> result = new HashMap<>();
         for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(
                 PropertyConverter.class)) {
-            TypeLiteral target = TypeLiteral.of(TypeLiteral.of(conv.getClass()).getType());
-            Collection<PropertyConverter> convList = result.get(target);
-            if (convList == null) {
-                convList = new ArrayList<>();
-                result.put(target, convList);
+            for(Type type:conv.getClass().getGenericInterfaces()){
+                if(type instanceof ParameterizedType){
+                    ParameterizedType pt = (ParameterizedType)type;
+                    if(PropertyConverter.class.equals(((ParameterizedType) type).getRawType())){
+                        TypeLiteral target = TypeLiteral.of(pt.getActualTypeArguments()[0]);
+                        Collection<PropertyConverter> convList = result.get(target);
+                        if (convList == null) {
+                            convList = new ArrayList<>();
+                            result.put(target, convList);
+                        }
+                        convList.add(conv);
+                    }
+                }
             }
-            convList.add(conv);
         }
         return result;
     }


[09/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.


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

Branch: refs/heads/master
Commit: 878b2363cfc3477f27503de6459e44feea4b3d86
Parents: 62c38d6
Author: Anatole Tresch <an...@apache.org>
Authored: Mon Nov 13 16:56:28 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Mon Nov 13 16:56:28 2017 +0100

----------------------------------------------------------------------
 code/core/bnd.bnd        |  6 +++---
 code/spi-support/bnd.bnd | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/878b2363/code/core/bnd.bnd
----------------------------------------------------------------------
diff --git a/code/core/bnd.bnd b/code/core/bnd.bnd
index 5419c17..b611eb1 100644
--- a/code/core/bnd.bnd
+++ b/code/core/bnd.bnd
@@ -21,12 +21,12 @@ Bundle-ContactAddress: dev-tamaya@incubator.apache.org
 Bundle-DocURL: http://tamaya.apache.org
 Bundle-Activator: org.apache.tamaya.core.OSGIActivator
 Export-Package: \
-	org.apache.tamaya.core,\
-	org.apache.tamaya.core.propertysource,\
-	org.apache.tamaya.core.provider
+	org.apache.tamaya.core
 Import-Package: \
 	org.apache.tamaya,\
 	org.apache.tamaya.spi,\
+	org.apache.tamaya.spisupport,\
+	org.apache.tamaya.spisupport.propertysource,\
 	org.osgi.framework,\
 	javax.annotation
 Private-Package: \

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/878b2363/code/spi-support/bnd.bnd
----------------------------------------------------------------------
diff --git a/code/spi-support/bnd.bnd b/code/spi-support/bnd.bnd
new file mode 100644
index 0000000..876ca2e
--- /dev/null
+++ b/code/spi-support/bnd.bnd
@@ -0,0 +1,26 @@
+-buildpath: \
+	osgi.annotation; version=6.0.0,\
+	osgi.core; version=6.0,\
+	osgi.cmpn; version=6.0
+
+-testpath: \
+	${junit}
+
+javac.source: 1.8
+javac.target: 1.8
+
+Bundle-Version: ${version}.${tstamp}
+Bundle-Name: Apache Tamaya - SPI Support
+Bundle-SymbolicName: org.apache.tamaya.spisupport
+Bundle-Description: Apacha Tamaya Config - SPI Support
+Bundle-Category: Implementation
+Bundle-Copyright: (C) Apache Foundation
+Bundle-License: Apache Licence version 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-ContactAddress: dev-tamaya@incubator.apache.org
+Bundle-DocURL: http://tamaya.apache.org
+Export-Package: \
+	org.apache.tamaya.spisupport,org.apache.tamaya.spisupport.propertysource
+Import-Package: \
+    org.apache.tamaya,\
+    org.apache.tamaya.spi


[11/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
new file mode 100644
index 0000000..d880e8d
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
@@ -0,0 +1,277 @@
+/*
+ * 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.TypeLiteral;
+import org.apache.tamaya.spi.*;
+
+import java.util.*;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.logging.Logger;
+
+/**
+ * Default implementation of a simple ConfigurationContext.
+ */
+public class DefaultConfigurationContext implements ConfigurationContext {
+
+    /** The logger used. */
+    private final static Logger LOG = Logger.getLogger(DefaultConfigurationContext.class.getName());
+
+    /**
+     * Subcomponent handling {@link PropertyConverter} instances.
+     */
+    private final PropertyConverterManager propertyConverterManager = new PropertyConverterManager();
+
+    /**
+     * The current unmodifiable list of loaded {@link PropertySource} instances.
+     */
+    private List<PropertySource> immutablePropertySources;
+
+    /**
+     * The current unmodifiable list of loaded {@link PropertyFilter} instances.
+     */
+    private List<PropertyFilter> immutablePropertyFilters;
+
+    /**
+     * The overriding policy used when combining PropertySources registered to evalute the final configuration
+     * values.
+     */
+    private PropertyValueCombinationPolicy propertyValueCombinationPolicy;
+
+    /**
+     * Lock for internal synchronization.
+     */
+    private final ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
+
+    @SuppressWarnings("unchecked")
+	protected DefaultConfigurationContext(DefaultConfigurationContextBuilder builder) {
+        List<PropertySource> propertySources = new ArrayList<>();
+        // first we load all PropertySources which got registered via java.util.ServiceLoader
+        propertySources.addAll(builder.propertySources);
+        // now sort them according to their ordinal values
+        immutablePropertySources = Collections.unmodifiableList(propertySources);
+
+        // as next step we pick up the PropertyFilters pretty much the same way
+        List<PropertyFilter> propertyFilters = new ArrayList<>(builder.getPropertyFilters());
+        immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
+
+        // Finally add the converters
+        for(Map.Entry<TypeLiteral<?>, Collection<PropertyConverter<?>>> en:builder.getPropertyConverter().entrySet()) {
+            for (@SuppressWarnings("rawtypes") PropertyConverter converter : en.getValue()) {
+                this.propertyConverterManager.register(en.getKey(), converter);
+            }
+        }
+        LOG.info("Registered " + propertyConverterManager.getPropertyConverters().size() + " property converters: " +
+                propertyConverterManager.getPropertyConverters());
+
+        propertyValueCombinationPolicy = builder.combinationPolicy;
+        if(propertyValueCombinationPolicy==null){
+            propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
+        }
+        if(propertyValueCombinationPolicy==null){
+            propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+        }
+        LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
+    }
+
+
+    @Deprecated
+    @Override
+    public void addPropertySources(PropertySource... propertySourcesToAdd) {
+        Lock writeLock = propertySourceLock.writeLock();
+        try {
+            writeLock.lock();
+            List<PropertySource> newPropertySources = new ArrayList<>(this.immutablePropertySources);
+            newPropertySources.addAll(Arrays.asList(propertySourcesToAdd));
+            Collections.sort(newPropertySources, PropertySourceComparator.getInstance());
+
+            this.immutablePropertySources = Collections.unmodifiableList(newPropertySources);
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof DefaultConfigurationContext)){
+            return false;
+        }
+
+        DefaultConfigurationContext that = (DefaultConfigurationContext) o;
+
+        if (!propertyConverterManager.equals(that.propertyConverterManager)) {
+            return false;
+        }
+        if (!immutablePropertySources.equals(that.immutablePropertySources)) {
+            return false;
+        }
+        if (!immutablePropertyFilters.equals(that.immutablePropertyFilters)) {
+            return false;
+        }
+        return getPropertyValueCombinationPolicy().equals(that.getPropertyValueCombinationPolicy());
+
+    }
+
+    @Override
+    public int hashCode() {
+        int result = propertyConverterManager.hashCode();
+        result = 31 * result + immutablePropertySources.hashCode();
+        result = 31 * result + immutablePropertyFilters.hashCode();
+        result = 31 * result + getPropertyValueCombinationPolicy().hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("ConfigurationContext{\n");
+        b.append("  Property Sources\n");
+        b.append("  ----------------\n");
+        if(immutablePropertySources.isEmpty()){
+            b.append("  No property sources loaded.\n\n");
+        }else {
+            b.append("  CLASS                         NAME                                                                  ORDINAL SCANNABLE SIZE    STATE     ERROR\n\n");
+            for (PropertySource ps : immutablePropertySources) {
+                b.append("  ");
+                appendFormatted(b, ps.getClass().getSimpleName(), 30);
+                appendFormatted(b, ps.getName(), 70);
+                appendFormatted(b, String.valueOf(PropertySourceComparator.getOrdinal(ps)), 8);
+                appendFormatted(b, String.valueOf(ps.isScannable()), 10);
+                if (ps.isScannable()) {
+                    appendFormatted(b, String.valueOf(ps.getProperties().size()), 8);
+                } else {
+                    appendFormatted(b, "-", 8);
+                }
+                PropertyValue state = ps.get("_state");
+                if(state==null){
+                    appendFormatted(b, "OK", 10);
+                }else {
+                    appendFormatted(b, state.getValue(), 10);
+                    if("ERROR".equals(state.getValue())){
+                        PropertyValue val = ps.get("_exception");
+                        if(val!=null) {
+                            appendFormatted(b, val.getValue(), 30);
+                        }
+                    }
+                }
+                b.append('\n');
+            }
+            b.append("\n");
+        }
+        b.append("  Property Filters\n");
+        b.append("  ----------------\n");
+        if(immutablePropertyFilters.isEmpty()){
+            b.append("  No property filters loaded.\n\n");
+        }else {
+            b.append("  CLASS                         INFO\n\n");
+            for (PropertyFilter filter : getPropertyFilters()) {
+                b.append("  ");
+                appendFormatted(b, filter.getClass().getSimpleName(), 30);
+                b.append(removeNewLines(filter.toString()));
+                b.append('\n');
+            }
+            b.append("\n\n");
+        }
+        b.append("  Property Converters\n");
+        b.append("  -------------------\n");
+        b.append("  CLASS                         TYPE                          INFO\n\n");
+        for(Map.Entry<TypeLiteral<?>, List<PropertyConverter<?>>> converterEntry:getPropertyConverters().entrySet()){
+            for(PropertyConverter converter: converterEntry.getValue()){
+                b.append("  ");
+                appendFormatted(b, converter.getClass().getSimpleName(), 30);
+                appendFormatted(b, converterEntry.getKey().getRawType().getSimpleName(), 30);
+                b.append(removeNewLines(converter.toString()));
+                b.append('\n');
+            }
+        }
+        b.append("\n\n");
+        b.append("  PropertyValueCombinationPolicy: " + getPropertyValueCombinationPolicy().getClass().getName()).append('\n');
+        b.append('}');
+        return b.toString();
+    }
+
+    private void appendFormatted(StringBuilder b, String text, int length) {
+        int padding;
+        if(text.length() <= (length)){
+            b.append(text);
+            padding = length - text.length();
+        }else{
+            b.append(text.substring(0, length-1));
+            padding = 1;
+        }
+        for(int i=0;i<padding;i++){
+            b.append(' ');
+        }
+    }
+
+    private String removeNewLines(String s) {
+        return s.replace('\n', ' ').replace('\r', ' ');
+    }
+
+
+    @Override
+    public List<PropertySource> getPropertySources() {
+        return immutablePropertySources;
+    }
+
+    @Override
+    public PropertySource getPropertySource(String name) {
+        for(PropertySource ps:getPropertySources()){
+            if(name.equals(ps.getName())){
+                return ps;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
+        propertyConverterManager.register(typeToConvert, propertyConverter);
+        LOG.info("Added PropertyConverter: " + propertyConverter.getClass().getName());
+    }
+
+    @Override
+    public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
+        return propertyConverterManager.getPropertyConverters();
+    }
+
+    @Override
+    public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
+        return propertyConverterManager.getPropertyConverters(targetType);
+    }
+
+    @Override
+    public List<PropertyFilter> getPropertyFilters() {
+        return immutablePropertyFilters;
+    }
+
+    @Override
+    public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy(){
+        return propertyValueCombinationPolicy;
+    }
+
+    @Override
+    public ConfigurationContextBuilder toBuilder() {
+        return new DefaultConfigurationContextBuilder(this);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java
new file mode 100644
index 0000000..079527f
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java
@@ -0,0 +1,437 @@
+/*
+ * 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.TypeLiteral;
+import org.apache.tamaya.spi.*;
+import org.apache.tamaya.spisupport.propertysource.CLIPropertySource;
+import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource;
+import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
+
+import java.io.File;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.*;
+import java.util.logging.Logger;
+
+/**
+ * Default implementation of {@link ConfigurationContextBuilder}.
+ */
+public class DefaultConfigurationContextBuilder implements ConfigurationContextBuilder {
+
+    private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextBuilder.class.getName());
+
+    protected List<PropertyFilter> propertyFilters = new ArrayList<>();
+    protected List<PropertySource> propertySources = new ArrayList<>();
+    protected PropertyValueCombinationPolicy combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
+    protected Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> propertyConverters = new HashMap<>();
+
+    /**
+     * Flag if the config has already been built.
+     * Configuration can be built only once
+     */
+    private boolean built;
+
+
+
+    /**
+     * Creates a new builder instance.
+     */
+    public DefaultConfigurationContextBuilder() {
+    }
+
+    /**
+     * Creates a new builder instance initializing it with the given context.
+     * @param context the context to be used, not null.
+     */
+    public DefaultConfigurationContextBuilder(ConfigurationContext context) {
+        this.propertyConverters.putAll(context.getPropertyConverters());
+        this.propertyFilters.addAll(context.getPropertyFilters());
+        for(PropertySource ps:context.getPropertySources()) {
+            addPropertySources(ps);
+        }
+        this.combinationPolicy = context.getPropertyValueCombinationPolicy();
+    }
+
+    /**
+     * Allows to reset configuration context during unit tests.
+     */
+    public final ConfigurationContextBuilder resetWithConfigurationContext(ConfigurationContext configurationContext) {
+        checkBuilderState();
+        //noinspection deprecation
+        this.propertyFilters.clear();
+        this.propertyFilters.addAll(configurationContext.getPropertyFilters());
+        this.propertySources.clear();
+        for(PropertySource ps:configurationContext.getPropertySources()) {
+            addPropertySources(ps);
+        }
+        this.propertyConverters.clear();
+        this.propertyConverters.putAll(configurationContext.getPropertyConverters());
+        this.combinationPolicy = configurationContext.getPropertyValueCombinationPolicy();
+        return this;
+    }
+
+
+    @Override
+    public ConfigurationContextBuilder setContext(ConfigurationContext context) {
+        checkBuilderState();
+        this.propertyConverters.putAll(context.getPropertyConverters());
+        for(PropertySource ps:context.getPropertySources()){
+            this.propertySources.add(ps);
+        }
+        this.propertyFilters.addAll(context.getPropertyFilters());
+        this.combinationPolicy = context.getPropertyValueCombinationPolicy();
+        return this;
+    }
+
+    @Override
+    public final ConfigurationContextBuilder addPropertySources(PropertySource... sources){
+        return addPropertySources(Arrays.asList(sources));
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertySources(Collection<PropertySource> sources){
+        checkBuilderState();
+        for(PropertySource source:sources) {
+            if (!this.propertySources.contains(source)) {
+                this.propertySources.add(source);
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addDefaultPropertySources() {
+        checkBuilderState();
+        List<PropertySource> propertySources = new ArrayList<>();
+        addCorePropertyResources(propertySources);
+        for(PropertySource ps: ServiceContextManager.getServiceContext().getServices(PropertySource.class)) {
+            if(!propertySources.contains(ps)){
+                propertySources.add(ps);
+            }
+        }
+        for(PropertySourceProvider provider:
+                ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class)){
+                propertySources.addAll(provider.getPropertySources());
+        }
+        Collections.sort(propertySources, PropertySourceComparator.getInstance());
+        return addPropertySources(propertySources);
+    }
+
+    protected void addCorePropertyResources(List<PropertySource> propertySources) {
+        for(PropertySource ps: new PropertySource[]{
+                new EnvironmentPropertySource(),
+                new JavaConfigurationPropertySource(),
+                new CLIPropertySource(),
+                new SystemPropertySource()
+        }){
+            if(!propertySources.contains(ps)){
+                propertySources.add(ps);
+            }
+        }
+    }
+
+    @Override
+    public ConfigurationContextBuilder addDefaultPropertyFilters() {
+        checkBuilderState();
+        for(PropertyFilter pf:ServiceContextManager.getServiceContext().getServices(PropertyFilter.class)){
+            addPropertyFilters(pf);
+        }
+        return this;
+    }
+
+    @Override
+    public DefaultConfigurationContextBuilder addDefaultPropertyConverters() {
+        checkBuilderState();
+        addCorePropertyConverters();
+        for(Map.Entry<TypeLiteral, Collection<PropertyConverter>> en:getDefaultPropertyConverters().entrySet()){
+            for(PropertyConverter pc: en.getValue()) {
+                addPropertyConverters(en.getKey(), pc);
+            }
+        }
+        return this;
+    }
+
+    @SuppressWarnings("unchecked")
+	protected void addCorePropertyConverters() {
+        // should be overridden by subclasses.
+    }
+
+    @Override
+    public final ConfigurationContextBuilder removePropertySources(PropertySource... propertySources) {
+        return removePropertySources(Arrays.asList(propertySources));
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertySources(Collection<PropertySource> propertySources) {
+        checkBuilderState();
+        this.propertySources.removeAll(propertySources);
+        return this;
+    }
+
+    protected PropertySource getPropertySource(String name) {
+        for(PropertySource ps:propertySources){
+            if(ps.getName().equals(name)){
+                return ps;
+            }
+        }
+        throw new IllegalArgumentException("No such PropertySource: "+name);
+    }
+
+    @Override
+    public List<PropertySource> getPropertySources() {
+        return Collections.unmodifiableList(this.propertySources);
+    }
+
+    @Override
+    public ConfigurationContextBuilder increasePriority(PropertySource propertySource) {
+        checkBuilderState();
+        int index = propertySources.indexOf(propertySource);
+        if(index<0){
+            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
+        }
+        if(index<(propertySources.size()-1)){
+            propertySources.remove(propertySource);
+            propertySources.add(index+1, propertySource);
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder decreasePriority(PropertySource propertySource) {
+        checkBuilderState();
+        int index = propertySources.indexOf(propertySource);
+        if(index<0){
+            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
+        }
+        if(index>0){
+            propertySources.remove(propertySource);
+            propertySources.add(index-1, propertySource);
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder highestPriority(PropertySource propertySource) {
+        checkBuilderState();
+        int index = propertySources.indexOf(propertySource);
+        if(index<0){
+            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
+        }
+        if(index<(propertySources.size()-1)){
+            propertySources.remove(propertySource);
+            propertySources.add(propertySource);
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder lowestPriority(PropertySource propertySource) {
+        checkBuilderState();
+        int index = propertySources.indexOf(propertySource);
+        if(index<0){
+            throw new IllegalArgumentException("No such PropertySource: " + propertySource);
+        }
+        if(index>0){
+            propertySources.remove(propertySource);
+            propertySources.add(0, propertySource);
+        }
+        return this;
+    }
+
+    @Override
+    public final ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters){
+        return addPropertyFilters(Arrays.asList(filters));
+    }
+
+    @Override
+    public final ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters){
+        checkBuilderState();
+        for(PropertyFilter f:filters) {
+            if (!this.propertyFilters.contains(f)) {
+                this.propertyFilters.add(f);
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public final ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters) {
+        return removePropertyFilters(Arrays.asList(filters));
+    }
+
+    @Override
+    public final ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters) {
+        checkBuilderState();
+        this.propertyFilters.removeAll(filters);
+        return this;
+    }
+
+
+    @Override
+    public final <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                    @SuppressWarnings("unchecked") PropertyConverter<T>... converters) {
+        return removePropertyConverters(typeToConvert, Arrays.asList(converters));
+    }
+
+    @Override
+    public final <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                    Collection<PropertyConverter<T>> converters) {
+        Collection<PropertyConverter<?>> subConverters = this.propertyConverters.get(typeToConvert);
+        if(subConverters!=null) {
+            subConverters.removeAll(converters);
+        }
+        return this;
+    }
+
+    @Override
+    public final ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert) {
+        this.propertyConverters.remove(typeToConvert);
+        return this;
+    }
+
+
+    @Override
+    public final ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy combinationPolicy){
+        checkBuilderState();
+        this.combinationPolicy = Objects.requireNonNull(combinationPolicy);
+        return this;
+    }
+
+
+    @Override
+    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> type, PropertyConverter<T>... propertyConverters){
+        checkBuilderState();
+        Objects.requireNonNull(type);
+        Objects.requireNonNull(propertyConverters);
+        Collection<PropertyConverter<?>> converters = this.propertyConverters.get(type);
+        if(converters==null){
+            converters = new ArrayList<>();
+            this.propertyConverters.put(type, converters);
+        }
+        for(PropertyConverter<T> propertyConverter:propertyConverters) {
+            if (!converters.contains(propertyConverter)) {
+                converters.add(propertyConverter);
+            } else {
+                LOG.warning("Converter ignored, already registered: " + propertyConverter);
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> type, Collection<PropertyConverter<T>> propertyConverters){
+        checkBuilderState();
+        Objects.requireNonNull(type);
+        Objects.requireNonNull(propertyConverters);
+        Collection<PropertyConverter<?>> converters = this.propertyConverters.get(type);
+        if(converters==null){
+            converters = new ArrayList<>();
+            this.propertyConverters.put(type, converters);
+        }
+        for(PropertyConverter<T> propertyConverter:propertyConverters) {
+            if (!converters.contains(propertyConverter)) {
+                converters.add(propertyConverter);
+            } else {
+                LOG.warning("Converter ignored, already registered: " + propertyConverter);
+            }
+        }
+        return this;
+    }
+
+    protected ConfigurationContextBuilder loadDefaults() {
+        checkBuilderState();
+        this.combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+        addDefaultPropertySources();
+        addDefaultPropertyFilters();
+        addDefaultPropertyConverters();
+        return this;
+    }
+
+
+    protected Map<TypeLiteral, Collection<PropertyConverter>> getDefaultPropertyConverters() {
+        Map<TypeLiteral, Collection<PropertyConverter>> result = new HashMap<>();
+        for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(
+                PropertyConverter.class)) {
+            for(Type type:conv.getClass().getGenericInterfaces()){
+                if(type instanceof ParameterizedType){
+                    ParameterizedType pt = (ParameterizedType)type;
+                    if(PropertyConverter.class.equals(((ParameterizedType) type).getRawType())){
+                        TypeLiteral target = TypeLiteral.of(pt.getActualTypeArguments()[0]);
+                        Collection<PropertyConverter> convList = result.get(target);
+                        if (convList == null) {
+                            convList = new ArrayList<>();
+                            result.put(target, convList);
+                        }
+                        convList.add(conv);
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * Builds a new configuration based on the configuration of this builder instance.
+     *
+     * @return a new {@link org.apache.tamaya.Configuration configuration instance},
+     *         never {@code null}.
+     */
+    @Override
+    public ConfigurationContext build() {
+        checkBuilderState();
+        built = true;
+        return new DefaultConfigurationContext(this);
+    }
+
+    @Override
+    public ConfigurationContextBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator) {
+        Collections.sort(propertyFilters, comparator);
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder sortPropertySources(Comparator<PropertySource> comparator) {
+        Collections.sort(propertySources, comparator);
+        return this;
+    }
+
+    private void checkBuilderState() {
+        if (built) {
+            throw new IllegalStateException("Configuration has already been build.");
+        }
+    }
+
+    @Override
+    public List<PropertyFilter> getPropertyFilters() {
+        return propertyFilters;
+    }
+
+    @Override
+    public Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter() {
+        return Collections.unmodifiableMap(this.propertyConverters);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/545e1779/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
----------------------------------------------------------------------
diff --git a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
index c993eeb..632f886 100644
--- a/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
+++ b/examples/01-minimal/src/main/java/org/apache/tamaya/examples/minimal/TestConfigProvider.java
@@ -19,13 +19,16 @@
 package org.apache.tamaya.examples.minimal;
 
 import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spisupport.DefaultConfigurationProvider;
+import org.apache.tamaya.core.internal.CoreConfigurationContextBuilder;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spi.ConfigurationProviderSpi;
 
 /**
  * Configuration provider that allows to set and reset a configuration
  * different per thread.
  */
-public class TestConfigProvider extends DefaultConfigurationProvider{
+public class TestConfigProvider implements ConfigurationProviderSpi{
 
     private ThreadLocal<Configuration> threadedConfig = new ThreadLocal<>();
 
@@ -35,7 +38,23 @@ public class TestConfigProvider extends DefaultConfigurationProvider{
         if(config!=null){
             return config;
         }
-        return super.getConfiguration();
+        config = createConfiguration(new CoreConfigurationContextBuilder()
+                .addDefaultPropertyFilters()
+                .addDefaultPropertySources()
+                .addDefaultPropertyConverters()
+                .build());
+        threadedConfig.set(config);
+        return config;
+    }
+
+    @Override
+    public Configuration createConfiguration(ConfigurationContext context) {
+        return null;
+    }
+
+    @Override
+    public ConfigurationContextBuilder getConfigurationContextBuilder() {
+        return null;
     }
 
     @Override
@@ -46,4 +65,9 @@ public class TestConfigProvider extends DefaultConfigurationProvider{
             threadedConfig.set(config);
         }
     }
+
+    @Override
+    public boolean isConfigurationSettable() {
+        return false;
+    }
 }


[06/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java
new file mode 100644
index 0000000..6fb31c6
--- /dev/null
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java
@@ -0,0 +1,68 @@
+/*
+ * 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.internal.converters;
+
+import org.apache.tamaya.ConfigQuery;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Query to convert a String value.
+ * @param <T> the target type.
+ */
+final class ConvertQuery<T> implements ConfigQuery<T> {
+
+    private static final Logger LOG = Logger.getLogger(ConvertQuery.class.getName());
+
+    private String rawValue;
+    private TypeLiteral<T> type;
+
+    public ConvertQuery(String rawValue, TypeLiteral<T> type) {
+        this.rawValue = Objects.requireNonNull(rawValue);
+        this.type = Objects.requireNonNull(type);
+    }
+
+    @Override
+    public T query(Configuration config) {
+        List<PropertyConverter<T>> converters = config.getContext().getPropertyConverters(type);
+        ConversionContext context = new ConversionContext.Builder(type).setConfigurationContext(config.getContext())
+                .setConfiguration(config).setKey(ConvertQuery.class.getName()).build();
+        for(PropertyConverter<?> conv: converters) {
+            try{
+                if(conv instanceof OptionalConverter){
+                    continue;
+                }
+                T result = (T)conv.convert(rawValue, context);
+                if(result!=null){
+                    return result;
+                }
+            }catch(Exception e){
+                LOG.log(Level.FINEST,  e, () -> "Converter "+ conv +" failed to convert to " + type);
+            }
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
deleted file mode 100644
index f66e638..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
+++ /dev/null
@@ -1,83 +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.core.internal.converters;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.osgi.service.component.annotations.Component;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Converter, converting from String to tge given enum type.
- */
-@Component(service = PropertyConverter.class)
-public class EnumConverter<T> implements PropertyConverter<T> {
-    private final Logger LOG = Logger.getLogger(EnumConverter.class.getName());
-    private Class<T> enumType;
-    private Method factory;
-
-    public EnumConverter(Class<T> enumType) {
-        if (!Enum.class.isAssignableFrom(enumType)) {
-            throw new IllegalArgumentException("Not an Enum: " + enumType.getName());
-        }
-        this.enumType = Objects.requireNonNull(enumType);
-        try {
-            this.factory = enumType.getMethod("valueOf", String.class);
-        } catch (NoSuchMethodException e) {
-            throw new ConfigException("Uncovertible enum type without valueOf method found, please provide a custom " +
-                    "PropertyConverter for: " + enumType.getName());
-        }
-    }
-
-    @Override
-    public T convert(String value, ConversionContext context) {
-        context.addSupportedFormats(getClass(),"<enumValue>");
-        try {
-            return (T) factory.invoke(null, value);
-        } catch (InvocationTargetException | IllegalAccessException e) {
-            LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
-        }
-        try {
-            return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH));
-        } catch (InvocationTargetException | IllegalAccessException e) {
-            LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
-        }
-        return null;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof EnumConverter)) return false;
-        EnumConverter<?> that = (EnumConverter<?>) o;
-        return Objects.equals(enumType, that.enumType);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(enumType);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
index 0901c9f..e9891be 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
@@ -23,7 +23,6 @@ import org.apache.tamaya.spi.PropertyConverter;
 import org.osgi.service.component.annotations.Component;
 
 import java.io.File;
-import java.net.URL;
 import java.util.Objects;
 import java.util.logging.Level;
 import java.util.logging.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
index 9486640..062d584 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
@@ -22,7 +22,6 @@ import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.osgi.service.component.annotations.Component;
 
-import java.time.LocalDate;
 import java.time.OffsetDateTime;
 import java.util.logging.Level;
 import java.util.logging.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
index ce8ebed..794ad8a 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
@@ -22,7 +22,6 @@ import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.osgi.service.component.annotations.Component;
 
-import java.time.OffsetDateTime;
 import java.time.OffsetTime;
 import java.util.logging.Level;
 import java.util.logging.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java
index 8be1533..dc53c84 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java
@@ -19,22 +19,14 @@
 package org.apache.tamaya.core.internal.converters;
 
 import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.internal.PropertyConverterManager;
 import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.osgi.service.component.annotations.Component;
 
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 /**
  * Converter, converting from String to Boolean.
@@ -42,8 +34,6 @@ import java.util.logging.Logger;
 @Component(service = PropertyConverter.class)
 public class OptionalConverter implements PropertyConverter<Optional> {
 
-    private static final Logger LOG = Logger.getLogger(OptionalConverter.class.getName());
-
     @Override
     public Optional convert(String value, ConversionContext context) {
         if(value==null){
@@ -72,36 +62,4 @@ public class OptionalConverter implements PropertyConverter<Optional> {
         return getClass().hashCode();
     }
 
-
-    private static final class ConvertQuery<T> implements ConfigQuery<T>{
-
-        private String rawValue;
-        private TypeLiteral<T> type;
-
-        public ConvertQuery(String rawValue, TypeLiteral<T> type) {
-            this.rawValue = Objects.requireNonNull(rawValue);
-            this.type = Objects.requireNonNull(type);
-        }
-
-        @Override
-        public T query(Configuration config) {
-            List<PropertyConverter<T>> converters = config.getContext().getPropertyConverters(type);
-            ConversionContext context = new ConversionContext.Builder(type).setConfigurationContext(config.getContext())
-                    .setConfiguration(config).setKey(ConvertQuery.class.getName()).build();
-            for(PropertyConverter<?> conv: converters) {
-                try{
-                    if(conv instanceof OptionalConverter){
-                        continue;
-                    }
-                    T result = (T)conv.convert(rawValue, context);
-                    if(result!=null){
-                        return result;
-                    }
-                }catch(Exception e){
-                    LOG.log(Level.FINEST,  e, () -> "Converter "+ conv +" failed to convert to " + type);
-                }
-            }
-            return null;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
index e59c0b9..404daee 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
@@ -22,11 +22,8 @@ import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.osgi.service.component.annotations.Component;
 
-import java.io.File;
-import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.Objects;
 import java.util.logging.Level;
 import java.util.logging.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java
new file mode 100644
index 0000000..05aa3d5
--- /dev/null
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java
@@ -0,0 +1,71 @@
+/*
+ * 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.internal.converters;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.osgi.service.component.annotations.Component;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+
+/**
+ * Converter, converting from String to Boolean.
+ */
+@Component(service = PropertyConverter.class)
+public class SupplierConverter implements PropertyConverter<Supplier> {
+
+    private static final Logger LOG = Logger.getLogger(SupplierConverter.class.getName());
+
+    @Override
+    public Supplier convert(String value, ConversionContext context) {
+        return () -> {
+            try{
+                Type targetType = context.getTargetType().getType();
+                ParameterizedType pt = (ParameterizedType) targetType;
+                if(String.class.equals(pt.getActualTypeArguments()[0])){
+                    return value;
+                }
+                ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(pt.getActualTypeArguments()[0]));
+                Object o = context.getConfiguration().query(converter);
+                if(o==null){
+                    throw new ConfigException("No such value: " + context.getKey());
+                }
+                return o;
+            }catch(Exception e){
+                throw new ConfigException("Error evaluating config value.", e);
+            }
+        };
+    }
+
+    @Override
+    public boolean equals(Object o){
+        return getClass().equals(o.getClass());
+    }
+
+    @Override
+    public int hashCode(){
+        return getClass().hashCode();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
deleted file mode 100644
index 316dd59..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
+++ /dev/null
@@ -1,162 +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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Abstract {@link org.apache.tamaya.spi.PropertySource} that allows to set a default ordinal that will be used, if no
- * ordinal is provided with the config.
- */
-public abstract class BasePropertySource implements PropertySource {
-    /** default ordinal that will be used, if no ordinal is provided with the config. */
-    private int defaultOrdinal;
-    /** Used if the ordinal has been set explicitly. */
-    private volatile Integer ordinal;
-    /** The name of the property source. */
-    private String name;
-
-    /**
-     * Constructor.
-     * @param name the (unique) property source name, not {@code null}.
-     */
-    protected BasePropertySource(String name){
-        this.name = Objects.requireNonNull(name);
-        this.defaultOrdinal = 0;
-    }
-
-    /**
-     * Constructor.
-     * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config.
-     */
-    protected BasePropertySource(int defaultOrdinal){
-        this.name = getClass().getSimpleName();
-        this.defaultOrdinal = defaultOrdinal;
-    }
-
-    /**
-     * Constructor.
-     * @param name the (unique) property source name, not {@code null}.
-     * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config.
-     */
-    protected BasePropertySource(String name, int defaultOrdinal){
-        this.name = Objects.requireNonNull(name);
-        this.defaultOrdinal = defaultOrdinal;
-    }
-
-
-    /**
-     * Constructor, using a default ordinal of 0.
-     */
-    protected BasePropertySource(){
-        this(0);
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Sets the property source's (unique) name.
-     * @param name the name, not {@code null}.
-     */
-    public void setName(String name){
-        this.name = Objects.requireNonNull(name);
-    }
-
-    /**
-     * Allows to set the ordinal of this property source explcitly. This will override any evaluated
-     * ordinal, or default ordinal. To reset an explcit ordinal call {@code setOrdinal(null);}.
-     * @param ordinal the explicit ordinal, or {@code null}.
-     */
-    public void setOrdinal(Integer ordinal){
-        this.ordinal = ordinal;
-    }
-
-    /**
-     * Allows to set the ordinal of this property source explcitly. This will override any evaluated
-     * ordinal, or default ordinal. To reset an explcit ordinal call {@code setOrdinal(null);}.
-     * @param defaultOrdinal the default ordinal, or {@code null}.
-     */
-    public void setDefaultOrdinal(Integer defaultOrdinal){
-        this.defaultOrdinal = defaultOrdinal;
-    }
-
-    public int getOrdinal() {
-        Integer ordinal = this.ordinal;
-        if(ordinal!=null){
-            Logger.getLogger(getClass().getName()).finest(
-                    "Using explicit ordinal '"+ordinal+"' for property source: " + getName());
-            return ordinal;
-        }
-        PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
-        if(configuredOrdinal!=null){
-            try {
-                return Integer.parseInt(configuredOrdinal.getValue());
-            } catch (Exception e) {
-                Logger.getLogger(getClass().getName()).log(Level.WARNING,
-                        "Configured ordinal is not an int number: " + configuredOrdinal, e);
-            }
-        }
-        return getDefaultOrdinal();
-    }
-
-    /**
-     * Returns the  default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
-     * @return the  default ordinal used, by default 0.
-     */
-    public int getDefaultOrdinal(){
-        return defaultOrdinal;
-    }
-
-    @Override
-    public PropertyValue get(String key) {
-        Map<String,PropertyValue> properties = getProperties();
-        PropertyValue val = properties.get(key);
-        if(val==null){
-            return null;
-        }
-        return val;
-    }
-
-    @Override
-    public boolean isScannable(){
-        return true;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof BasePropertySource)) return false;
-        BasePropertySource that = (BasePropertySource) o;
-        return Objects.equals(getName(), that.getName());
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(getName());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/CLIPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/CLIPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/CLIPropertySource.java
deleted file mode 100644
index 276cc94..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/CLIPropertySource.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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.osgi.service.component.annotations.Component;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that allows to add the programs main arguments as configuration entries. Unix syntax using '--' and
- * '-' params is supported.
- */
-@Component(service = PropertySource.class)
-public class CLIPropertySource extends BasePropertySource{
-
-    /** The original main arguments. */
-    private static String[] args = new String[0];
-
-    /** The map of parsed main arguments. */
-    private static Map<String,PropertyValue> mainArgs;
-
-    /* Initializes the initial state. */
-    static {
-        initMainArgs(args);
-    }
-
-    /**
-     * Creates a new instance.
-     */
-    public CLIPropertySource(){
-        this(null);
-    }
-
-    /**
-     * Creates a new instance, allows optionally to pass the main arguments.
-     * @param args the args, or null.
-     */
-    public CLIPropertySource(String... args){
-        if(args!=null){
-            initMainArgs(args);
-        }
-    }
-
-    /**
-     * Creates a new instance, allows optionally to pass the main arguments.
-     * @param args the args, or null.
-     * @param ordinal the ordinal to be applied.
-     */
-    public CLIPropertySource(int ordinal, String... args){
-        if(args!=null){
-            initMainArgs(args);
-        }
-        setOrdinal(ordinal);
-    }
-
-
-
-    /**
-     * Configure the main arguments, hereby parsing and mapping the main arguments into
-     * configuration propertiesi as key-value pairs.
-     * @param args the main arguments, not {@code null}.
-     */
-    public static void initMainArgs(String... args){
-        CLIPropertySource.args = Objects.requireNonNull(args);
-        // TODO is there a way to figure out the args?
-        String argsProp = System.getProperty("main.args");
-        if(argsProp!=null){
-            CLIPropertySource.args = argsProp.split("\\s");
-        }
-        Map<String,PropertyValue> result;
-        if(CLIPropertySource.args==null){
-            result = Collections.emptyMap();
-        }else{
-            result = new HashMap<>();
-            String prefix = System.getProperty("main.args.prefix");
-            if(prefix==null){
-                prefix="";
-            }
-            String key = null;
-            for(String arg:CLIPropertySource.args){
-                if(arg.startsWith("--")){
-                    arg = arg.substring(2);
-                    int index = arg.indexOf("=");
-                    if(index>0){
-                        key = arg.substring(0,index).trim();
-                        result.put(prefix+key, PropertyValue.of(key, arg.substring(index+1).trim(), "main-args"));
-                        key = null;
-                    }else{
-                        result.put(prefix+arg, PropertyValue.of(prefix+arg, arg, "main-args"));
-                    }
-                }else if(arg.startsWith("-")){
-                    key = arg.substring(1);
-                }else{
-                    if(key!=null){
-                        result.put(prefix+key, PropertyValue.of(prefix+key, arg, "main-args"));
-                        key = null;
-                    }else{
-                        result.put(prefix+arg, PropertyValue.of(prefix+arg, arg, "main-args"));
-                    }
-                }
-            }
-        }
-        CLIPropertySource.mainArgs = Collections.unmodifiableMap(result);
-    }
-
-    @Override
-    public Map<String, PropertyValue> getProperties() {
-        return Collections.unmodifiableMap(mainArgs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
deleted file mode 100644
index 0ba4cd4..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
+++ /dev/null
@@ -1,293 +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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.osgi.service.component.annotations.Component;
-
-import java.util.*;
-
-/**
- * <p>{@link PropertySource} to access environment variables via Tamaya
- * which are set via {@code export VARIABLE=value} on UNIX systems or
- * {@code set VARIABLE=value} on Windows systems.</p>
- *
- * <p>Using the {@linkplain EnvironmentPropertySource} without any
- * additional configuration gives access to all existing environment
- * variables available to the Java process Tamaya is running in.</p>
- *
- * <h1>Simple usage example</h1>
- *
- * <pre>
- * $ export OPS_MODE=production
- * $ export COLOR=false
- * $ java -jar application.jar
- * </pre>
- *
- * <p>To access {@code OPS_MODE} and {@code COLOR} with the following code
- * fragment could be used:</p>
- *
- * <pre>
- * PropertySource ps = new EnvironmentPropertySource();
- * PropertyValue opsMode = ps.get("OPS_MODE");
- * PropertyValue color = ps.get("COLOR");
- * </pre>
- *
- * <h1>Application specific environmet variables with prefix</h1>
- *
- * <p>Given the case where to instances of the same application are running on
- * a single machine but need different values for the environment variable
- * {@code CUSTOMER}. The {@linkplain EnvironmentPropertySource} allows you
- * to prefix the environment variable with an application specific prefix
- * and to access it by the non-prefixed variable name.</p>
- *
- * <pre>
- * $ export CUSTOMER=none
- * $ export a81.CUSTOMER=moon
- * $ export b78.CUSTOMER=luna
- * </pre>
- *
- * <p>Given an environment with these tree variables the application running
- * for the customer called Moon could be started with the following command:</p>
- *
- * <pre>
- * $ java -Dtamaya.envprops.prefix=a81 -jar application.jar
- * </pre>
- *
- * <p>The application specific value can now be accessed from the code of the
- * application like this:</p>
- *
- * <pre>
- * PropertySource ps = new EnvironmentPropertySource();
- * PropertyValue pv = ps.get("CUSTOMER");
- * System.out.println(pv.getValue());
- * </pre>
- *
- * <p>The output of application would be {@code moon}.</p>
- *
- * <h1>Disabling the access to environment variables</h1>
- *
- * <p>The access to environment variables could be simply
- * disabled by the setting the systemproperty {@code tamaya.envprops.disable}
- * or {@code tamaya.defaults.disable} to {@code true}.</p>
- */
-@Component(service = PropertySource.class)
-public class EnvironmentPropertySource extends BasePropertySource {
-    private static final String TAMAYA_ENVPROPS_PREFIX = "tamaya.envprops.prefix";
-    private static final String TAMAYA_ENVPROPS_DISABLE = "tamaya.envprops.disable";
-    private static final String TAMAYA_DEFAULT_DISABLE = "tamaya.defaults.disable";
-
-    /**
-     * Default ordinal for {@link org.apache.tamaya.core.propertysource.EnvironmentPropertySource}
-     */
-    public static final int DEFAULT_ORDINAL = 300;
-
-    /**
-     * Prefix that allows environment properties to virtually be mapped on specified sub section.
-     */
-    private String prefix;
-
-    /**
-     * If true, this property source does not return any properties. This is useful since this
-     * property source is applied by default, but can be switched off by setting the
-     * {@code tamaya.envprops.disable} system/environment property to {@code true}.
-     */
-    private boolean disabled = false;
-
-    private SystemPropertiesProvider propertiesProvider = new SystemPropertiesProvider();
-
-    /**
-     * Creates a new instance. Also initializes the {@code prefix} and {@code disabled} properties
-     * from the system-/ environment properties:
-     * <pre>
-     *     tamaya.envprops.prefix
-     *     tamaya.envprops.disable
-     * </pre>
-     */
-    public EnvironmentPropertySource(){
-        initFromSystemProperties();
-    }
-
-    /**
-     * Initializes the {@code prefix} and {@code disabled} properties from the system-/
-     * environment properties:
-     * <pre>
-     *     tamaya.envprops.prefix
-     *     tamaya.envprops.disable
-     * </pre>
-     */
-    private void initFromSystemProperties() {
-        String temp = getPropertiesProvider().getEnvPropsPrefix();
-
-        if (temp != null) {
-            prefix = temp;
-        }
-
-        temp = getPropertiesProvider().getEnvPropsDisable();
-
-        if (temp != null) {
-            this.disabled = Boolean.parseBoolean(temp);
-        }
-
-        temp = getPropertiesProvider().getDefaultsDisable();
-
-        if (temp != null) {
-            disabled |= Boolean.parseBoolean(temp);
-        }
-    }
-
-    /**
-     * Creates a new instance using a fixed ordinal value.
-     * @param ordinal the ordinal number.
-     */
-    public EnvironmentPropertySource(int ordinal){
-        this(null, ordinal);
-    }
-
-    /**
-     * Creates a new instance.
-     * @param prefix the prefix to be used, or null.
-     * @param ordinal the ordinal to be used.
-     */
-    public EnvironmentPropertySource(String prefix, int ordinal){
-        this.prefix = prefix;
-        setOrdinal(ordinal);
-    }
-
-    /**
-     * Creates a new instance.
-     * @param prefix the prefix to be used, or null.
-     */
-    public EnvironmentPropertySource(String prefix){
-        this.prefix = prefix;
-    }
-
-    @Override
-    public int getDefaultOrdinal() {
-        return DEFAULT_ORDINAL;
-    }
-
-    @Override
-    public String getName() {
-        if (isDisabled()) {
-            return "environment-properties(disabled)";
-        }
-        return "environment-properties";
-    }
-
-    @Override
-    public PropertyValue get(String key) {
-        if (isDisabled()) {
-            return null;
-        }
-
-        String effectiveKey = hasPrefix() ? getPrefix() + "." + key
-                                          : key;
-
-        String value = getPropertiesProvider().getenv(effectiveKey);
-
-        return PropertyValue.of(key, value, getName());
-    }
-
-    private boolean hasPrefix() {
-        return null != prefix;
-    }
-
-    @Override
-    public Map<String, PropertyValue> getProperties() {
-        if (isDisabled()) {
-            return Collections.emptyMap();
-        }
-
-        String effectivePrefix = getPrefix() + ".";
-        int effectivePrefixLength = hasPrefix() ? getPrefix().length() + 1
-                                                : 0;
-        Map<String, String> envProps = getPropertiesProvider().getenv();
-
-        Map<String, PropertyValue> values = new HashMap<>();
-
-        for (Map.Entry<String, String> entry : envProps.entrySet()) {
-            if (hasPrefix()) {
-                if (entry.getKey().startsWith(effectivePrefix)) {
-
-                    String choppedKey = entry.getKey().substring(effectivePrefixLength);
-                    String value = entry.getValue();
-                    values.put(choppedKey, PropertyValue.of(choppedKey, value, getName()));
-                }
-            } else {
-                values.put(entry.getKey(), PropertyValue.of(entry.getKey(), entry.getValue(), getName()));
-            }
-        }
-
-        return values;
-    }
-
-    @Override
-    public boolean isScannable() {
-        return true;
-    }
-
-    void setPropertiesProvider(SystemPropertiesProvider spp) {
-        propertiesProvider = spp;
-        initFromSystemProperties();
-    }
-
-    SystemPropertiesProvider getPropertiesProvider() {
-        return propertiesProvider;
-    }
-
-    public String getPrefix() {
-        return prefix;
-    }
-
-    public boolean isDisabled() {
-        return disabled;
-    }
-
-    /**
-     * <p>Provides access to the system properties used to configure
-     * {@linkplain EnvironmentPropertySource}.</p>
-     *
-     * <p>This implementation delegates all property lookups
-     * to {@linkplain System#getProperty(String)}.</p>
-     */
-    static class SystemPropertiesProvider {
-        String getEnvPropsPrefix() {
-            return System.getenv(TAMAYA_ENVPROPS_PREFIX);
-        }
-
-        String getEnvPropsDisable() {
-            return System.getenv(TAMAYA_ENVPROPS_DISABLE);
-        }
-
-        String getDefaultsDisable() {
-            return System.getenv(TAMAYA_DEFAULT_DISABLE);
-        }
-
-        String getenv(String name) {
-            return System.getenv(name);
-        }
-
-        Map<String, String> getenv() {
-            return System.getenv();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/JavaConfigurationPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/JavaConfigurationPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/JavaConfigurationPropertySource.java
deleted file mode 100644
index 1518fc0..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/JavaConfigurationPropertySource.java
+++ /dev/null
@@ -1,136 +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.core.propertysource;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.internal.PropertySourceComparator;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.osgi.service.component.annotations.Component;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-
-import static java.lang.String.format;
-import static java.lang.Thread.currentThread;
-
-/**
- * Provider which reads all {@value DEFAULT_SIMPLE_PROPERTIES_FILE_NAME} and
- * {@value DEFAULT_XML_PROPERTIES_FILE_NAME} files found in the
- * classpath. By setting
- * {@code tamaya.defaultprops.disable} or {@code tamaya.defaults.disable}
- * as system or environment property this feature can be disabled.
- */
-@Component(service = PropertySource.class)
-public class JavaConfigurationPropertySource extends BasePropertySource {
-    /**
-     * Default location in the classpath, where Tamaya looks for simple line based configuration by default.
-     */
-    public static final String DEFAULT_SIMPLE_PROPERTIES_FILE_NAME="META-INF/javaconfiguration.properties";
-
-    /**
-     * Default location in the classpath, where Tamaya looks for XML based configuration by default.
-     */
-    public static final String DEFAULT_XML_PROPERTIES_FILE_NAME = "META-INF/javaconfiguration.xml";
-
-    private static final int DEFAULT_ORDINAL = 900;
-
-    private boolean enabled = evaluateEnabled();
-
-    public JavaConfigurationPropertySource(){
-        super("resource:META-INF/javaconfiguration.*", DEFAULT_ORDINAL);
-    }
-
-    private boolean evaluateEnabled() {
-        String value = System.getProperty("tamaya.defaultprops.disable");
-        if(value==null){
-            value = System.getenv("tamaya.defaultprops.disable");
-        }
-        if(value==null){
-            value = System.getProperty("tamaya.defaults.disable");
-        }
-        if(value==null){
-            value = System.getenv("tamaya.defaults.disable");
-        }
-        if(value==null){
-            return true;
-        }
-        return value.isEmpty() || !Boolean.parseBoolean(value);
-    }
-
-    private List<PropertySource> getPropertySources() {
-        List<PropertySource> propertySources = new ArrayList<>();
-        propertySources.addAll(loadPropertySourcesByName(DEFAULT_SIMPLE_PROPERTIES_FILE_NAME));
-        propertySources.addAll(loadPropertySourcesByName(DEFAULT_XML_PROPERTIES_FILE_NAME));
-        Collections.sort(propertySources, PropertySourceComparator.getInstance());
-        return propertySources;
-    }
-
-    private Collection<? extends PropertySource> loadPropertySourcesByName(String filename) {
-        List<PropertySource> propertySources = new ArrayList<>();
-        Enumeration<URL> propertyLocations;
-        try {
-            propertyLocations = ServiceContextManager.getServiceContext()
-                    .getResources(filename, currentThread().getContextClassLoader());
-        } catch (IOException e) {
-            String msg = format("Error while searching for %s", filename);
-
-            throw new ConfigException(msg, e);
-        }
-
-        while (propertyLocations.hasMoreElements()) {
-            URL currentUrl = propertyLocations.nextElement();
-            SimplePropertySource sps = new SimplePropertySource(currentUrl);
-
-            propertySources.add(sps);
-        }
-
-        return propertySources;
-    }
-
-    public boolean isEnabled() {
-        return enabled;
-    }
-
-    public void setEnabled(boolean enabled){
-        this.enabled = enabled;
-    }
-
-
-    @Override
-    public Map<String, PropertyValue> getProperties() {
-        if (!isEnabled()) {
-            return Collections.emptyMap();
-        }
-        Map<String,PropertyValue> result = new HashMap<>();
-        for(PropertySource ps:getPropertySources()){
-            result.putAll(ps.getProperties());
-        }
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "JavaConfigurationPropertySource{" +
-                "enabled=" + enabled +
-                '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
deleted file mode 100644
index 6046e0c..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
+++ /dev/null
@@ -1,140 +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.core.propertysource;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-/**
- * Simple implementation of a {@link org.apache.tamaya.spi.PropertySource} for
- * simple property files and XML property files.
- */
-public class SimplePropertySource extends BasePropertySource {
-
-    private static final Logger LOG = Logger.getLogger(SimplePropertySource.class.getName());
-
-    /**
-     * The current properties.
-     */
-    private Map<String, PropertyValue> properties = new HashMap<>();
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param propertiesLocation the URL encoded location, not {@code null}.
-     */
-    public SimplePropertySource(File propertiesLocation) {
-        super(0);
-        try {
-            setName(propertiesLocation.toString());
-            this.properties = load(propertiesLocation.toURI().toURL());
-        } catch (IOException e) {
-            throw new ConfigException("Failed to load properties from " + propertiesLocation, e);
-        }
-    }
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param propertiesLocation the URL encoded location, not {@code null}.
-     */
-    public SimplePropertySource(URL propertiesLocation) {
-        super(0);
-        this.properties = load(Objects.requireNonNull(propertiesLocation));
-        setName(propertiesLocation.toString());
-    }
-
-    /**
-     * Creates a new Properties based PropertySource based on the given properties map.
-     *
-     * @param name       the name, not {@code null}.
-     * @param properties the properties, not {@code null}.
-     */
-    public SimplePropertySource(String name, Map<String, String> properties) {
-        super(0);
-        setName(Objects.requireNonNull(name));
-        for(Map.Entry<String,String> en:properties.entrySet()){
-            this.properties.put(en.getKey(), PropertyValue.of(en.getKey(), en.getValue(), name));
-        }
-    }
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param name               The property source name
-     * @param propertiesLocation the URL encoded location, not {@code null}.
-     */
-    public SimplePropertySource(String name, URL propertiesLocation) {
-        super(0);
-        this.properties = load(propertiesLocation);
-        setName(name);
-    }
-
-    @Override
-    public Map<String, PropertyValue> getProperties() {
-        return this.properties;
-    }
-
-    /**
-     * loads the Properties from the given URL
-     *
-     * @param propertiesFile {@link java.net.URL} to load Properties from
-     * @return loaded {@link java.util.Properties}
-     * @throws IllegalStateException in case of an error while reading properties-file
-     */
-    private Map<String, PropertyValue> load(URL propertiesFile) {
-        setName(propertiesFile.toString());
-        boolean isXML = isXMLPropertieFiles(propertiesFile);
-
-        Map<String, PropertyValue> properties = new HashMap<>();
-        try (InputStream stream = propertiesFile.openStream()) {
-            Properties props = new Properties();
-            if (stream != null) {
-                if (isXML) {
-                    props.loadFromXML(stream);
-                } else {
-                    props.load(stream);
-                }
-            }
-
-            for (String key : props.stringPropertyNames()) {
-                properties.put(key, PropertyValue.of(key, props.getProperty(key), getName()));
-            }
-        } catch (IOException e) {
-            throw new ConfigException("Error loading properties from " + propertiesFile, e);
-        }
-
-        return properties;
-    }
-
-    private boolean isXMLPropertieFiles(URL url) {
-        return url.getFile().endsWith(".xml");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
deleted file mode 100644
index b4ded3a..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
+++ /dev/null
@@ -1,190 +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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.osgi.service.component.annotations.Component;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * This {@link org.apache.tamaya.spi.PropertySource} manages the system properties. You can disable this feature by
- * setting {@code tamaya.envprops.disable} or {@code tamaya.defaults.disable}.
- */
-@Component(service = PropertySource.class)
-public class SystemPropertySource extends BasePropertySource {
-
-    /**
-     * default ordinal for {@link org.apache.tamaya.core.propertysource.SystemPropertySource}
-     */
-    public static final int DEFAULT_ORDINAL = 1000;
-
-    private volatile Map<String, PropertyValue> cachedProperties;
-
-    /**
-     * previous System.getProperties().hashCode()
-     * so we can check if we need to reload
-     */
-    private volatile int previousHash;
-
-    /**
-     * Prefix that allows system properties to virtually be mapped on specified sub section.
-     */
-    private String prefix;
-
-    /**
-     * If true, this property source does not return any properties. This is useful since this
-     * property source is applied by default, but can be switched off by setting the
-     * {@code tamaya.envprops.disable} system/environment property to {@code true}.
-     */
-    private boolean disabled = false;
-
-    /**
-     * Creates a new instance. Also initializes the {@code prefix} and {@code disabled} properties
-     * from the system-/ environment properties:
-     * <pre>
-     *     tamaya.envprops.prefix
-     *     tamaya.envprops.disable
-     * </pre>
-     */
-    public SystemPropertySource(){
-        initFromSystemProperties();
-        if(!disabled){
-            cachedProperties = Collections.unmodifiableMap(loadProperties());
-        }
-    }
-
-    /**
-     * Initializes the {@code prefix} and {@code disabled} properties from the system-/
-     * environment properties:
-     * <pre>
-     *     tamaya.envprops.prefix
-     *     tamaya.envprops.disable
-     * </pre>
-     */
-    private void initFromSystemProperties() {
-        String value = System.getProperty("tamaya.sysprops.prefix");
-        if(value==null){
-            prefix = System.getenv("tamaya.sysprops.prefix");
-        }
-        value = System.getProperty("tamaya.sysprops.disable");
-        if(value==null){
-            value = System.getenv("tamaya.sysprops.disable");
-        }
-        if(value==null){
-            value = System.getProperty("tamaya.defaults.disable");
-        }
-        if(value==null){
-            value = System.getenv("tamaya.defaults.disable");
-        }
-        if(value!=null && !value.isEmpty()) {
-            this.disabled = Boolean.parseBoolean(value);
-        }
-    }
-
-    /**
-     * Creates a new instance using a fixed ordinal value.
-     * @param ordinal the ordinal number.
-     */
-    public SystemPropertySource(int ordinal){
-        this(null, ordinal);
-    }
-
-    /**
-     * Creates a new instance.
-     * @param prefix the prefix to be used, or null.
-     * @param ordinal the ordinal to be used.
-     */
-    public SystemPropertySource(String prefix, int ordinal){
-        this.prefix = prefix;
-        setOrdinal(ordinal);
-    }
-
-    /**
-     * Creates a new instance.
-     * @param prefix the prefix to be used, or null.
-     */
-    public SystemPropertySource(String prefix){
-        this.prefix = prefix;
-    }
-
-    @Override
-    public int getDefaultOrdinal() {
-        return DEFAULT_ORDINAL;
-    }
-
-
-    private Map<String,PropertyValue> loadProperties() {
-        Properties sysProps = System.getProperties();
-        previousHash = System.getProperties().hashCode();
-        final String prefix = this.prefix;
-        Map<String,PropertyValue> values = new HashMap<>();
-        for (Map.Entry<Object,Object> entry : sysProps.entrySet()) {
-            if(prefix==null) {
-                values.put(entry.getKey().toString(), PropertyValue.of(entry.getKey().toString(), entry.getValue().toString(), getName()));
-            }else {
-                values.put(prefix + entry.getKey(), PropertyValue.of(prefix + entry.getKey(), entry.getValue().toString(), getName()));
-            }
-        }
-        return values;
-    }
-
-    @Override
-    public String getName() {
-        if(disabled){
-            return "system-properties(disabled)";
-        }
-        return "system-properties";
-    }
-
-    @Override
-    public PropertyValue get(String key) {
-        if(disabled){
-            return null;
-        }
-        String prefix = this.prefix;
-        if(prefix==null) {
-            return PropertyValue.of(key, System.getProperty(key), getName());
-        }
-        return PropertyValue.of(key, System.getProperty(key.substring(prefix.length())), getName());
-    }
-
-    @Override
-    public Map<String, PropertyValue> getProperties() {
-        if(disabled){
-            return Collections.emptyMap();
-        }
-        // only need to reload and fill our map if something has changed
-        // synchronization was removed, Instance was marked as volatile. In the worst case it
-        // is reloaded twice, but the values will be the same.
-        if (previousHash != System.getProperties().hashCode()) {
-            this.cachedProperties = Collections.unmodifiableMap(loadProperties());
-        }
-        return this.cachedProperties;
-    }
-
-    @Override
-    public boolean isScannable() {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/propertysource/package-info.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/package-info.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/package-info.java
deleted file mode 100644
index 05ed466..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-
-/**
- * Contains internal implementations artifacts registered as services.
- */
-package org.apache.tamaya.core.propertysource;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
index f934197..396aef1 100644
--- a/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
+++ b/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
@@ -41,3 +41,4 @@ org.apache.tamaya.core.internal.converters.OffsetDateTimeConverter
 org.apache.tamaya.core.internal.converters.OffsetTimeConverter
 org.apache.tamaya.core.internal.converters.InstantConverter
 org.apache.tamaya.core.internal.converters.OptionalConverter
+org.apache.tamaya.core.internal.converters.SupplierConverter

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
index 56c599c..d1e392d 100644
--- a/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ b/code/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -16,7 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-org.apache.tamaya.core.propertysource.EnvironmentPropertySource
-org.apache.tamaya.core.propertysource.SystemPropertySource
-org.apache.tamaya.core.propertysource.CLIPropertySource
-org.apache.tamaya.core.propertysource.JavaConfigurationPropertySource
\ No newline at end of file
+org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource
+org.apache.tamaya.spisupport.propertysource.SystemPropertySource
+org.apache.tamaya.spisupport.propertysource.CLIPropertySource
+org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
index ddb36e2..2c8f627 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationContextBuilderTest.java
@@ -20,8 +20,8 @@ package org.apache.tamaya.core;
 
 import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder;
 import org.apache.tamaya.spi.*;
+import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder;
 import org.junit.Test;
 
 import java.util.Arrays;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
index 7c483bb..38412f3 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextTest.java
@@ -22,7 +22,6 @@ import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.TypeLiteral;
 import org.apache.tamaya.core.testdata.TestPropertyDefaultSource;
 import org.apache.tamaya.spi.*;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.*;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationTest.java
deleted file mode 100644
index d45dbbd..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationTest.java
+++ /dev/null
@@ -1,201 +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.core.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.*;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-public class DefaultConfigurationTest {
-
-    /**
-     * Tests for get(String)
-     */
-    @Test(expected = NullPointerException.class)
-    public void getDoesNotAcceptNull() {
-        DefaultConfiguration c =  new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.get(null);
-    }
-
-    /**
-     * Tests for get(String, Class)
-     */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-	@Test(expected = NullPointerException.class)
-    public void getDoesNotAcceptNullForClassTargetType() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.get("a", (Class) null);
-    }
-
-    /**
-     * Tests for get(String, TypeLiteral)
-     */
-    @Test(expected = NullPointerException.class)
-    public void getDoesNotAcceptNullForTypeLiteralTargetType() {
-        DefaultConfiguration c =  new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.get("a", (TypeLiteral<?>)null);
-    }
-
-    /**
-     * Tests for getOrDefault(String, Class, String)
-     */
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsKeyForThreeParameterVariant() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault(null, String.class, "ok");
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsDefaultValueForThreeParameterVariant() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault("a", String.class, null);
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-	@Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsTargetTypeForThreeParameterVariant() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault("a", (Class)null, "b");
-    }
-
-    /**
-     * Tests for getOrDefault(String, TypeLiteral, String)
-     */
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsKeyForThreeParameterVariantSecondIsTypeLiteral() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault(null, TypeLiteral.of(String.class), "ok");
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsDefaultValueForThreeParameterVariantSecondIsTypeLiteral() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault("a", TypeLiteral.of(String.class), null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsTargetTypeForThreeParameterVariantSecondIsTypeLiteral() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault("a", (TypeLiteral<String>) null, "b");
-    }
-
-    /**
-     * Tests for getOrDefault(String, String)
-     */
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsKeyForTwoParameterVariantDefaultValueIsSecond() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault(null, "ok");
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void getOrDefaultDoesNotAcceptNullAsDefaultValueForTwoParameterVariantDefaultValueIsSecond() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.getOrDefault("a", null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void with_Null() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.with(null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void query_Null() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-
-        c.query(null);
-    }
-
-    @Test
-    public void with() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-        assertEquals(c.with(config -> config), c);
-    }
-
-    @Test
-    public void query() {
-        DefaultConfiguration c = new DefaultConfiguration(new DummyConfigurationContext());
-        assertEquals(c.query(config -> "testQ"), "testQ");
-    }
-
-    public static class DummyConfigurationContext implements ConfigurationContext {
-        @Override
-        public void addPropertySources(PropertySource... propertySources) {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public List<PropertySource> getPropertySources() {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public PropertySource getPropertySource(String name) {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public <T> void addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T> propertyConverter) {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> type) {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public List<PropertyFilter> getPropertyFilters() {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy() {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-
-        @Override
-        public ConfigurationContextBuilder toBuilder() {
-            throw new RuntimeException("Method should be never called in this test");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
deleted file mode 100644
index 1b1425b..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
+++ /dev/null
@@ -1,45 +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.core.internal;
-
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.junit.Test;
-
-import javax.annotation.Priority;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by atsticks on 12.09.16.
- */
-public class PriorityServiceComparatorTest {
-
-
-    @Test
-    public void compare() throws Exception {
-        assertTrue(PriorityServiceComparator.getInstance().compare("a", "b")==0);
-        assertTrue(PriorityServiceComparator.getInstance().compare(getClass(), getClass())==0);
-        assertTrue(PriorityServiceComparator.getInstance().compare(new A(), new SystemPropertySource())==-1);
-        assertTrue(PriorityServiceComparator.getInstance().compare(new SystemPropertySource(), new A())==1);
-    }
-
-    @Priority(100)
-    private static final class A{}
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
deleted file mode 100644
index fd9c766..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
+++ /dev/null
@@ -1,182 +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.core.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-
-@SuppressWarnings("unchecked")
-public class PropertyConverterManagerTest {
-
-    private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder(
-            "someKey", TypeLiteral.of(Object.class)).build();
-
-    @Test
-    public void customTypeWithFactoryMethodOfIsRecognizedAsSupported() {
-        PropertyConverterManager manager = new PropertyConverterManager();
-
-        assertThat(manager.isTargetTypeSupported(TypeLiteral.of(MyType.class)),
-                   is(true));
-    }
-
-    @SuppressWarnings({ "rawtypes" })
-	@Test
-    public void factoryMethodOfIsUsedAsConverter() {
-        PropertyConverterManager manager = new PropertyConverterManager();
-
-		List<PropertyConverter<MyType>> converters = manager.getPropertyConverters(
-                (TypeLiteral)TypeLiteral.of(MyType.class));
-
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<MyType> converter = converters.get(0);
-
-        Object result = converter.convert("IN", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(MyType.class));
-        assertThat(((MyType)result).getValue(), equalTo("IN"));
-    }
-
-	@Test
-    public void testDirectConverterMapping(){
-        PropertyConverterManager manager = new PropertyConverterManager();
-        List<PropertyConverter<C>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(C.class)));
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<C> converter = converters.get(0);
-        C result = converter.convert("testDirectConverterMapping", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(C.class));
-        assertThat((result).getInValue(), equalTo("testDirectConverterMapping"));
-    }
-
-	@Test
-    public void testDirectSuperclassConverterMapping(){
-        PropertyConverterManager manager = new PropertyConverterManager(true);
-        List<PropertyConverter<B>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
-        assertThat(converters, hasSize(1));
-        converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<B> converter = converters.get(0);
-        B result = converter.convert("testDirectSuperclassConverterMapping", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(C.class));
-        assertThat(((C)result).getInValue(), equalTo("testDirectSuperclassConverterMapping"));
-    }
-
-	@Test
-    public void testMultipleConverterLoad(){
-        PropertyConverterManager manager = new PropertyConverterManager();
-        List<PropertyConverter<B>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
-        assertThat(converters, hasSize(0));
-        manager = new PropertyConverterManager();
-        converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
-        assertThat(converters, hasSize(0));
-        manager.initConverters();
-        converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
-        assertThat(converters, hasSize(1));
-    }
-
-	@Test
-    public void testTransitiveSuperclassConverterMapping(){
-        PropertyConverterManager manager = new PropertyConverterManager(true);
-        List<PropertyConverter<A>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(A.class)));
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<A> converter = converters.get(0);
-        A result = converter.convert("testTransitiveSuperclassConverterMapping", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(C.class));
-        assertThat(((C)result).getInValue(), equalTo("testTransitiveSuperclassConverterMapping"));
-    }
-
-	@Test
-    public void testDirectInterfaceMapping(){
-        PropertyConverterManager manager = new PropertyConverterManager(true);
-        List<PropertyConverter<Readable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(Readable.class)));
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<Readable> converter = converters.get(0);
-        Readable result = converter.convert("testDirectInterfaceMapping", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(C.class));
-        assertThat(((C)result).getInValue(), equalTo("testDirectInterfaceMapping"));
-    }
-
-    @Test
-    public void testTransitiveInterfaceMapping1(){
-        PropertyConverterManager manager = new PropertyConverterManager(true);
-        List<PropertyConverter<Runnable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(Runnable.class)));
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<Runnable> converter = converters.get(0);
-        Runnable result = converter.convert("testTransitiveInterfaceMapping1", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(C.class));
-        assertThat(((C)result).getInValue(), equalTo("testTransitiveInterfaceMapping1"));
-    }
-
-    @Test
-    public void testTransitiveInterfaceMapping2(){
-        PropertyConverterManager manager = new PropertyConverterManager(true);
-        List<PropertyConverter<AutoCloseable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(AutoCloseable.class)));
-        assertThat(converters, hasSize(1));
-
-        PropertyConverter<AutoCloseable> converter = converters.get(0);
-        AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2", DUMMY_CONTEXT);
-
-        assertThat(result, notNullValue());
-        assertThat(result, instanceOf(C.class));
-        assertThat(((C)result).getInValue(), equalTo("testTransitiveInterfaceMapping2"));
-    }
-
-    public static class MyType {
-        private final String typeValue;
-
-        private MyType(String value) {
-            typeValue = value;
-        }
-
-        public static MyType of(String source) {
-            return new MyType(source);
-        }
-
-        public String getValue() {
-            return typeValue;
-        }
-
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyFilterComparatorTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyFilterComparatorTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyFilterComparatorTest.java
deleted file mode 100644
index 0ad4c8a..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/PropertyFilterComparatorTest.java
+++ /dev/null
@@ -1,75 +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.core.internal;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertyValue;
-import org.junit.Test;
-
-import javax.annotation.Priority;
-
-import java.util.Comparator;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PropertyFilterComparatorTest {
-
-    @Test
-    public void comparationOfFiltersWithSamePriorityIsCorrect() {
-        Comparator<PropertyFilter> comparator = PropertyFilterComparator.getInstance();
-
-        int result = comparator.compare(new PropertyFilterA(), new PropertyFilterA());
-
-        assertThat(result).isEqualTo(0);
-    }
-
-    @Test
-    public void comparationOfFiltersFirstHigherThenSecondWorksCorrectly() {
-        Comparator<PropertyFilter> comparator = PropertyFilterComparator.getInstance();
-
-        int result = comparator.compare(new PropertyFilterB(), new PropertyFilterA());
-
-        assertThat(result).isGreaterThan(0);
-    }
-
-    @Test
-    public void comparationOfFiltersSecondHigherThenFirstWorksCorrectly() {
-        Comparator<PropertyFilter> comparator = PropertyFilterComparator.getInstance();
-
-        int result = comparator.compare(new PropertyFilterA(), new PropertyFilterB());
-
-        assertThat(result).isLessThan(0);
-    }
-
-
-    @Priority(1)
-    private static class PropertyFilterA  implements PropertyFilter {
-        public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
-            throw new RuntimeException("Not implemented or look at me!");
-        }
-    }
-
-    @Priority(2)
-    private static class PropertyFilterB  implements PropertyFilter {
-        public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
-            throw new RuntimeException("Not implemented or look at me!");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
deleted file mode 100644
index 54f3113..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
+++ /dev/null
@@ -1,136 +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.core.propertysource;
-
-import org.apache.tamaya.core.internal.PropertySourceComparator;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.*;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class BasePropertySourceTest {
-
-    @Test
-    public void isAlwaysScanable() {
-        BasePropertySource bs = new BasePropertySource() {
-            @Override
-            public Map<String, PropertyValue> getProperties() {
-                return Collections.emptyMap();
-            }
-        };
-
-        assertThat(bs.isScannable()).isTrue();
-    }
-
-    @Test
-    public void givenOrdinalOverwritesGivenDefaulOrdinal() {
-        BasePropertySource bs = new BasePropertySource() {
-            @Override
-            public Map<String, PropertyValue> getProperties() {
-                return Collections.emptyMap();
-            }
-        };
-
-        bs.setDefaultOrdinal(10);
-
-        assertThat(bs.getDefaultOrdinal()).isEqualTo(10);
-        assertThat(bs.getOrdinal()).isEqualTo(10);
-
-        bs.setOrdinal(20);
-
-        assertThat(bs.getOrdinal()).isEqualTo(20);
-    }
-
-    @Test
-    public void testGetOrdinal() {
-
-        PropertySource defaultPropertySource = new BasePropertySource(56) {
-
-            @Override
-            public String getName() {
-                return "testWithDefault";
-            }
-
-            @Override
-            public PropertyValue get(String key) {
-                return null;
-            }
-
-            @Override
-            public Map<String, PropertyValue> getProperties() {
-                return Collections.emptyMap();
-            }
-        };
-
-        Assert.assertEquals(56, PropertySourceComparator.getOrdinal(defaultPropertySource));
-        Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
-
-        // propertySource with invalid ordinal
-        Assert.assertEquals(1, new OverriddenInvalidOrdinalPropertySource().getOrdinal());
-    }
-
-    @Test
-    public void testGet() {
-        Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
-    }
-
-    private static class OverriddenOrdinalPropertySource extends BasePropertySource {
-
-        private OverriddenOrdinalPropertySource() {
-            super(250);
-        }
-
-        @Override
-        public String getName() {
-            return "overriddenOrdinal";
-        }
-
-        @Override
-        public Map<String, PropertyValue> getProperties() {
-            Map<String,PropertyValue> result = new HashMap<>(1);
-            result.put(PropertySource.TAMAYA_ORDINAL, PropertyValue.of(PropertySource.TAMAYA_ORDINAL, "1000", getName()));
-            return result;
-        }
-    }
-
-    private static class OverriddenInvalidOrdinalPropertySource extends BasePropertySource {
-
-        private OverriddenInvalidOrdinalPropertySource() {
-            super(1);
-        }
-
-        @Override
-        public String getName() {
-            return "overriddenInvalidOrdinal";
-        }
-
-        @Override
-        public Map<String, PropertyValue> getProperties() {
-            Map<String,PropertyValue> result = new HashMap<>(1);
-            result.put(PropertySource.TAMAYA_ORDINAL, PropertyValue.of(PropertySource.TAMAYA_ORDINAL, "invalid", getName()));
-            return result;
-        }
-    }
-
-
-}



[05/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/propertysource/CLIPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/CLIPropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/CLIPropertySourceTest.java
deleted file mode 100644
index bd6468b..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/CLIPropertySourceTest.java
+++ /dev/null
@@ -1,58 +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.core.propertysource;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for PropertySource for reading main arguments as configuration.
- */
-public class CLIPropertySourceTest {
-
-    @Test
-    public void setCLIProps() throws Exception {
-        System.clearProperty("main.args");
-        CLIPropertySource ps = new CLIPropertySource();
-        assertTrue(ps.getProperties().isEmpty());
-        CLIPropertySource.initMainArgs("-a", "b");
-        assertFalse(ps.getProperties().isEmpty());
-        assertEquals(ps.getProperties().get("a").getValue(), "b");
-        CLIPropertySource.initMainArgs("--c");
-        assertFalse(ps.getProperties().isEmpty());
-        assertEquals(ps.getProperties().get("c").getValue(), "c");
-        CLIPropertySource.initMainArgs("sss");
-        assertFalse(ps.getProperties().isEmpty());
-        assertEquals("sss", ps.getProperties().get("sss").getValue());
-        CLIPropertySource.initMainArgs("-a", "b", "--c", "sss", "--val=vvv");
-        assertFalse(ps.getProperties().isEmpty());
-        assertEquals("b", ps.getProperties().get("a").getValue());
-        assertEquals("c", ps.getProperties().get("c").getValue());
-        assertEquals("sss", ps.getProperties().get("sss").getValue());
-    // getProperties() throws Exception {
-        System.setProperty("main.args", "-a b\t--c sss  ");
-        ps = new CLIPropertySource();
-        assertFalse(ps.getProperties().isEmpty());
-        System.clearProperty("main.args");
-        assertEquals("b", ps.getProperties().get("a").getValue());
-        assertEquals("c", ps.getProperties().get("c").getValue());
-        assertEquals("sss", ps.getProperties().get("sss").getValue());
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
deleted file mode 100644
index 477ffb2..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
+++ /dev/null
@@ -1,180 +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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertyValue;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static java.lang.Boolean.TRUE;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Tests for {@link org.apache.tamaya.core.propertysource.EnvironmentPropertySource}.
- */
-public class EnvironmentPropertySourceTest {
-    private EnvironmentPropertySource envPropertySource;
-
-    @Before
-    public void setOUT() {
-        envPropertySource = new EnvironmentPropertySource();
-    }
-
-    @Test
-    public void testGetOrdinal() throws Exception {
-        assertEquals(EnvironmentPropertySource.DEFAULT_ORDINAL, envPropertySource.getOrdinal());
-    }
-
-    @Test
-    public void testGetName() throws Exception {
-        assertEquals("environment-properties", envPropertySource.getName());
-    }
-
-    @Test
-    public void testGet() throws Exception {
-        for (Map.Entry<String, String> envEntry : System.getenv().entrySet()) {
-            assertEquals(envPropertySource.get(envEntry.getKey()).getValue(), envEntry.getValue());
-        }
-    }
-
-    @Test
-    public void testGetProperties() throws Exception {
-        Map<String, PropertyValue> props = envPropertySource.getProperties();
-        for(Map.Entry<String,PropertyValue> en: props.entrySet()){
-            if(!en.getKey().startsWith("_")){
-                assertEquals(System.getenv(en.getKey()), en.getValue().getValue());
-            }
-        }
-    }
-
-    @Test
-    public void testIsScannable() throws Exception {
-        assertTrue(envPropertySource.isScannable());
-    }
-
-    @Test
-    public void ifPrefixHasBeenConfiguredLookedUpEnvVarNameIsPrefixAndKeyName() {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getEnvPropsPrefix()).thenReturn("zzz");
-        when(provider.getenv("zzz.VARIABLE")).thenReturn("value");
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.get("VARIABLE").getValue()).isEqualTo("value");
-    }
-
-    @Test
-    public void ifPrefixHasNotBeenConfiguredLookedUpEnvVarNameIsKeyName() {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getEnvPropsPrefix()).thenReturn(null);
-        when(provider.getenv("VARIABLE")).thenReturn("value");
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.get("VARIABLE").getValue()).isEqualTo("value");
-    }
-
-    @Test
-    public void ifPrefixHasBeenSetAllEnvVarsWithPrefixWillBeReturnedByGetProperties() {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getEnvPropsPrefix()).thenReturn("zzz");
-        HashMap<String, String> configuredValues = new HashMap<String, String>();
-        configuredValues.put("zzz.A", "aaa");
-        configuredValues.put("zzz.B", "bbb");
-        configuredValues.put("C", "ccc");
-        configuredValues.put("D", "ddd");
-
-        when(provider.getenv()).thenReturn(configuredValues);
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.getProperties()).hasSize(2);
-
-        Map<String, PropertyValue> properties = envPropertySource.getProperties();
-
-        assertThat(properties.keySet()).containsOnly("A", "B");
-        assertThat(properties.get("A").getValue()).isEqualTo("aaa");
-        assertThat(properties.get("B").getValue()).isEqualTo("bbb");
-    }
-
-    @Test
-    public void canBeDisableBySystemPropertyTamayaDefaultsDisable() {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getDefaultsDisable()).thenReturn(TRUE.toString());
-        when(provider.getenv("VARIABLE")).thenReturn("value");
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.get("VARIABLE")).isNull();
-    }
-
-    @Test
-    public void canBeDisableBySystemPropertyTamayaEnvpropsDisable() {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getEnvPropsDisable()).thenReturn(TRUE.toString());
-        when(provider.getenv("VARIABLE")).thenReturn("value");
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.get("VARIABLE")).isNull();
-    }
-
-    @Test
-    public void isDisabledIfEvenIsDefaultsDisableIsFalse() throws Exception {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getDefaultsDisable()).thenReturn("false");
-        when(provider.getEnvPropsDisable()).thenReturn("true");
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.isDisabled()).isTrue();
-    }
-
-    @Test
-    public void isDisabledIfEvenIsEnvPropsDisableIsFalse() throws Exception {
-        EnvironmentPropertySource.SystemPropertiesProvider provider =
-            mock(EnvironmentPropertySource.SystemPropertiesProvider.class);
-
-        when(provider.getDefaultsDisable()).thenReturn("true");
-        when(provider.getEnvPropsDisable()).thenReturn("false");
-
-        envPropertySource.setPropertiesProvider(provider);
-
-        assertThat(envPropertySource.isDisabled()).isTrue();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
deleted file mode 100644
index d11b48e..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
+++ /dev/null
@@ -1,59 +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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class PropertiesFilePropertySourceTest {
-
-    private final SimplePropertySource testfilePropertySource = new SimplePropertySource(Thread.currentThread()
-            .getContextClassLoader().getResource("testfile.properties"));
-    private final SimplePropertySource overrideOrdinalPropertySource = new SimplePropertySource(
-            Thread.currentThread().getContextClassLoader().getResource("overrideOrdinal.properties"));
-
-
-    @Test
-    public void testGetOrdinal() {
-        Assert.assertEquals(0, testfilePropertySource.getOrdinal());
-        Assert.assertEquals(Integer.parseInt(overrideOrdinalPropertySource.get(PropertySource.TAMAYA_ORDINAL)
-                .getValue()),
-                overrideOrdinalPropertySource.getOrdinal());
-    }
-
-
-    @Test
-    public void testGet() {
-        Assert.assertEquals("val3", testfilePropertySource.get("key3").getValue());
-        Assert.assertEquals("myval5", overrideOrdinalPropertySource.get("mykey5").getValue());
-        Assert.assertNull(testfilePropertySource.get("nonpresentkey"));
-    }
-
-
-    @Test
-    public void testGetProperties() throws Exception {
-        Assert.assertEquals(5, testfilePropertySource.getProperties().size()); // double the size for .source values.
-        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key1"));
-        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key2"));
-        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key3"));
-        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key4"));
-        Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key5"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
deleted file mode 100644
index 2edc466..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
+++ /dev/null
@@ -1,89 +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.core.propertysource;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertyValue;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.CoreMatchers.allOf;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.aMapWithSize;
-import static org.hamcrest.Matchers.hasEntry;
-
-public class SimplePropertySourceTest {
-    @Test
-    public void successfulCreationWithPropertiesFromXMLPropertiesFile() {
-        URL resource = getClass().getResource("/valid-properties.xml");
-
-        SimplePropertySource source = new SimplePropertySource(resource);
-
-        assertThat(source, notNullValue());
-        assertThat(source.getProperties(), aMapWithSize(2)); // double the size for .source values.
-        assertThat(source.getProperties(), hasEntry("a", PropertyValue.of("a", "b", resource.toString())));
-        assertThat(source.getProperties(), hasEntry("b", PropertyValue.of("b", "1", resource.toString())));
-
-    }
-
-    @Test
-    public void failsToCreateFromNonXMLPropertiesXMLFile() {
-        URL resource = getClass().getResource("/non-xml-properties.xml");
-        ConfigException catchedException = null;
-
-        try {
-            new SimplePropertySource(resource);
-        } catch (ConfigException ce) {
-            catchedException = ce;
-        }
-
-        assertThat(catchedException.getMessage(), allOf(startsWith("Error loading properties from"),
-                                                        endsWith("non-xml-properties.xml")));
-    }
-
-    @Test
-    public void failsToCreateFromInvalidPropertiesXMLFile() {
-        URL resource = getClass().getResource("/invalid-properties.xml");
-        ConfigException catchedException = null;
-
-        try {
-            new SimplePropertySource(resource);
-        } catch (ConfigException ce) {
-            catchedException = ce;
-        }
-
-        assertThat(catchedException.getMessage(), allOf(startsWith("Error loading properties from"),
-                                                        endsWith("invalid-properties.xml")));
-    }
-
-
-    @Test
-    public void successfulCreationWithPropertiesFromSimplePropertiesFile() {
-        URL resource = getClass().getResource("/testfile.properties");
-
-        SimplePropertySource source = new SimplePropertySource(resource);
-
-        assertThat(source, notNullValue());
-        assertThat(source.getProperties(), aMapWithSize(5)); // double the size for .source values.
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
deleted file mode 100644
index 2b2b61e..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
+++ /dev/null
@@ -1,91 +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.core.propertysource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Map;
-import java.util.Properties;
-
-public class SystemPropertySourceTest {
-
-    private final SystemPropertySource testPropertySource = new SystemPropertySource();
-
-
-    @Test
-    public void testGetOrdinal() throws Exception {
-
-        // test the default ordinal
-        Assert.assertEquals(SystemPropertySource.DEFAULT_ORDINAL, testPropertySource.getOrdinal());
-
-        // set the ordinal to 1001
-        System.setProperty(PropertySource.TAMAYA_ORDINAL, "1001");
-        Assert.assertEquals(1001, new SystemPropertySource().getOrdinal());
-        // currently its not possible to change ordinal at runtime
-
-        // reset it to not destroy other tests!!
-        System.clearProperty(PropertySource.TAMAYA_ORDINAL);
-    }
-
-    @Test
-    public void testGetName() throws Exception {
-        Assert.assertEquals("system-properties", testPropertySource.getName());
-    }
-
-    @Test
-    public void testGet() throws Exception {
-        String propertyKeyToCheck = System.getProperties().stringPropertyNames().iterator().next();
-
-        PropertyValue property = testPropertySource.get(propertyKeyToCheck);
-        Assert.assertNotNull("Property '" + propertyKeyToCheck + "' is not present in " +
-                SystemPropertySource.class.getSimpleName(), property);
-        Assert.assertEquals(System.getProperty(propertyKeyToCheck), property.getValue());
-    }
-
-    @Test
-    public void testGetProperties() throws Exception {
-        checkWithSystemProperties(testPropertySource.getProperties());
-
-        // modify system properties
-        System.setProperty("test", "myTestVal");
-
-        checkWithSystemProperties(testPropertySource.getProperties());
-
-        // cleanup
-        System.clearProperty("test");
-    }
-
-    private void checkWithSystemProperties(Map<String,PropertyValue> toCheck) {
-        Properties systemEntries = System.getProperties();
-        int num = 0;
-        for (PropertyValue propertySourceEntry : toCheck.values()) {
-            if(propertySourceEntry.getKey().startsWith("_")){
-                continue; // meta entry
-            }
-            num ++;
-            Assert.assertEquals("Entry values for key '" + propertySourceEntry.getKey() + "' do not match",
-                                systemEntries.getProperty(propertySourceEntry.getKey()), propertySourceEntry.getValue());
-        }
-        Assert.assertEquals("size of System.getProperties().entrySet() must be the same as SystemPropertySrouce.getProperties().entrySet()",
-                systemEntries.size(), num);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java
index 09d86f1..c315ff6 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.core.testdata;
 
-import org.apache.tamaya.core.propertysource.BasePropertySource;
+import org.apache.tamaya.spisupport.propertysource.BasePropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 
 import java.util.Collections;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java
index b93be17..5a427e0 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.core.testdata;
 
-import org.apache.tamaya.core.propertysource.BasePropertySource;
+import org.apache.tamaya.spisupport.propertysource.BasePropertySource;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertySourceProvider;
 import org.apache.tamaya.spi.PropertyValue;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/code/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/code/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
index 409c9cb..14e0c24 100644
--- a/code/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ b/code/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -17,6 +17,6 @@
 # under the License.
 #
 org.apache.tamaya.core.testdata.TestPropertyDefaultSource
-org.apache.tamaya.core.propertysource.SystemPropertySource
-org.apache.tamaya.core.propertysource.EnvironmentPropertySource
+org.apache.tamaya.spisupport.propertysource.SystemPropertySource
+org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource
 org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/pom.xml
----------------------------------------------------------------------
diff --git a/code/pom.xml b/code/pom.xml
index aba365b..719d498 100644
--- a/code/pom.xml
+++ b/code/pom.xml
@@ -34,6 +34,7 @@ under the License.
 
     <modules>
         <module>api</module>
+        <module>spi-support</module>
         <module>core</module>
     </modules>
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/pom.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/pom.xml b/code/spi-support/pom.xml
new file mode 100644
index 0000000..bbefa89
--- /dev/null
+++ b/code/spi-support/pom.xml
@@ -0,0 +1,81 @@
+<!-- 
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.tamaya</groupId>
+        <artifactId>tamaya-code</artifactId>
+        <version>0.4-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tamaya-spisupport</artifactId>
+    <name>Apache Tamaya Common Support Classes</name>
+    <description>Apache Tamaya Support Classes useful when implementing the Tamaya SPI or code independent of the core RI
+        implementation.</description>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <!--
+                 ! See https://issues.apache.org/jira/browse/TAMAYA-318
+                 !-->
+                <groupId>org.pitest</groupId>
+                <artifactId>pitest-maven</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java
new file mode 100644
index 0000000..92fd614
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java
@@ -0,0 +1,48 @@
+/*
+ * 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.PropertyValue;
+
+import java.util.Map;
+
+
+/**
+ * Component SPI which encapsulates the evaluation of a single or full <b>raw</b>value
+ * for a {@link ConfigurationContext}.
+ */
+public interface ConfigValueEvaluator {
+
+    /**
+     * Evaluates single value using a {@link ConfigurationContext}.
+     * @param key the config key, not null.
+     * @param context the context, not null.
+     * @return the value, or null.
+     */
+    PropertyValue evaluteRawValue(String key, ConfigurationContext context);
+
+    /**
+     * Evaluates all property values from a {@link ConfigurationContext}.
+     * @param context the context, not null.
+     * @return the value, or null.
+     */
+    Map<String, PropertyValue> evaluateRawValues(ConfigurationContext context);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java
new file mode 100644
index 0000000..b764ed6
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java
@@ -0,0 +1,334 @@
+/*
+ * 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.Configuration;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.*;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A builder for creating new or adapting instances of {@link Configuration}.
+ * Builders can be obtained in exactly two ways:
+ * <ol>
+ *     <li>By accessing a preinitialized builder from an existing {@link Configuration},
+ *     by calling {@link org.apache.tamaya.Configuration#toBuilder()}.</li>
+ *     <li>By accessing an empty builder instance from
+ *     {@link org.apache.tamaya.ConfigurationProvider#getConfigurationBuilder()}.</li>
+ * </ol>
+ */
+public interface ConfigurationBuilder {
+
+    /**
+     * Init this builder instance with the given {@link ConfigurationContext} instance. This
+     * method will use any existing property sources, filters, converters and the combination
+     * policy of the given {@link ConfigurationContext} and initialize the current builder
+     * with them.
+     *
+     * @param context the {@link ConfigurationContext} instance to be used, not {@code null}.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder setContext(ConfigurationContext context);
+
+    /**
+     * This method can be used for adding {@link PropertySource}s.
+     * Hereby the property source is added to the tail of property sources with
+     * lowest priority  regardless of its current ordinal value. To sort the property
+     * sources based on their ordinals call {@link #sortPropertySources}.
+     *
+     * @param propertySources the PropertySources to add
+     * @return this builder, for chaining, never null.
+     * @throws IllegalArgumentException If a property source with a given name already
+     * exists.
+     */
+    ConfigurationBuilder addPropertySources(PropertySource... propertySources);
+
+    /**
+     * This method can be used for programmatically adding {@link PropertySource}s.
+     * Hereby the property source is added to the tail of property sources with
+     * lowest priority regardless of its current ordinal value. To sort the property
+     * sources based on their ordinals call {@link #sortPropertySources}.
+     *
+     * @param propertySources the PropertySources to add
+     * @return this builder, for chaining, never null.
+     * @throws IllegalArgumentException If a property source with a given name already
+     * exists.
+     */
+    ConfigurationBuilder addPropertySources(Collection<PropertySource> propertySources);
+
+    /**
+     * Add all registered (default) property sources to the context built. The sources are ordered
+     * based on their ordinal values and added to the chain of property sources with
+     * higher priority.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder addDefaultPropertySources();
+
+    /**
+     * Removes the given property sources, if existing. The existing order of property
+     * sources is preserved.
+     *
+     * @param propertySources the property sources to remove, not {@code null}.
+     * @return the builder for chaining.
+     */
+    ConfigurationBuilder removePropertySources(PropertySource... propertySources);
+
+    /**
+     * Removes the given property sources, if existing. The existing order of property
+     * sources is preserved.
+     *
+     * @param propertySources the property sources to remove, not {@code null}.
+     * @return the builder for chaining.
+     */
+    ConfigurationBuilder removePropertySources(Collection<PropertySource> propertySources);
+
+    /**
+     * Access the current chain of property sources. Items at the end of the list have
+     * precedence/more significance.
+     *
+     * @return the property source chain, never {@code null}.
+     */
+    List<PropertySource> getPropertySources();
+
+    /**
+     * Access the current chain of property filters. Items at the end of the list have
+     * precedence/more significance.
+     *
+     * @return the property source chain, never {@code null}.
+     */
+    List<PropertyFilter> getPropertyFilters();
+
+    /**
+     * Access the current registered property converters.
+     *
+     * @return the current registered property converters.
+     */
+    Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter();
+
+    /**
+     * Increases the priority of the given property source, by moving it towards the end
+     * of the chain of property sources. If the property source given is already at the end
+     * this method has no effect. This operation does not change any ordinal values.
+     *
+     * @param propertySource the property source to be incresed regarding its significance.
+     * @return the builder for chaining.
+     * @throws IllegalArgumentException If no such property source exists in the current
+     * chain.
+     */
+    ConfigurationBuilder increasePriority(PropertySource propertySource);
+
+    /**
+     * Decreases the priority of the given property source, by moving it towards the start
+     * of the chain of property sources. If the property source given is already the first
+     * this method has no effect. This operation does not change any ordinal values.
+     *
+     * @param propertySource the property source to be decresed regarding its significance.
+     * @return the builder for chaining.
+     * @throws IllegalArgumentException If no such property source exists in the current
+     * chain.
+     */
+    ConfigurationBuilder decreasePriority(PropertySource propertySource);
+
+    /**
+     * Increases the priority of the given property source to be maximal, by moving it to
+     * the tail of the of property source chain. If the property source given is
+     * already the last item this method has no effect. This operation does not change
+     * any ordinal values.
+     *
+     * @param propertySource the property source to be maximized regarding its significance.
+     * @return the builder for chaining.
+     * @throws IllegalArgumentException If no such property source exists in the current
+     * chain.
+     */
+    ConfigurationBuilder highestPriority(PropertySource propertySource);
+
+    /**
+     * Decreases the priority of the given property source to be minimal, by moving it to
+     * the start of the chain of property source chain. If the property source given is
+     * already the first item this method has no effect. This operation does not change
+     * any ordinal values.
+     *
+     * @param propertySource the property source to be minimized regarding its significance.
+     * @return the builder for chaining.
+     * @throws IllegalArgumentException If no such property source exists in the current
+     * chain.
+     */
+    ConfigurationBuilder lowestPriority(PropertySource propertySource);
+
+    /**
+     * Adds the given PropertyFilter instances, hereby the instances are added
+     * to the end of the list with highest priority. The ordering of existing
+     * property filters remains unchanged. To sort the property
+     * filters call {@link #sortPropertyFilter}.
+     *
+     * @param filters the filters to add
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder addPropertyFilters(PropertyFilter... filters);
+
+    /**
+     * Adds the given PropertyFilter instances, hereby the instances are added
+     * to the end of the list with highest priority. The ordering of existing
+     * property filters remains unchanged. To sort the property
+     * filters call {@link #sortPropertyFilter}.
+     *
+     * @param filters the filters to add
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder addPropertyFilters(Collection<PropertyFilter> filters);
+
+    /**
+     * Add all registered (default) property filters to the context built.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder addDefaultPropertyFilters();
+
+
+    /**
+     * Removes the given PropertyFilter instances, if existing. The order of the remaining
+     * filters is preserved.
+     *
+     * @param filters the filter to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder removePropertyFilters(PropertyFilter... filters);
+
+    /**
+     * Removes the given PropertyFilter instances, if existing. The order of the remaining
+     * filters is preserved.
+     *
+     * @param filters the filter to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder removePropertyFilters(Collection<PropertyFilter> filters);
+
+    /**
+     * This method can be used for adding {@link PropertyConverter}s.
+     * Converters are added at the end after any existing converters.
+     * For converters already registered for the current target type the
+     * method has no effect.
+     *
+     * @param typeToConvert     the type for which the converters is for
+     * @param propertyConverters the PropertyConverters to add for this type
+     * @param <T> the target type.
+     * @return this builder, for chaining, never null.
+     */
+    <T> ConfigurationBuilder addPropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                                PropertyConverter<T>... propertyConverters);
+
+    /**
+     * This method can be used for adding {@link PropertyConverter}s.
+     * Converters are added at the end after any existing converters.
+     * For converters already registered for the current target type the
+     * method has no effect.
+     *
+     * @param typeToConvert     the type for which the converters is for
+     * @param propertyConverters the PropertyConverters to add for this type
+     * @param <T> the target type.
+     * @return this builder, for chaining, never null.
+     */
+    <T> ConfigurationBuilder addPropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                                Collection<PropertyConverter<T>> propertyConverters);
+
+    /**
+     * Add all registered (default) property converters to the context built.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder addDefaultPropertyConverters();
+
+    /**
+     * Removes the given PropertyConverter instances for the given type,
+     * if existing.
+     *
+     * @param typeToConvert the type which the converters is for
+     * @param propertyConverters    the converters to remove
+     * @param <T> the target type.
+     * @return this builder, for chaining, never null.
+     */
+    <T> ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                                   PropertyConverter<T>... propertyConverters);
+
+    /**
+     * Removes the given PropertyConverter instances for the given type,
+     * if existing.
+     *
+     * @param typeToConvert the type which the converters is for
+     * @param propertyConverters    the converters to remove
+     * @param <T> the target type.
+     * @return this builder, for chaining, never null.
+     */
+    <T> ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                                   Collection<PropertyConverter<T>> propertyConverters);
+
+    /**
+     * Removes all converters for the given type, which actually renders a given type
+     * unsupported for type conversion.
+     *
+     * @param typeToConvert the type which the converters is for
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder removePropertyConverters(TypeLiteral<?> typeToConvert);
+
+    /**
+     * Sorts the current registered property sources using the given comparator.
+     *
+     * NOTE: property sources at the beginning have minimal significance.
+     *
+     * @param comparator the comparator to be used, not {@code null}.
+     * @return this instance for chaining.
+     */
+    ConfigurationBuilder sortPropertySources(Comparator<PropertySource> comparator);
+
+    /**
+     * Sorts the current registered property filters using the given comparator.
+     *
+     * NOTE: property filters at the beginning have minimal significance.
+     *
+     * @param comparator the comparator to be used, not {@code null}.
+     * @return this instance for chaining.
+     */
+    ConfigurationBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator);
+
+    /**
+     * Sets the {@link PropertyValueCombinationPolicy} used to evaluate the final
+     * property values.
+     *
+     * @param policy the {@link PropertyValueCombinationPolicy} used, not {@code null}.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy);
+
+    /**
+     * Builds a new {@link Configuration} based on the data in this builder. The ordering of property
+     * sources and property filters is not changed, regardless of their ordinals. For ensure a certain
+     * ordering/significance call {@link #sortPropertyFilter(Comparator)} and/or {@link #sortPropertySources(Comparator)}
+     * before building the context.
+     *
+     * @return the final configuration.
+     */
+    Configuration build();
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java
new file mode 100644
index 0000000..d50ed7d
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java
@@ -0,0 +1,70 @@
+/*
+ * 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.PropertyFilter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Implementation of the Configuration API. This class uses the current {@link ConfigurationContext} to evaluate the
+ * chain of {@link PropertySource} and {@link PropertyFilter}
+ * instance to evaluate the current Configuration.
+ */
+public class DefaultConfigValueEvaluator implements ConfigValueEvaluator{
+
+    @Override
+    public PropertyValue evaluteRawValue(String key, ConfigurationContext context) {
+        PropertyValue unfilteredValue = null;
+        for (PropertySource propertySource : context.getPropertySources()) {
+            unfilteredValue = context.getPropertyValueCombinationPolicy().
+                    collect(unfilteredValue, key, propertySource);
+        }
+        if(unfilteredValue==null || unfilteredValue.getValue()==null){
+            return null;
+        }
+        return unfilteredValue;
+    }
+
+    @Override
+    public Map<String, PropertyValue> evaluateRawValues(ConfigurationContext context) {
+        Map<String, PropertyValue> result = new HashMap<>();
+        for (PropertySource propertySource : context.getPropertySources()) {
+            for (Map.Entry<String,PropertyValue> propEntry: propertySource.getProperties().entrySet()) {
+                PropertyValue unfilteredValue = result.get(propEntry.getKey());
+                unfilteredValue = context.getPropertyValueCombinationPolicy().
+                        collect(unfilteredValue, propEntry.getKey(), propertySource);
+                if(unfilteredValue!=null){
+                    result.put(unfilteredValue.getKey(), unfilteredValue);
+                }
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "DefaultConfigEvaluator{}";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
new file mode 100644
index 0000000..227c9ab
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
@@ -0,0 +1,268 @@
+/*
+ * 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.ConfigException;
+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 org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+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 PropertySource} and {@link org.apache.tamaya.spi.PropertyFilter}
+ * instance to evaluate the current Configuration.
+ */
+public class DefaultConfiguration implements Configuration {
+    /**
+     * The logger.
+     */
+    private static final Logger LOG = Logger.getLogger(DefaultConfiguration.class.getName());
+
+    /**
+     * The current {@link ConfigurationContext} of the current instance.
+     */
+    private final ConfigurationContext configurationContext;
+
+    /**
+     * EvaluationStrategy
+     */
+    private ConfigValueEvaluator configEvaluator = loadConfigValueEvaluator();
+
+    private ConfigValueEvaluator loadConfigValueEvaluator() {
+        ConfigValueEvaluator eval = null;
+        try{
+            eval = ServiceContextManager.getServiceContext()
+                    .getService(ConfigValueEvaluator.class);
+        }catch(Exception e){
+            LOG.log(Level.WARNING, "Failed to load ConfigValueEvaluator from ServiceContext, using default.", e);
+        }
+        if(eval==null){
+            eval = new DefaultConfigValueEvaluator();
+        }
+        return eval;
+    }
+
+
+    /**
+     * Constructor.
+     * @param configurationContext The configuration Context to be used.
+     */
+    public DefaultConfiguration(ConfigurationContext configurationContext){
+        this.configurationContext = Objects.requireNonNull(configurationContext);
+    }
+
+    /**
+     * Get a given value, filtered with the context's filters as needed.
+     * @param key the property's key, not null.
+     * @return the filtered value, or null.
+     */
+    @Override
+    public String get(String key) {
+        Objects.requireNonNull(key, "Key must not be null.");
+
+        PropertyValue value = configEvaluator.evaluteRawValue(key, configurationContext);
+        if(value==null || value.getValue()==null){
+            return null;
+        }
+        value = PropertyFiltering.applyFilter(value, configurationContext);
+        if(value!=null){
+            return value.getValue();
+        }
+        return null;
+    }
+
+    /**
+     * Evaluates the raw value using the context's PropertyValueCombinationPolicy.
+     * @param key the key, not null.
+     * @return the value, before filtering is applied.
+     */
+    protected PropertyValue evaluteRawValue(String key) {
+        List<PropertySource> propertySources = configurationContext.getPropertySources();
+        PropertyValue filteredValue = null;
+        PropertyValueCombinationPolicy combinationPolicy = this.configurationContext
+                .getPropertyValueCombinationPolicy();
+        for (PropertySource propertySource : propertySources) {
+            filteredValue = combinationPolicy.collect(filteredValue, key, propertySource);
+        }
+        return filteredValue;
+    }
+
+
+    @Override
+    public String getOrDefault(String key, String defaultValue) {
+        Objects.requireNonNull(key, "Key must not be null.");
+        Objects.requireNonNull(defaultValue, "Default value must not be null");
+
+        String val = get(key);
+        if(val==null){
+            return defaultValue;
+        }
+        return val;
+    }
+
+    @Override
+    public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
+        Objects.requireNonNull(key, "Key must not be null.");
+        Objects.requireNonNull(type, "Target type must not be null");
+        Objects.requireNonNull(defaultValue, "Default value must not be null");
+
+        T val = get(key, type);
+        if(val==null){
+            return defaultValue;
+        }
+        return val;
+    }
+
+    /**
+     * Get the current properties, composed by the loaded {@link PropertySource} and filtered
+     * by registered {@link org.apache.tamaya.spi.PropertyFilter}.
+     *
+     * @return the final properties.
+     */
+    @Override
+    public Map<String, String> getProperties() {
+        Map<String, PropertyValue> filtered = PropertyFiltering.applyFilters(
+                configEvaluator.evaluateRawValues(configurationContext),
+                configurationContext);
+        Map<String,String> result = new HashMap<>();
+        for(PropertyValue val:filtered.values()){
+            if(val.getValue()!=null) {
+                result.put(val.getKey(), val.getValue());
+                // TODO: Discuss metadata handling...
+                result.putAll(val.getMetaEntries());
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * Accesses the current String value for the given key and tries to convert it
+     * using the {@link PropertyConverter} instances provided by the current
+     * {@link ConfigurationContext}.
+     *
+     * @param key  the property's absolute, or relative path, e.g. @code
+     *             a/b/c/d.myProperty}, never {@code null}.
+     * @param type The target type required, not {@code null}.
+     * @param <T>  the value type
+     * @return the converted value, never {@code null}.
+     */
+    @Override
+    public <T> T get(String key, Class<T> type) {
+        return get(key, (TypeLiteral<T>)TypeLiteral.of(type));
+    }
+
+    /**
+     * Accesses the current String value for the given key and tries to convert it
+     * using the {@link PropertyConverter} instances provided by the current
+     * {@link ConfigurationContext}.
+     *
+     * @param key  the property's absolute, or relative path, e.g. @code
+     *             a/b/c/d.myProperty}.
+     * @param type The target type required, not null.
+     * @param <T>  the value type
+     * @return the converted value, never null.
+     */
+    @Override
+    public <T> T get(String key, TypeLiteral<T> type) {
+        Objects.requireNonNull(key, "Key must not be null.");
+        Objects.requireNonNull(type, "Target type must not be null");
+
+        return convertValue(key, get(key), type);
+    }
+
+    @SuppressWarnings("unchecked")
+	protected <T> T convertValue(String key, String value, TypeLiteral<T> type) {
+        if (value != null) {
+            List<PropertyConverter<T>> converters = configurationContext.getPropertyConverters(type);
+            ConversionContext context = new ConversionContext.Builder(this, this.configurationContext, key, type)
+                    .build();
+            for (PropertyConverter<T> converter : converters) {
+                try {
+                    T t = converter.convert(value, context);
+                    if (t != null) {
+                        return t;
+                    }
+                } catch (Exception e) {
+                    LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value, e);
+                }
+            }
+            // if the target type is a String, we can return the value, no conversion required.
+            if(type.equals(TypeLiteral.of(String.class))){
+                return (T)value;
+            }
+            // unsupported type, throw an exception
+            throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
+                    ", supported formats: " + context.getSupportedFormats());
+        }
+        return null;
+    }
+
+    @Override
+    public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
+        Objects.requireNonNull(key);
+        Objects.requireNonNull(type);
+        Objects.requireNonNull(defaultValue);
+
+        T val = get(key, type);
+        if(val==null){
+            return defaultValue;
+        }
+        return val;
+    }
+
+    @Override
+    public Configuration with(ConfigOperator operator) {
+        return operator.operate(this);
+    }
+
+    @Override
+    public <T> T query(ConfigQuery<T> query) {
+        return query.query(this);
+    }
+
+    @Override
+    public ConfigurationContext getContext() {
+        return this.configurationContext;
+    }
+
+    @Override
+    public String toString() {
+        return "Configuration{\n " +
+                configurationContext +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java
new file mode 100644
index 0000000..f1c0f46
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java
@@ -0,0 +1,229 @@
+/*
+ * 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.Configuration;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.*;
+
+import java.util.*;
+
+/**
+ * Default implementation of {@link ConfigurationContextBuilder}.
+ */
+public class DefaultConfigurationBuilder implements ConfigurationBuilder {
+
+    private final ConfigurationContextBuilder contextBuilder;
+
+    /**
+     * Creates a new builder instance.
+     */
+    public DefaultConfigurationBuilder(ConfigurationContextBuilder contextBuilder) {
+        this.contextBuilder = Objects.requireNonNull(contextBuilder);
+    }
+
+    /**
+     * Creates a new builder instance initializing it with the given context.
+     * @param configuration the configuration to be used, not null.
+     */
+    public DefaultConfigurationBuilder(Configuration configuration) {
+        this.contextBuilder = configuration.getContext().toBuilder();
+    }
+
+    /**
+     * Allows to set configuration context during unit tests.
+     */
+    ConfigurationBuilder setConfiguration(Configuration configuration) {
+        this.contextBuilder.setContext(configuration.getContext());
+        return this;
+    }
+
+
+    @Override
+    public ConfigurationBuilder setContext(ConfigurationContext context) {
+        this.contextBuilder.setContext(context);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder addPropertySources(PropertySource... sources){
+        this.contextBuilder.addPropertySources(sources);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder addPropertySources(Collection<PropertySource> sources){
+        this.contextBuilder.addPropertySources(sources);
+        return this;
+    }
+
+    public ConfigurationBuilder addDefaultPropertyFilters() {
+        this.contextBuilder.addDefaultPropertyFilters();
+        return this;
+    }
+
+    public ConfigurationBuilder addDefaultPropertySources() {
+        this.contextBuilder.addDefaultPropertySources();
+        return this;
+    }
+
+    public ConfigurationBuilder addDefaultPropertyConverters() {
+        this.contextBuilder.addDefaultPropertyConverters();
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder removePropertySources(PropertySource... propertySources) {
+        this.contextBuilder.removePropertySources(propertySources);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder removePropertySources(Collection<PropertySource> propertySources) {
+        this.contextBuilder.removePropertySources(propertySources);
+        return this;
+    }
+
+    @Override
+    public List<PropertySource> getPropertySources() {
+        return this.contextBuilder.getPropertySources();
+    }
+
+    @Override
+    public ConfigurationBuilder increasePriority(PropertySource propertySource) {
+        this.contextBuilder.increasePriority(propertySource);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder decreasePriority(PropertySource propertySource) {
+        this.contextBuilder.decreasePriority(propertySource);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder highestPriority(PropertySource propertySource) {
+        this.contextBuilder.highestPriority(propertySource);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder lowestPriority(PropertySource propertySource) {
+        this.contextBuilder.lowestPriority(propertySource);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder addPropertyFilters(PropertyFilter... filters){
+        this.contextBuilder.addPropertyFilters(filters);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder addPropertyFilters(Collection<PropertyFilter> filters){
+        this.contextBuilder.addPropertyFilters(filters);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder removePropertyFilters(PropertyFilter... filters) {
+        this.contextBuilder.removePropertyFilters(filters);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder removePropertyFilters(Collection<PropertyFilter> filters) {
+        this.contextBuilder.removePropertyFilters(filters);
+        return this;
+    }
+
+
+    @Override
+    public <T> ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                    PropertyConverter<T>... converters) {
+        this.contextBuilder.removePropertyConverters(typeToConvert, converters);
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
+                                                                    Collection<PropertyConverter<T>> converters) {
+        this.contextBuilder.removePropertyConverters(typeToConvert, converters);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder removePropertyConverters(TypeLiteral<?> typeToConvert) {
+        this.contextBuilder.removePropertyConverters(typeToConvert);
+        return this;
+    }
+
+
+    @Override
+    public ConfigurationBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy combinationPolicy){
+        this.contextBuilder.setPropertyValueCombinationPolicy(combinationPolicy);
+        return this;
+    }
+
+
+    @Override
+    public <T> ConfigurationBuilder addPropertyConverters(TypeLiteral<T> type, PropertyConverter<T>... propertyConverters){
+        this.contextBuilder.addPropertyConverters(type, propertyConverters);
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationBuilder addPropertyConverters(TypeLiteral<T> type, Collection<PropertyConverter<T>> propertyConverters){
+        this.contextBuilder.addPropertyConverters(type, propertyConverters);
+        return this;
+    }
+
+    /**
+     * Builds a new configuration based on the configuration of this builder instance.
+     *
+     * @return a new {@link org.apache.tamaya.Configuration configuration instance},
+     *         never {@code null}.
+     */
+    @Override
+    public Configuration build() {
+        return new DefaultConfiguration(this.contextBuilder.build());
+    }
+
+    @Override
+    public ConfigurationBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator) {
+        this.contextBuilder.sortPropertyFilter(comparator);
+        return this;
+    }
+
+    @Override
+    public ConfigurationBuilder sortPropertySources(Comparator<PropertySource> comparator) {
+        this.contextBuilder.sortPropertySources(comparator);
+        return this;
+    }
+
+    @Override
+    public List<PropertyFilter> getPropertyFilters() {
+        return this.contextBuilder.getPropertyFilters();
+    }
+
+    @Override
+    public Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter() {
+        return this.contextBuilder.getPropertyConverter();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultServiceContext.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultServiceContext.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultServiceContext.java
new file mode 100644
index 0000000..61819f9
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultServiceContext.java
@@ -0,0 +1,204 @@
+/*
+ * 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.ConfigException;
+import org.apache.tamaya.spi.ServiceContext;
+
+import javax.annotation.Priority;
+import java.io.IOException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This class implements the (default) {@link ServiceContext} interface and hereby uses the JDK
+ * {@link ServiceLoader} to load the services required.
+ */
+public final class DefaultServiceContext implements ServiceContext {
+    private static final Logger LOG = Logger.getLogger(DefaultServiceContext.class.getName());
+    /**
+     * List current services loaded, per class.
+     */
+    private final ConcurrentHashMap<Class<?>, List<Object>> servicesLoaded = new ConcurrentHashMap<>();
+    /**
+     * Singletons.
+     */
+    private final Map<Class<?>, Object> singletons = new ConcurrentHashMap<>();
+    @SuppressWarnings("rawtypes")
+	private Map<Class, Class> factoryTypes = new ConcurrentHashMap<>();
+
+    @Override
+    public <T> T getService(Class<T> serviceType) {
+        Object cached = singletons.get(serviceType);
+        if (cached == null) {
+            cached = create(serviceType);
+            if(cached!=null) {
+                singletons.put(serviceType, cached);
+            }
+        }
+        return serviceType.cast(cached);
+    }
+
+    @Override
+    public <T> T create(Class<T> serviceType) {
+        @SuppressWarnings("unchecked")
+		Class<? extends T> implType = factoryTypes.get(serviceType);
+        if(implType==null) {
+            Collection<T> services = getServices(serviceType);
+            if (services.isEmpty()) {
+                return null;
+            } else {
+                return getServiceWithHighestPriority(services, serviceType);
+            }
+        }
+        try {
+            return implType.newInstance();
+        } catch (Exception e) {
+            LOG.log(Level.SEVERE, "Failed to create instance of " + implType.getName(), e);
+            return  null;
+        }
+    }
+
+    /**
+     * Loads and registers services.
+     *
+     * @param <T>         the concrete type.
+     * @param serviceType The service type.
+     * @return the items found, never {@code null}.
+     */
+    @Override
+    public <T> List<T> getServices(final Class<T> serviceType) {
+        @SuppressWarnings("unchecked")
+		List<T> found = (List<T>) servicesLoaded.get(serviceType);
+        if (found != null) {
+            return found;
+        }
+        List<T> services = new ArrayList<>();
+        try {
+            for (T t : ServiceLoader.load(serviceType)) {
+                services.add(t);
+            }
+            if(services.isEmpty()) {
+                for (T t : ServiceLoader.load(serviceType, serviceType.getClassLoader())) {
+                    services.add(t);
+                }
+            }
+            Collections.sort(services, PriorityServiceComparator.getInstance());
+            services = Collections.unmodifiableList(services);
+        } catch (ServiceConfigurationError e) {
+            LOG.log(Level.WARNING,
+                    "Error loading services current type " + serviceType, e);
+            if(services==null){
+                services = Collections.emptyList();
+            }
+        }
+        @SuppressWarnings("unchecked")
+		final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>) services));
+        return previousServices != null ? previousServices : services;
+    }
+
+    /**
+     * Checks the given instance for a @Priority annotation. If present the annotation's value is evaluated. If no such
+     * annotation is present, a default priority of {@code 1} is returned.
+     * @param o the instance, not {@code null}.
+     * @return a priority, by default 1.
+     */
+    public static int getPriority(Object o){
+        int prio = 1; //X TODO discuss default priority
+        Priority priority = o.getClass().getAnnotation(Priority.class);
+        if (priority != null) {
+            prio = priority.value();
+        }
+        return prio;
+    }
+
+    /**
+     * @param services to scan
+     * @param <T>      type of the service
+     *
+     * @return the service with the highest {@link Priority#value()}
+     *
+     * @throws ConfigException if there are multiple service implementations with the maximum priority
+     */
+    private <T> T getServiceWithHighestPriority(Collection<T> services, Class<T> serviceType) {
+        T highestService = null;
+        // we do not need the priority stuff if the list contains only one element
+        if (services.size() == 1) {
+            highestService = services.iterator().next();
+            this.factoryTypes.put(serviceType, highestService.getClass());
+            return highestService;
+        }
+
+        Integer highestPriority = null;
+        int highestPriorityServiceCount = 0;
+
+        for (T service : services) {
+            int prio = getPriority(service);
+            if (highestPriority == null || highestPriority < prio) {
+                highestService = service;
+                highestPriorityServiceCount = 1;
+                highestPriority = prio;
+            } else if (highestPriority == prio) {
+                highestPriorityServiceCount++;
+            }
+        }
+
+        if (highestPriorityServiceCount > 1) {
+            throw new ConfigException(MessageFormat.format("Found {0} implementations for Service {1} with Priority {2}: {3}",
+                                                           highestPriorityServiceCount,
+                                                           serviceType.getName(),
+                                                           highestPriority,
+                                                           services));
+        }
+        this.factoryTypes.put(serviceType, highestService.getClass());
+        return highestService;
+    }
+
+    @Override
+    public int ordinal() {
+        return 1;
+    }
+
+    @Override
+    public Enumeration<URL> getResources(String resource, ClassLoader cl) throws IOException {
+        if(cl==null){
+            cl = Thread.currentThread().getContextClassLoader();
+        }
+        if(cl==null){
+            cl = getClass().getClassLoader();
+        }
+        return cl.getResources(resource);
+    }
+
+    @Override
+    public URL getResource(String resource, ClassLoader cl) {
+        if(cl==null){
+            cl = Thread.currentThread().getContextClassLoader();
+        }
+        if(cl==null){
+            cl = getClass().getClassLoader();
+        }
+        return cl.getResource(resource);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
new file mode 100644
index 0000000..ed5214a
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
@@ -0,0 +1,83 @@
+/*
+ * 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.ConfigException;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.osgi.service.component.annotations.Component;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Converter, converting from String to tge given enum type.
+ */
+@Component(service = PropertyConverter.class)
+public class EnumConverter<T> implements PropertyConverter<T> {
+    private final Logger LOG = Logger.getLogger(EnumConverter.class.getName());
+    private Class<T> enumType;
+    private Method factory;
+
+    public EnumConverter(Class<T> enumType) {
+        if (!Enum.class.isAssignableFrom(enumType)) {
+            throw new IllegalArgumentException("Not an Enum: " + enumType.getName());
+        }
+        this.enumType = Objects.requireNonNull(enumType);
+        try {
+            this.factory = enumType.getMethod("valueOf", String.class);
+        } catch (NoSuchMethodException e) {
+            throw new ConfigException("Uncovertible enum type without valueOf method found, please provide a custom " +
+                    "PropertyConverter for: " + enumType.getName());
+        }
+    }
+
+    @Override
+    public T convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(),"<enumValue>");
+        try {
+            return (T) factory.invoke(null, value);
+        } catch (InvocationTargetException | IllegalAccessException e) {
+            LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
+        }
+        try {
+            return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH));
+        } catch (InvocationTargetException | IllegalAccessException e) {
+            LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
+        }
+        return null;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof EnumConverter)) return false;
+        EnumConverter<?> that = (EnumConverter<?>) o;
+        return Objects.equals(enumType, that.enumType);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(enumType);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java
new file mode 100644
index 0000000..dbef51f
--- /dev/null
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java
@@ -0,0 +1,84 @@
+/*
+ * 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 javax.annotation.Priority;
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * Comparator implementation for odering services loaded based on their increasing priority values.
+ */
+public class PriorityServiceComparator implements Comparator<Object>, Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final PriorityServiceComparator INSTANCE = new PriorityServiceComparator();
+
+    /** Singleton constructor. */
+    private PriorityServiceComparator(){}
+
+    /**
+     * Get the shared instance of the comparator.
+     * @return the shared instance, never null.
+     */
+    public static PriorityServiceComparator getInstance(){
+        return INSTANCE;
+    }
+
+    @Override
+    public int compare(Object o1, Object o2) {
+        int prio = getPriority(o1) - getPriority(o2);
+        if (prio < 0) {
+            return 1;
+        } else if (prio > 0) {
+            return -1;
+        } else {
+            return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
+        }
+    }
+
+    /**
+     * Checks the given instance for a @Priority annotation. If present the annotation's value is evaluated. If no such
+     * annotation is present, a default priority {@code 1} is returned.
+     *
+     * @param o the instance, not {@code null}.
+     * @return a priority, by default 1.
+     */
+    public static int getPriority(Object o) {
+        return getPriority(o.getClass());
+    }
+
+    /**
+     * Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
+     * If no such annotation is present, a default priority {@code 1} is returned.
+     *
+     * @param type the type, not {@code null}.
+     * @return a priority, by default 1.
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    public static int getPriority(Class type) {
+        int prio = 1;
+		Priority priority = (Priority)type.getAnnotation(Priority.class);
+        if (priority != null) {
+            prio = priority.value();
+        }
+        return prio;
+    }
+}


[08/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.


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

Branch: refs/heads/master
Commit: 62c38d62adda757ce6ac7628efac01e254167b97
Parents: 7917a9f
Author: Anatole Tresch <an...@apache.org>
Authored: Mon Nov 13 16:53:01 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Mon Nov 13 16:53:01 2017 +0100

----------------------------------------------------------------------
 .../internal/DefaultJavaConfigurationTest.java  | 50 +++++++++++++++++
 .../internal/converters/EnumConverterTest.java  | 52 ------------------
 .../provider/JavaConfigurationProviderTest.java | 58 --------------------
 code/spi-support/pom.xml                        |  4 ++
 .../tamaya/spisupport/EnumConverterTest.java    | 52 ++++++++++++++++++
 .../JavaConfigurationProviderTest.java          | 46 ++++++++++++++++
 .../META-INF/javaconfiguration.properties       | 22 ++++++++
 .../resources/META-INF/javaconfiguration.xml    | 25 +++++++++
 8 files changed, 199 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java
new file mode 100644
index 0000000..a1d638f
--- /dev/null
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java
@@ -0,0 +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.internal;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import static org.apache.tamaya.ConfigurationProvider.getConfiguration;
+
+public class DefaultJavaConfigurationTest {
+
+    private static final String A_UMLAUT = "\u00E4";
+    private static final String O_UMLAUT = "\u00F6";
+
+    @Test
+    public void loadsSimpleAndXMLPropertyFilesProper() {
+        for (int i = 1; i < 6; i++) {
+            String key = "confkey" + i;
+            String value = "javaconf-value" + i;
+            // check if we had our key in configuration.current
+            MatcherAssert.assertThat(getConfiguration().getProperties().containsKey(key), Matchers.is(true));
+            MatcherAssert.assertThat(value, Matchers.equalTo(getConfiguration().get(key)));
+        }
+
+        MatcherAssert.assertThat(getConfiguration().getProperties().containsKey("aaeehh"), Matchers.is(true));
+        MatcherAssert.assertThat(getConfiguration().getProperties().get("aaeehh"), Matchers.equalTo(A_UMLAUT));
+
+        MatcherAssert.assertThat(getConfiguration().getProperties().containsKey(O_UMLAUT), Matchers.is(true));
+        MatcherAssert.assertThat(getConfiguration().getProperties().get(O_UMLAUT), Matchers.equalTo("o"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
deleted file mode 100644
index 0bbc710..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
+++ /dev/null
@@ -1,52 +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.core.internal.converters;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.junit.Test;
-
-import java.math.RoundingMode;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- * Test class testing the {@link EnumConverter} class.
- */
-public class EnumConverterTest {
-
-	private final EnumConverter<RoundingMode> testConverter = new EnumConverter<>(RoundingMode.class);
-
-	private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder("someKey", TypeLiteral.of(Enum.class))
-			.build();
-
-	@Test
-	public void testConversionWithMixedCasing() {
-		for (String input : Arrays.asList(RoundingMode.CEILING.toString(), "ceiling", "CeiLinG")) {
-			assertEquals(RoundingMode.CEILING, testConverter.convert(input, DUMMY_CONTEXT));
-		}
-	}
-
-	@Test
-	public void testConvert_OtherValue() {
-		assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java b/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
deleted file mode 100644
index f7c7f7c..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
+++ /dev/null
@@ -1,58 +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.core.provider;
-
-import org.apache.tamaya.core.propertysource.JavaConfigurationPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.apache.tamaya.ConfigurationProvider.getConfiguration;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-
-public class JavaConfigurationProviderTest {
-
-    private static final String A_UMLAUT = "\u00E4";
-    private static final String O_UMLAUT = "\u00F6";
-
-    @Test
-    public void loadsSimpleAndXMLPropertyFilesProper() {
-        PropertySource propertySource = new JavaConfigurationPropertySource();
-        assertThat(propertySource.getProperties().keySet(), hasSize(7));  // double the size for .source values.
-
-        for (int i = 1; i < 6; i++) {
-            String key = "confkey" + i;
-            String value = "javaconf-value" + i;
-
-            assertThat(value, equalTo(propertySource.get(key).getValue()));
-
-            // check if we had our key in configuration.current
-            assertThat(getConfiguration().getProperties().containsKey(key), is(true));
-            assertThat(value, equalTo(getConfiguration().get(key)));
-        }
-
-        assertThat(getConfiguration().getProperties().containsKey("aaeehh"), is(true));
-        assertThat(getConfiguration().getProperties().get("aaeehh"), equalTo(A_UMLAUT));
-
-        assertThat(getConfiguration().getProperties().containsKey(O_UMLAUT), is(true));
-        assertThat(getConfiguration().getProperties().get(O_UMLAUT), equalTo("o"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/pom.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/pom.xml b/code/spi-support/pom.xml
index bbefa89..e602199 100644
--- a/code/spi-support/pom.xml
+++ b/code/spi-support/pom.xml
@@ -61,6 +61,10 @@ under the License.
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
new file mode 100644
index 0000000..8391c3a
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.junit.Test;
+
+import java.math.RoundingMode;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Test class testing the {@link EnumConverter} class.
+ */
+public class EnumConverterTest {
+
+	private final EnumConverter<RoundingMode> testConverter = new EnumConverter<>(RoundingMode.class);
+
+	private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder("someKey", TypeLiteral.of(Enum.class))
+			.build();
+
+	@Test
+	public void testConversionWithMixedCasing() {
+		for (String input : Arrays.asList(RoundingMode.CEILING.toString(), "ceiling", "CeiLinG")) {
+			assertEquals(RoundingMode.CEILING, testConverter.convert(input, DUMMY_CONTEXT));
+		}
+	}
+
+	@Test
+	public void testConvert_OtherValue() {
+		assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
new file mode 100644
index 0000000..0e363b9
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import static org.apache.tamaya.ConfigurationProvider.getConfiguration;
+
+public class JavaConfigurationProviderTest {
+
+    private static final String A_UMLAUT = "\u00E4";
+    private static final String O_UMLAUT = "\u00F6";
+
+    @Test
+    public void loadsSimpleAndXMLPropertyFilesProper() {
+        PropertySource propertySource = new JavaConfigurationPropertySource();
+        MatcherAssert.assertThat(propertySource.getProperties().keySet(), Matchers.hasSize(7));  // double the size for .source values.
+
+        for (int i = 1; i < 6; i++) {
+            String key = "confkey" + i;
+            String value = "javaconf-value" + i;
+
+            MatcherAssert.assertThat(value, Matchers.equalTo(propertySource.get(key).getValue()));
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties b/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties
new file mode 100644
index 0000000..33beabb
--- /dev/null
+++ b/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties
@@ -0,0 +1,22 @@
+# 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.
+
+confkey1=javaconf-value1
+confkey2=javaconf-value2
+confkey3=javaconf-value3
+confkey4=javaconf-value4
+confkey5=javaconf-value5

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml b/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml
new file mode 100644
index 0000000..f6cdc97
--- /dev/null
+++ b/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <entry key="aaeehh">ä</entry>
+    <entry key="ö">o</entry>
+</properties>


[07/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.

Posted by an...@apache.org.
TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.


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

Branch: refs/heads/master
Commit: 7917a9f38e4087814ea1987395cb48edff7dfe2c
Parents: 353817c
Author: Anatole Tresch <an...@apache.org>
Authored: Mon Nov 13 16:40:43 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Mon Nov 13 16:40:45 2017 +0100

----------------------------------------------------------------------
 code/core/pom.xml                               |   5 +
 .../org/apache/tamaya/core/OSGIActivator.java   |   4 +
 .../internal/DefaultConfigValueEvaluator.java   |  72 ---
 .../core/internal/DefaultConfiguration.java     | 245 ----------
 .../internal/DefaultConfigurationContext.java   |  73 ++-
 .../DefaultConfigurationContextBuilder.java     | 101 ++--
 .../internal/DefaultConfigurationProvider.java  |   1 +
 .../core/internal/DefaultServiceContext.java    |   1 +
 .../tamaya/core/internal/OSGIServiceLoader.java |   1 +
 .../internal/PriorityServiceComparator.java     |  81 ----
 .../core/internal/PropertyConverterManager.java | 464 ------------------
 .../core/internal/PropertyFilterComparator.java |  73 ---
 .../tamaya/core/internal/PropertyFiltering.java | 125 -----
 .../core/internal/PropertySourceComparator.java |  86 ----
 .../tamaya/core/internal/ReflectionUtil.java    |  42 --
 .../core/internal/WrappedPropertySource.java    | 125 -----
 .../core/internal/converters/ConvertQuery.java  |  68 +++
 .../core/internal/converters/EnumConverter.java |  83 ----
 .../core/internal/converters/FileConverter.java |   1 -
 .../converters/OffsetDateTimeConverter.java     |   1 -
 .../converters/OffsetTimeConverter.java         |   1 -
 .../internal/converters/OptionalConverter.java  |  42 --
 .../core/internal/converters/PathConverter.java |   3 -
 .../internal/converters/SupplierConverter.java  |  71 +++
 .../core/propertysource/BasePropertySource.java | 162 -------
 .../core/propertysource/CLIPropertySource.java  | 131 ------
 .../EnvironmentPropertySource.java              | 293 ------------
 .../JavaConfigurationPropertySource.java        | 136 ------
 .../propertysource/SimplePropertySource.java    | 140 ------
 .../propertysource/SystemPropertySource.java    | 190 --------
 .../core/propertysource/package-info.java       |  23 -
 .../org.apache.tamaya.spi.PropertyConverter     |   1 +
 .../org.apache.tamaya.spi.PropertySource        |   8 +-
 .../core/ConfigurationContextBuilderTest.java   |   2 +-
 .../DefaultConfigurationContextTest.java        |   1 -
 .../core/internal/DefaultConfigurationTest.java | 201 --------
 .../internal/PriorityServiceComparatorTest.java |  45 --
 .../internal/PropertyConverterManagerTest.java  | 182 -------
 .../internal/PropertyFilterComparatorTest.java  |  75 ---
 .../propertysource/BasePropertySourceTest.java  | 136 ------
 .../propertysource/CLIPropertySourceTest.java   |  58 ---
 .../EnvironmentPropertySourceTest.java          | 180 -------
 .../PropertiesFilePropertySourceTest.java       |  59 ---
 .../SimplePropertySourceTest.java               |  89 ----
 .../SystemPropertySourceTest.java               |  91 ----
 .../testdata/TestPropertyDefaultSource.java     |   2 +-
 .../testdata/TestPropertySourceProvider.java    |   2 +-
 .../org.apache.tamaya.spi.PropertySource        |   4 +-
 code/pom.xml                                    |   1 +
 code/spi-support/pom.xml                        |  81 ++++
 .../tamaya/spisupport/ConfigValueEvaluator.java |  48 ++
 .../tamaya/spisupport/ConfigurationBuilder.java | 334 +++++++++++++
 .../spisupport/DefaultConfigValueEvaluator.java |  70 +++
 .../tamaya/spisupport/DefaultConfiguration.java | 268 +++++++++++
 .../spisupport/DefaultConfigurationBuilder.java | 229 +++++++++
 .../spisupport/DefaultServiceContext.java       | 204 ++++++++
 .../apache/tamaya/spisupport/EnumConverter.java |  83 ++++
 .../spisupport/PriorityServiceComparator.java   |  84 ++++
 .../spisupport/PropertyConverterManager.java    | 471 +++++++++++++++++++
 .../spisupport/PropertyFilterComparator.java    |  72 +++
 .../tamaya/spisupport/PropertyFiltering.java    | 124 +++++
 .../spisupport/PropertySourceComparator.java    | 122 +++++
 .../tamaya/spisupport/ReflectionUtil.java       |  42 ++
 .../tamaya/spisupport/RegexPropertyFilter.java  |  84 ++++
 .../propertysource/BasePropertySource.java      | 173 +++++++
 .../propertysource/BuildablePropertySource.java | 231 +++++++++
 .../BuildablePropertySourceProvider.java        | 114 +++++
 .../propertysource/CLIPropertySource.java       | 137 ++++++
 .../EnvironmentPropertySource.java              | 287 +++++++++++
 .../JavaConfigurationPropertySource.java        | 134 ++++++
 .../propertysource/MapPropertySource.java       | 102 ++++
 .../PropertiesResourcePropertySource.java       | 109 +++++
 .../propertysource/SimplePropertySource.java    | 284 +++++++++++
 .../propertysource/SystemPropertySource.java    | 199 ++++++++
 .../propertysource/WrappedPropertySource.java   | 126 +++++
 .../spisupport/propertysource/package-info.java |  23 +
 .../java/org/apache/tamaya/spisupport/A.java    |  29 ++
 .../java/org/apache/tamaya/spisupport/B.java    |  29 ++
 .../BuildablePropertySourceProviderTest.java    |  78 +++
 .../spisupport/BuildablePropertySourceTest.java |  89 ++++
 .../java/org/apache/tamaya/spisupport/C.java    |  56 +++
 .../tamaya/spisupport/CTestConverter.java       |  32 ++
 .../spisupport/DefaultConfigurationTest.java    | 201 ++++++++
 .../spisupport/EmptyConfigurationContext.java   |  78 +++
 .../EmptyConfigurationContextBuilder.java       | 174 +++++++
 .../PriorityServiceComparatorTest.java          |  44 ++
 .../PropertyConverterManagerTest.java           | 180 +++++++
 .../PropertyFilterComparatorTest.java           |  76 +++
 .../spisupport/RegexPropertyFilterTest.java     |  70 +++
 .../propertysource/BasePropertySourceTest.java  | 136 ++++++
 .../propertysource/CLIPropertySourceTest.java   |  59 +++
 .../propertysource/EnumConverterTest.java       |  60 +++
 .../EnvironmentPropertySourceTest.java          |  68 +++
 .../propertysource/MapPropertySourceTest.java   |  76 +++
 .../PropertiesFilePropertySourceTest.java       |  60 +++
 .../SimplePropertySourceTest.java               |  89 ++++
 .../SystemPropertySourceTest.java               |  91 ++++
 .../TestPropertyDefaultSource.java              |  57 +++
 .../services/DefaultServiceContext.java         | 205 ++++++++
 .../org.apache.tamaya.spi.PropertyConverter     |  19 +
 .../org.apache.tamaya.spi.ServiceContext        |  19 +
 .../src/test/resources/invalid-properties.xml   |  25 +
 .../src/test/resources/non-xml-properties.xml   |  18 +
 .../test/resources/overrideOrdinal.properties   |  25 +
 .../src/test/resources/testfile.properties      |  22 +
 .../src/test/resources/valid-properties.xml     |  25 +
 .../apache/tamaya/examples/minimal/Main.java    |   4 +-
 .../examples/minimal/TestConfigProvider.java    |   2 +-
 .../SimplePropertySource.java                   |   2 +-
 .../SimplePropertySourceProvider.java           |   2 +-
 .../tamaya/examples/distributed/Display.java    |   4 +-
 .../examples/distributed/DisplayManager.java    |   4 +-
 112 files changed, 6703 insertions(+), 3721 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/pom.xml
----------------------------------------------------------------------
diff --git a/code/core/pom.xml b/code/core/pom.xml
index 0c57c6d..2d98631 100644
--- a/code/core/pom.xml
+++ b/code/core/pom.xml
@@ -40,6 +40,11 @@ under the License.
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-spisupport</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java b/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
index 46355f3..09bf384 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java
@@ -23,6 +23,10 @@ package org.apache.tamaya.core;
 import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.core.internal.*;
 import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.spisupport.DefaultConfiguration;
+import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder;
+import org.apache.tamaya.spisupport.PropertyFilterComparator;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigValueEvaluator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigValueEvaluator.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigValueEvaluator.java
deleted file mode 100644
index 4d8a7f3..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigValueEvaluator.java
+++ /dev/null
@@ -1,72 +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.core.internal;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.osgi.service.component.annotations.Component;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * Implementation of the Configuration API. This class uses the current {@link ConfigurationContext} to evaluate the
- * chain of {@link PropertySource} and {@link PropertyFilter}
- * instance to evaluate the current Configuration.
- */
-@Component(service = ConfigValueEvaluator.class)
-public class DefaultConfigValueEvaluator implements ConfigValueEvaluator{
-
-    @Override
-    public PropertyValue evaluteRawValue(String key, ConfigurationContext context) {
-        PropertyValue unfilteredValue = null;
-        for (PropertySource propertySource : context.getPropertySources()) {
-            unfilteredValue = context.getPropertyValueCombinationPolicy().
-                    collect(unfilteredValue, key, propertySource);
-        }
-        if(unfilteredValue==null || unfilteredValue.getValue()==null){
-            return null;
-        }
-        return unfilteredValue;
-    }
-
-    @Override
-    public Map<String, PropertyValue> evaluateRawValues(ConfigurationContext context) {
-        Map<String, PropertyValue> result = new HashMap<>();
-        for (PropertySource propertySource : context.getPropertySources()) {
-            for (Map.Entry<String,PropertyValue> propEntry: propertySource.getProperties().entrySet()) {
-                PropertyValue unfilteredValue = result.get(propEntry.getKey());
-                unfilteredValue = context.getPropertyValueCombinationPolicy().
-                        collect(unfilteredValue, propEntry.getKey(), propertySource);
-                if(unfilteredValue!=null){
-                    result.put(unfilteredValue.getKey(), unfilteredValue);
-                }
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "DefaultConfigEvaluator{}";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
deleted file mode 100644
index 1c22e44..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
+++ /dev/null
@@ -1,245 +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.core.internal;
-
-import org.apache.tamaya.ConfigException;
-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.*;
-import org.osgi.service.component.annotations.Component;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-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 PropertySource} and {@link PropertyFilter}
- * instance to evaluate the current Configuration.
- */
-@Component(service = Configuration.class)
-public class DefaultConfiguration implements Configuration {
-    /**
-     * The logger.
-     */
-    private static final Logger LOG = Logger.getLogger(DefaultConfiguration.class.getName());
-
-    /**
-     * The current {@link ConfigurationContext} of the current instance.
-     */
-    private final ConfigurationContext configurationContext;
-
-    /**
-     * EvaluationStrategy
-     */
-    private ConfigValueEvaluator configEvaluator = loadConfigValueEvaluator();
-
-    private ConfigValueEvaluator loadConfigValueEvaluator() {
-        ConfigValueEvaluator eval = null;
-        try{
-            eval = ServiceContextManager.getServiceContext()
-                    .getService(ConfigValueEvaluator.class);
-        }catch(Exception e){
-            LOG.log(Level.WARNING, "Failed to load ConfigValueEvaluator from ServiceContext, using default.", e);
-        }
-        if(eval==null){
-            eval = new DefaultConfigValueEvaluator();
-        }
-        return eval;
-    }
-
-
-    /**
-     * Constructor.
-     * @param configurationContext The configuration Context to be used.
-     */
-    public DefaultConfiguration(ConfigurationContext configurationContext){
-        this.configurationContext = Objects.requireNonNull(configurationContext);
-    }
-
-    @Override
-    public String get(String key) {
-        Objects.requireNonNull(key, "Key must not be null.");
-
-        PropertyValue value = configEvaluator.evaluteRawValue(key, configurationContext);
-        if(value==null){
-            return null;
-        }
-        value = PropertyFiltering.applyFilter(value, configurationContext);
-        if(value!=null){
-            return value.getValue();
-        }
-        return null;
-    }
-
-
-    @Override
-    public String getOrDefault(String key, String defaultValue) {
-        Objects.requireNonNull(key, "Key must not be null.");
-        Objects.requireNonNull(defaultValue, "Default value must not be null");
-
-        String val = get(key);
-        if(val==null){
-            return defaultValue;
-        }
-        return val;
-    }
-
-    @Override
-    public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
-        Objects.requireNonNull(key, "Key must not be null.");
-        Objects.requireNonNull(type, "Target type must not be null");
-        Objects.requireNonNull(defaultValue, "Default value must not be null");
-
-        T val = get(key, type);
-        if(val==null){
-            return defaultValue;
-        }
-        return val;
-    }
-
-    /**
-     * Get the current properties, composed by the loaded {@link PropertySource} and filtered
-     * by registered {@link PropertyFilter}.
-     *
-     * @return the final properties.
-     */
-    @Override
-    public Map<String, String> getProperties() {
-        Map<String, PropertyValue> filtered = PropertyFiltering.applyFilters(
-                configEvaluator.evaluateRawValues(configurationContext),
-                configurationContext);
-        Map<String,String> result = new HashMap<>();
-        for(PropertyValue val:filtered.values()){
-            if(val.getValue()!=null) {
-                result.put(val.getKey(), val.getValue());
-                // TODO: Discuss metadata handling...
-                result.putAll(val.getMetaEntries());
-            }
-        }
-        return result;
-    }
-
-
-    /**
-     * Accesses the current String value for the given key and tries to convert it
-     * using the {@link PropertyConverter} instances provided by the current
-     * {@link ConfigurationContext}.
-     *
-     * @param key  the property's absolute, or relative path, e.g. @code
-     *             a/b/c/d.myProperty}, never {@code null}.
-     * @param type The target type required, not {@code null}.
-     * @param <T>  the value type
-     * @return the converted value, never {@code null}.
-     */
-    @SuppressWarnings("unchecked")
-	@Override
-    public <T> T get(String key, Class<T> type) {
-        Objects.requireNonNull(key, "Key must not be null.");
-        Objects.requireNonNull(type, "Target type must not be null");
-
-        return get(key, (TypeLiteral<T>)TypeLiteral.of(type));
-    }
-
-    /**
-     * Accesses the current String value for the given key and tries to convert it
-     * using the {@link PropertyConverter} instances provided by the current
-     * {@link ConfigurationContext}.
-     *
-     * @param key  the property's absolute, or relative path, e.g. @code
-     *             a/b/c/d.myProperty}.
-     * @param type The target type required, not {@code null}.
-     * @param <T>  the value type
-     * @return the converted value, never {@code null}.
-     */
-    @Override
-    public <T> T get(String key, TypeLiteral<T> type) {
-        Objects.requireNonNull(key, "Key must not be null.");
-        Objects.requireNonNull(type, "Target type must not be null");
-
-        return convertValue(key, get(key), type);
-    }
-
-    @SuppressWarnings("unchecked")
-	protected <T> T convertValue(String key, String value, TypeLiteral<T> type) {
-        if (value != null) {
-            List<PropertyConverter<T>> converters = configurationContext.getPropertyConverters(type);
-            ConversionContext context = new ConversionContext.Builder(this, this.configurationContext, key, type)
-                    .build();
-            for (PropertyConverter<T> converter : converters) {
-                try {
-                    T t = converter.convert(value, context);
-                    if (t != null) {
-                        return t;
-                    }
-                } catch (Exception e) {
-                    LOG.log(Level.INFO, "PropertyConverter: " + converter + " failed to convert value: " + value, e);
-                }
-            }
-            // if the target type is a String, we can return the value, no conversion required.
-            if(type.equals(TypeLiteral.of(String.class))){
-                return (T)value;
-            }
-            // unsupported type, throw an exception
-            throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
-                    ", supported formats: " + context.getSupportedFormats());
-        }
-        return null;
-    }
-
-    @Override
-    public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
-        Objects.requireNonNull(key);
-        Objects.requireNonNull(type);
-        Objects.requireNonNull(defaultValue);
-
-        T val = get(key, type);
-        if(val==null){
-            return defaultValue;
-        }
-        return val;
-    }
-
-    @Override
-    public Configuration with(ConfigOperator operator) {
-        return operator.operate(this);
-    }
-
-    @Override
-    public <T> T query(ConfigQuery<T> query) {
-        return query.query(this);
-    }
-
-    @Override
-    public ConfigurationContext getContext() {
-        return this.configurationContext;
-    }
-
-    @Override
-    public String toString() {
-        return "Configuration{\n " +
-                configurationContext +
-                '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
index 9645681..95ebbca 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
@@ -1,24 +1,23 @@
 /*
  * 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
+ *  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
+ *     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.
+ *  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.internal;
 
-import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.TypeLiteral;
 import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.ConfigurationContextBuilder;
@@ -28,8 +27,15 @@ import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
 import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.*;
+import org.apache.tamaya.spisupport.PropertyConverterManager;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.logging.Logger;
@@ -86,13 +92,17 @@ public class DefaultConfigurationContext implements ConfigurationContext {
                 this.propertyConverterManager.register(en.getKey(), converter);
             }
         }
+        LOG.info("Registered " + propertyConverterManager.getPropertyConverters().size() + " property converters: " +
+                propertyConverterManager.getPropertyConverters());
+
         propertyValueCombinationPolicy = builder.combinationPolicy;
         if(propertyValueCombinationPolicy==null){
             propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
         }
         if(propertyValueCombinationPolicy==null){
-            propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
+            propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
         }
+        LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
     }
 
 
@@ -114,14 +124,24 @@ public class DefaultConfigurationContext implements ConfigurationContext {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof DefaultConfigurationContext)) return false;
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof DefaultConfigurationContext)){
+            return false;
+        }
 
         DefaultConfigurationContext that = (DefaultConfigurationContext) o;
 
-        if (!propertyConverterManager.equals(that.propertyConverterManager)) return false;
-        if (!immutablePropertySources.equals(that.immutablePropertySources)) return false;
-        if (!immutablePropertyFilters.equals(that.immutablePropertyFilters)) return false;
+        if (!propertyConverterManager.equals(that.propertyConverterManager)) {
+            return false;
+        }
+        if (!immutablePropertySources.equals(that.immutablePropertySources)) {
+            return false;
+        }
+        if (!immutablePropertyFilters.equals(that.immutablePropertyFilters)) {
+            return false;
+        }
         return getPropertyValueCombinationPolicy().equals(that.getPropertyValueCombinationPolicy());
 
     }
@@ -143,11 +163,12 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         if(immutablePropertySources.isEmpty()){
             b.append("  No property sources loaded.\n\n");
         }else {
-            b.append("  CLASS                         NAME                                                              SCANNABLE SIZE    STATE     ERROR\n\n");
+            b.append("  CLASS                         NAME                                                                  ORDINAL SCANNABLE SIZE    STATE     ERROR\n\n");
             for (PropertySource ps : immutablePropertySources) {
                 b.append("  ");
                 appendFormatted(b, ps.getClass().getSimpleName(), 30);
                 appendFormatted(b, ps.getName(), 70);
+                appendFormatted(b, String.valueOf(PropertySourceComparator.getOrdinal(ps)), 8);
                 appendFormatted(b, String.valueOf(ps.isScannable()), 10);
                 if (ps.isScannable()) {
                     appendFormatted(b, String.valueOf(ps.getProperties().size()), 8);
@@ -188,7 +209,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         b.append("  -------------------\n");
         b.append("  CLASS                         TYPE                          INFO\n\n");
         for(Map.Entry<TypeLiteral<?>, List<PropertyConverter<?>>> converterEntry:getPropertyConverters().entrySet()){
-            for(PropertyConverter<?> converter: converterEntry.getValue()){
+            for(PropertyConverter converter: converterEntry.getValue()){
                 b.append("  ");
                 appendFormatted(b, converter.getClass().getSimpleName(), 30);
                 appendFormatted(b, converterEntry.getKey().getRawType().getSimpleName(), 30);
@@ -197,7 +218,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
             }
         }
         b.append("\n\n");
-        b.append("  PropertyValueCombinationPolicy: ").append(getPropertyValueCombinationPolicy().getClass().getName()).append('\n');
+        b.append("  PropertyValueCombinationPolicy: " + getPropertyValueCombinationPolicy().getClass().getName()).append('\n');
         b.append('}');
         return b.toString();
     }
@@ -264,7 +285,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
 
     @Override
     public ConfigurationContextBuilder toBuilder() {
-        return ConfigurationProvider.getConfigurationContextBuilder().setContext(this);
+        return new DefaultConfigurationContextBuilder(this);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
index 2ddade6..4cad87d 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
@@ -1,30 +1,24 @@
 /*
  * 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
+ *  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
+ *     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.
+ *  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.internal;
 
-import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.internal.converters.*;
-import org.apache.tamaya.core.propertysource.CLIPropertySource;
-import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.core.propertysource.JavaConfigurationPropertySource;
 import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.PropertyConverter;
@@ -33,10 +27,14 @@ import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertySourceProvider;
 import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
 import org.apache.tamaya.spi.ServiceContextManager;
-import org.osgi.service.component.annotations.Component;
+import org.apache.tamaya.core.internal.converters.*;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
+import org.apache.tamaya.spisupport.propertysource.CLIPropertySource;
+import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource;
+import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
 
 import java.io.File;
-import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.URI;
@@ -46,9 +44,8 @@ import java.util.*;
 import java.util.logging.Logger;
 
 /**
- * Default implementation of {@link org.apache.tamaya.spi.ConfigurationContextBuilder}.
+ * Default implementation of {@link ConfigurationContextBuilder}.
  */
-@Component(service = ConfigurationContextBuilder.class)
 public class DefaultConfigurationContextBuilder implements ConfigurationContextBuilder {
 
     private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextBuilder.class.getName());
@@ -64,6 +61,8 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
      */
     private boolean built;
 
+
+
     /**
      * Creates a new builder instance.
      */
@@ -71,7 +70,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
     }
 
     /**
-     * Creates a new builder instance.
+     * Creates a new builder instance initializing it with the given context.
      * @param context the context to be used, not null.
      */
     public DefaultConfigurationContextBuilder(ConfigurationContext context) {
@@ -101,6 +100,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         return this;
     }
 
+
     @Override
     public ConfigurationContextBuilder setContext(ConfigurationContext context) {
         checkBuilderState();
@@ -134,7 +134,11 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         checkBuilderState();
         List<PropertySource> propertySources = new ArrayList<>();
         addCorePropertyResources(propertySources);
-        propertySources.addAll(ServiceContextManager.getServiceContext().getServices(PropertySource.class));
+        for(PropertySource ps: ServiceContextManager.getServiceContext().getServices(PropertySource.class)) {
+            if(!propertySources.contains(ps)){
+                propertySources.add(ps);
+            }
+        }
         for(PropertySourceProvider provider:
                 ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class)){
                 propertySources.addAll(provider.getPropertySources());
@@ -144,10 +148,16 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
     }
 
     private void addCorePropertyResources(List<PropertySource> propertySources) {
-        propertySources.add(new EnvironmentPropertySource());
-        propertySources.add(new JavaConfigurationPropertySource());
-        propertySources.add(new CLIPropertySource());
-        propertySources.add(new SystemPropertySource());
+        for(PropertySource ps: new PropertySource[]{
+                new EnvironmentPropertySource(),
+                new JavaConfigurationPropertySource(),
+                new CLIPropertySource(),
+                new SystemPropertySource()
+        }){
+            if(!propertySources.contains(ps)){
+                propertySources.add(ps);
+            }
+        }
     }
 
     @Override
@@ -159,8 +169,6 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         return this;
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-	@Override
     public DefaultConfigurationContextBuilder addDefaultPropertyConverters() {
         checkBuilderState();
         addCorePropertyConverters();
@@ -173,7 +181,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
     }
 
     @SuppressWarnings("unchecked")
-	private void addCorePropertyConverters() {
+	protected void addCorePropertyConverters() {
         addPropertyConverters(TypeLiteral.<BigDecimal>of(BigDecimal.class), new BigDecimalConverter());
         addPropertyConverters(TypeLiteral.<BigInteger>of(BigInteger.class), new BigIntegerConverter());
         addPropertyConverters(TypeLiteral.<Boolean>of(Boolean.class), new BooleanConverter());
@@ -205,6 +213,15 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         return this;
     }
 
+    private PropertySource getPropertySource(String name) {
+        for(PropertySource ps:propertySources){
+            if(ps.getName().equals(name)){
+                return ps;
+            }
+        }
+        throw new IllegalArgumentException("No such PropertySource: "+name);
+    }
+
     @Override
     public List<PropertySource> getPropertySources() {
         return this.propertySources;
@@ -317,6 +334,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         return this;
     }
 
+
     @Override
     public ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy combinationPolicy){
         checkBuilderState();
@@ -324,8 +342,9 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         return this;
     }
 
+
     @Override
-    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> type, @SuppressWarnings("unchecked") PropertyConverter<T>... propertyConverters){
+    public <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> type, PropertyConverter<T>... propertyConverters){
         checkBuilderState();
         Objects.requireNonNull(type);
         Objects.requireNonNull(propertyConverters);
@@ -338,7 +357,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
             if (!converters.contains(propertyConverter)) {
                 converters.add(propertyConverter);
             } else {
-                LOG.finer("Converter ignored, already registered: " + propertyConverter);
+                LOG.warning("Converter ignored, already registered: " + propertyConverter);
             }
         }
         return this;
@@ -358,7 +377,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
             if (!converters.contains(propertyConverter)) {
                 converters.add(propertyConverter);
             } else {
-                LOG.finer("Converter ignored, already registered: " + propertyConverter);
+                LOG.warning("Converter ignored, already registered: " + propertyConverter);
             }
         }
         return this;
@@ -366,20 +385,19 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
 
     protected ConfigurationContextBuilder loadDefaults() {
         checkBuilderState();
-        this.combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
+        this.combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
         addDefaultPropertySources();
         addDefaultPropertyFilters();
         addDefaultPropertyConverters();
         return this;
     }
 
-    @SuppressWarnings("rawtypes")
-	private Map<TypeLiteral, Collection<PropertyConverter>> getDefaultPropertyConverters() {
+
+    private Map<TypeLiteral, Collection<PropertyConverter>> getDefaultPropertyConverters() {
         Map<TypeLiteral, Collection<PropertyConverter>> result = new HashMap<>();
         for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(
                 PropertyConverter.class)) {
-            Type type = TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(), PropertyConverter.class)[0];
-            TypeLiteral target = TypeLiteral.of(type);
+            TypeLiteral target = TypeLiteral.of(TypeLiteral.of(conv.getClass()).getType());
             Collection<PropertyConverter> convList = result.get(target);
             if (convList == null) {
                 convList = new ArrayList<>();
@@ -390,10 +408,11 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
         return result;
     }
 
+
     /**
      * Builds a new configuration based on the configuration of this builder instance.
      *
-     * @return a new {@link Configuration configuration instance},
+     * @return a new {@link org.apache.tamaya.Configuration configuration instance},
      *         never {@code null}.
      */
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
index d7abf8b..dd73889 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.Configuration;
 import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.ConfigurationProviderSpi;
+import org.apache.tamaya.spisupport.DefaultConfiguration;
 import org.osgi.service.component.annotations.Component;
 
 import java.util.Objects;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
index 04377e2..372ae2a 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.core.internal;
 
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.spi.ServiceContext;
+import org.apache.tamaya.spisupport.PriorityServiceComparator;
 
 import javax.annotation.Priority;
 import java.io.IOException;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
index 3bf0291..b973d5f 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
@@ -26,6 +26,7 @@ import java.util.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.tamaya.spisupport.PriorityServiceComparator;
 import org.osgi.framework.*;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/PriorityServiceComparator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PriorityServiceComparator.java b/code/core/src/main/java/org/apache/tamaya/core/internal/PriorityServiceComparator.java
deleted file mode 100644
index 3b2ff5a..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PriorityServiceComparator.java
+++ /dev/null
@@ -1,81 +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.core.internal;
-
-import javax.annotation.Priority;
-import java.util.Comparator;
-
-/**
- * Comparator implementation for ordering services loaded based on their increasing priority values.
- */
-public class PriorityServiceComparator implements Comparator<Object> {
-
-    private static final PriorityServiceComparator INSTANCE = new PriorityServiceComparator();
-
-    /** Singleton constructor. */
-    private PriorityServiceComparator(){}
-
-    /**
-     * Get the shared instance of the comparator.
-     * @return the shared instance, never null.
-     */
-    public static PriorityServiceComparator getInstance(){
-        return INSTANCE;
-    }
-
-    @Override
-    public int compare(Object o1, Object o2) {
-        int prio = getPriority(o1) - getPriority(o2);
-        if (prio < 0) {
-            return 1;
-        } else if (prio > 0) {
-            return -1;
-        } else {
-            return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
-        }
-    }
-
-    /**
-     * Checks the given instance for a @Priority annotation. If present the annotation's value is evaluated. If no such
-     * annotation is present, a default priority {@code 1} is returned.
-     *
-     * @param o the instance, not {@code null}.
-     * @return a priority, by default 1.
-     */
-    public static int getPriority(Object o) {
-        return getPriority(o.getClass());
-    }
-
-    /**
-     * Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
-     * If no such annotation is present, a default priority {@code 1} is returned.
-     *
-     * @param type the type, not {@code null}.
-     * @return a priority, by default 1.
-     */
-    @SuppressWarnings({ "rawtypes", "unchecked" }) 
-    public static int getPriority(Class type) {
-        int prio = 1;
-		Priority priority = (Priority)type.getAnnotation(Priority.class);
-        if (priority != null) {
-            prio = priority.value();
-        }
-        return prio;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
deleted file mode 100644
index eb5fa92..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
+++ /dev/null
@@ -1,464 +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.core.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.internal.converters.EnumConverter;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Manager that deals with {@link org.apache.tamaya.spi.PropertyConverter} instances.
- * This class is thread-safe.
- */
-public class PropertyConverterManager {
-    /**
-     * The logger used.
-     */
-    private static final Logger LOG = Logger.getLogger(PropertyConverterManager.class.getName());
-    /**
-     * The registered converters.
-     */
-    private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = new ConcurrentHashMap<>();
-    /**
-     * The transitive converters.
-     */
-    private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> transitiveConverters = new ConcurrentHashMap<>();
-    /**
-     * The lock used.
-     */
-    private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
-    private static final Comparator<Object> PRIORITY_COMPARATOR = new Comparator<Object>() {
-
-        @Override
-        public int compare(Object o1, Object o2) {
-            int prio = DefaultServiceContext.getPriority(o1) - DefaultServiceContext.getPriority(o2);
-            if (prio < 0) {
-                return 1;
-            } else if (prio > 0) {
-                return -1;
-            } else {
-                return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
-            }
-        }
-    };
-
-    /**
-     * Constructor.
-     */
-    public PropertyConverterManager() {
-        this(false);
-    }
-
-    public PropertyConverterManager(boolean init) {
-        if (init) {
-            initConverters();
-        }
-    }
-
-    /**
-     * Registers the default converters provided out of the box.
-     */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected void initConverters() {
-        for ( PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(PropertyConverter.class)) {
-            Type type = TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(), PropertyConverter.class)[0];
-            register(TypeLiteral.of(type), conv);
-        }
-    }
-
-    /**
-     * Registers a new converter instance.
-     *
-     * @param targetType the target type, not {@code null}.
-     * @param converter  the converter, not {@code null}.
-     * @param <T>        the type.
-     */
-    @SuppressWarnings("unchecked")
-    public <T> void register(TypeLiteral<T> targetType, PropertyConverter<T> converter) {
-        Objects.requireNonNull(converter);
-        Lock writeLock = lock.writeLock();
-        try {
-            writeLock.lock();
-			List<PropertyConverter<?>> converters = List.class.cast(this.converters.get(targetType));
-            if(converters!=null && converters.contains(converter)){
-                return;
-            }
-            List<PropertyConverter<?>> newConverters = new ArrayList<>();
-            if (converters != null) {
-                newConverters.addAll(converters);
-            }
-            if(!newConverters.contains(converter)) {
-                newConverters.add(converter);
-            }
-            Collections.sort(newConverters, PRIORITY_COMPARATOR);
-            this.converters.put(targetType, Collections.unmodifiableList(newConverters));
-            // evaluate transitive closure for all inherited supertypes and implemented interfaces
-            // direct implemented interfaces
-            for (Class<?> ifaceType : targetType.getRawType().getInterfaces()) {
-                converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
-                newConverters = new ArrayList<>();
-                if (converters != null) {
-                    newConverters.addAll(converters);
-                }
-                newConverters.add(converter);
-                Collections.sort(newConverters, PRIORITY_COMPARATOR);
-                this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
-            }
-            Class<?> superClass = targetType.getRawType().getSuperclass();
-            while (superClass != null && !superClass.equals(Object.class)) {
-                converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(superClass)));
-                newConverters = new ArrayList<>();
-                if (converters != null) {
-                    newConverters.addAll(converters);
-                }
-                newConverters.add(converter);
-                Collections.sort(newConverters, PRIORITY_COMPARATOR);
-                this.transitiveConverters.put(TypeLiteral.of(superClass), Collections.unmodifiableList(newConverters));
-                for (Class<?> ifaceType : superClass.getInterfaces()) {
-                    converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
-                    newConverters = new ArrayList<>();
-                    if (converters != null) {
-                        newConverters.addAll(converters);
-                    }
-                    newConverters.add(converter);
-                    Collections.sort(newConverters, PRIORITY_COMPARATOR);
-                    this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
-                }
-                superClass = superClass.getSuperclass();
-            }
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    /**
-     * Allows to evaluate if a given target type is supported.
-     *
-     * @param targetType the target type, not {@code null}.
-     * @return true, if a converter for the given type is registered, or a default one can be created.
-     */
-    public boolean isTargetTypeSupported(TypeLiteral<?> targetType) {
-        return converters.containsKey(targetType) || transitiveConverters.containsKey(targetType) || createDefaultPropertyConverter(targetType) != null;
-    }
-
-    /**
-     * Get a map of all property converters currently registered. This will not contain the converters that
-     * may be created, when an instance is adapted, which provides a String constructor or compatible
-     * factory methods taking a single String instance.
-     *
-     * @return the current map of instantiated and registered converters.
-     * @see #createDefaultPropertyConverter(org.apache.tamaya.TypeLiteral)
-     */
-    public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
-        Lock readLock = lock.readLock();
-        try {
-            readLock.lock();
-            return new HashMap<>(this.converters);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    /**
-     * Get the list of all current registered converters for the given target type.
-     * If not converters are registered, they component tries to create and register a dynamic
-     * converter based on String constructor or static factory methods available.
-     * The converters provided are of the following type and returned in the following order:
-     * <ul>
-     * <li>Converters mapped explicitly to the required target type are returned first, ordered
-     * by decreasing priority. This means, if explicit converters are registered these are used
-     * primarily for converting a value.</li>
-     * <li>The target type of each explicitly registered converter also can be transitively mapped to
-     * 1) all directly implemented interfaces, 2) all its superclasses (except Object), 3) all the interfaces
-     * implemented by its superclasses. These groups of transitive converters is returned similarly in the
-     * order as mentioned, whereas also here a priority based decreasing ordering is applied.</li>
-     * <li>java.lang wrapper classes and native types are automatically mapped.</li>
-     * <li>If no explicit converters are registered, for Enum types a default implementation is provided that
-     * compares the configuration values with the different enum members defined (cases sensitive mapping).</li>
-     * </ul>
-     * <p>
-     * So given that list above directly registered mappings always are tried first, before any transitive mapping
-     * should be used. Also in all cases @Priority annotations are honored for ordering of the converters in place.
-     * Transitive conversion is supported for all directly implemented interfaces (including inherited ones) and
-     * the inheritance hierarchy (exception Object). Superinterfaces of implemented interfaces are ignored.
-     *
-     * @param targetType the target type, not {@code null}.
-     * @param <T>        the type class
-     * @return the ordered list of converters (may be empty for not convertible types).
-     * @see #createDefaultPropertyConverter(org.apache.tamaya.TypeLiteral)
-     */
-    @SuppressWarnings("unchecked")
-	public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
-        Lock readLock = lock.readLock();
-        List<PropertyConverter<T>> converterList = new ArrayList<>();
-        // direct mapped converters
-        try {
-            readLock.lock();
-            addConvertersToList(List.class.cast(this.converters.get(targetType)), converterList);
-            addConvertersToList(List.class.cast(this.transitiveConverters.get(targetType)), converterList);
-        } finally {
-            readLock.unlock();
-        }
-        // handling of java.lang wrapper classes
-        TypeLiteral<T> boxedType = mapBoxedType(targetType);
-        if (boxedType != null) {
-            try {
-                readLock.lock();
-                addConvertersToList(List.class.cast(this.converters.get(boxedType)), converterList);
-            } finally {
-                readLock.unlock();
-            }
-        }
-        if (converterList.isEmpty() && !TypeLiteral.of(String.class).equals(targetType)) {
-            // adding any converters created on the fly, e.g. for enum types.
-            PropertyConverter<T> defaultConverter = createDefaultPropertyConverter(targetType);
-            if (defaultConverter != null) {
-                register(targetType, defaultConverter);
-                try {
-                    readLock.lock();
-                    addConvertersToList(List.class.cast(this.converters.get(targetType)), converterList);
-                } finally {
-                    readLock.unlock();
-                }
-            }
-        }
-        // check for parametrized types, ignoring param type
-        // direct mapped converters
-        if(targetType.getType()!=null) {
-            try {
-                readLock.lock();
-                addConvertersToList(List.class.cast(this.converters.get(
-                        TypeLiteral.of(targetType.getRawType()))), converterList);
-            } finally {
-                readLock.unlock();
-            }
-        }
-        return converterList;
-    }
-
-    private <T> void addConvertersToList(Collection<PropertyConverter<T>> converters, List<PropertyConverter<T>> converterList) {
-        if (converters != null) {
-            for(PropertyConverter<T> conv:converters) {
-                if(!converterList.contains(conv)) {
-                    converterList.add(conv);
-                }
-            }
-        }
-    }
-
-    /**
-     * Maps native types to the corresponding boxed types.
-     *
-     * @param targetType the native type.
-     * @param <T>        the type
-     * @return the boxed type, or null.
-     */
-    @SuppressWarnings("unchecked")
-	private <T> TypeLiteral<T> mapBoxedType(TypeLiteral<T> targetType) {
-        Type parameterType = targetType.getType();
-        if (parameterType == int.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Integer.class));
-        }
-        if (parameterType == short.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Short.class));
-        }
-        if (parameterType == byte.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Byte.class));
-        }
-        if (parameterType == long.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Long.class));
-        }
-        if (parameterType == boolean.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
-        }
-        if (parameterType == char.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Character.class));
-        }
-        if (parameterType == float.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Float.class));
-        }
-        if (parameterType == double.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Double.class));
-        }
-        if (parameterType == int[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Integer[].class));
-        }
-        if (parameterType == short[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Short[].class));
-        }
-        if (parameterType == byte[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Byte[].class));
-        }
-        if (parameterType == long[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Long[].class));
-        }
-        if (parameterType == boolean.class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
-        }
-        if (parameterType == char[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Character[].class));
-        }
-        if (parameterType == float[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Float[].class));
-        }
-        if (parameterType == double[].class) {
-            return TypeLiteral.class.cast(TypeLiteral.of(Double[].class));
-        }
-        return null;
-    }
-
-    /**
-     * Creates a dynamic PropertyConverter for the given target type.
-     *
-     * @param targetType the target type
-     * @param <T>        the type class
-     * @return a new converter, or null.
-     */
-    protected <T> PropertyConverter<T> createDefaultPropertyConverter(final TypeLiteral<T> targetType) {
-        if (Enum.class.isAssignableFrom(targetType.getRawType())) {
-            return new EnumConverter<>(targetType.getRawType());
-        }
-        PropertyConverter<T> converter = null;
-        final Method factoryMethod = getFactoryMethod(targetType.getRawType(), "of", "valueOf", "instanceOf", "getInstance", "from", "fromString", "parse");
-        if (factoryMethod != null) {
-            converter = new DefaultPropertyConverter<>(factoryMethod, targetType.getRawType());
-        }
-        if (converter == null) {
-            final Constructor<T> constr;
-            try {
-                constr = targetType.getRawType().getDeclaredConstructor(String.class);
-            } catch (NoSuchMethodException e) {
-                LOG.log(Level.FINEST, "No matching constructor for " + targetType, e);
-                return null;
-            }
-            converter = new PropertyConverter<T>() {
-                    @Override
-                    public T convert(String value, ConversionContext context) {
-                        AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                            @Override
-                            public Object run() {
-                                AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                                    @Override
-                                    public Object run() {
-                                        constr.setAccessible(true);
-                                        return null;
-                                    }
-                                });
-                                return null;
-                            }
-                        });
-                        try {
-                            return constr.newInstance(value);
-                        } catch (Exception e) {
-                            LOG.log(Level.SEVERE, "Error creating new PropertyConverter instance " + targetType, e);
-                        }
-                        return null;
-                    }
-                };
-        }
-        return converter;
-    }
-
-    /**
-     * Tries to evaluate a factory method that can be used to create an instance based on a String.
-     *
-     * @param type        the target type
-     * @param methodNames the possible static method names
-     * @return the first method found, or null.
-     */
-    private Method getFactoryMethod(Class<?> type, String... methodNames) {
-        Method m;
-        for (String name : methodNames) {
-            try {
-                m = type.getDeclaredMethod(name, String.class);
-                return m;
-            } catch (NoSuchMethodException | RuntimeException e) {
-                LOG.finest("No such factory method found on type: " + type.getName() + ", methodName: " + name);
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof PropertyConverterManager)) return false;
-
-        PropertyConverterManager that = (PropertyConverterManager) o;
-
-        return converters.equals(that.converters);
-    }
-
-    @Override
-    public int hashCode() {
-        return converters.hashCode();
-    }
-
-    private static class DefaultPropertyConverter<T> implements PropertyConverter<T> {
-
-        private final Method factoryMethod;
-        private final Class<T> targetType;
-
-        DefaultPropertyConverter(Method factoryMethod, Class<T> targetType){
-            this.factoryMethod = Objects.requireNonNull(factoryMethod);
-            this.targetType =  Objects.requireNonNull(targetType);
-        }
-
-        @Override
-        public T convert(String value, ConversionContext context) {
-            context.addSupportedFormats(getClass(), "<String -> "+factoryMethod.toGenericString());
-
-            if (!Modifier.isStatic(factoryMethod.getModifiers())) {
-                throw new ConfigException(factoryMethod.toGenericString() +
-                        " is not a static method. Only static methods can be used as factory methods.");
-            }
-            try {
-                AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                    @Override
-                    public Object run() {
-                        factoryMethod.setAccessible(true);
-                        return null;
-                    }
-                });
-                Object invoke = factoryMethod.invoke(null, value);
-                return targetType.cast(invoke);
-            } catch (Exception e) {
-                throw new ConfigException("Failed to decode '" + value + "'", e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
deleted file mode 100644
index 96779df..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
+++ /dev/null
@@ -1,73 +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.core.internal;
-
-import org.apache.tamaya.spi.PropertyFilter;
-
-import javax.annotation.Priority;
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Comparator for PropertyFilters based on their priority annotations.
- */
-public class PropertyFilterComparator implements Comparator<PropertyFilter>, Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private static final PropertyFilterComparator INSTANCE = new PropertyFilterComparator();
-
-    /** Singleton constructor. */
-    private PropertyFilterComparator(){}
-
-    /**
-     * Get the shared instance of the comparator.
-     * @return the shared instance, never null.
-     */
-    public static PropertyFilterComparator getInstance(){
-        return INSTANCE;
-    }
-
-    /**
-     * Compare 2 filters for ordering the filter chain.
-     *
-     * @param filter1 the first filter
-     * @param filter2 the second filter
-     * @return the comparison result
-     */
-    private int comparePropertyFilters(PropertyFilter filter1, PropertyFilter filter2) {
-        Priority prio1 = filter1.getClass().getAnnotation(Priority.class);
-        Priority prio2 = filter2.getClass().getAnnotation(Priority.class);
-        int ord1 = prio1 != null ? prio1.value() : 0;
-        int ord2 = prio2 != null ? prio2.value() : 0;
-
-        if (ord1 < ord2) {
-            return -1;
-        } else if (ord1 > ord2) {
-            return 1;
-        } else {
-            return filter1.getClass().getName().compareTo(filter2.getClass().getName());
-        }
-    }
-
-    @Override
-    public int compare(PropertyFilter filter1, PropertyFilter filter2) {
-        return comparePropertyFilters(filter1, filter2);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
deleted file mode 100644
index 16ff457..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
+++ /dev/null
@@ -1,125 +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.core.internal;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-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 PropertySource} and {@link PropertyFilter}
- * instance to evaluate the current Configuration.
- */
-public final class PropertyFiltering{
-    /**
-     * The logger.
-     */
-    private static final Logger LOG = Logger.getLogger(PropertyFiltering.class.getName());
-
-    /**
-     * The maximal number of filter cycles performed before aborting.
-     */
-    private static final int MAX_FILTER_LOOPS = 10;
-
-    /**
-     * Private singleton constructor.
-     */
-    private PropertyFiltering(){}
-
-    /**
-     * Filters a single value.
-     * @param value the raw value, not {@code null}.
-     * @param context the context
-     * @return the filtered value, including {@code 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 {@code 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!
-        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 result;
-    }
-
-    /**
-     * Basic filter logic.
-     * @param context the filter context, not {@code null}.
-     * @return the filtered value.
-     */
-    private static PropertyValue filterValue(FilterContext context) {
-        PropertyValue inputValue = context.getProperty();
-        PropertyValue filteredValue = inputValue;
-
-        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 == 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);
-                }
-            }
-        }
-        return filteredValue;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
deleted file mode 100644
index 20ca097..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
+++ /dev/null
@@ -1,86 +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.core.internal;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import javax.annotation.Priority;
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Comparator for ordering of PropertySources based on their ordinal method and class name.
- */
-public class PropertySourceComparator implements Comparator<PropertySource>, Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private static final PropertySourceComparator INSTANCE = new PropertySourceComparator();
-
-    /** Singleton constructor. */
-    private PropertySourceComparator(){}
-
-    /**
-     * Get the shared instance of the comparator.
-     * @return the shared instance, never null.
-     */
-    public static PropertySourceComparator getInstance(){
-        return INSTANCE;
-    }
-
-    /**
-     * Order property source reversely, the most important comes first.
-     *
-     * @param source1 the first PropertySource
-     * @param source2 the second PropertySource
-     * @return the comparison result.
-     */
-    private int comparePropertySources(PropertySource source1, PropertySource source2) {
-        if (getOrdinal(source1) < getOrdinal(source2)) {
-            return -1;
-        } else if (getOrdinal(source1) > getOrdinal(source2)) {
-            return 1;
-        } else {
-            return source1.getClass().getName().compareTo(source2.getClass().getName());
-        }
-    }
-
-    /**
-     * Evaluates an ordinal value from a {@link PropertySource}, Hereby the ordinal of type {@code int}
-     * is evaluated as follows:
-     * <ol>
-     *     <li>It evaluates the {@code String} value for {@link PropertySource#TAMAYA_ORDINAL} and tries
-     *     to convert it to an {@code int} value, using {@link Integer#parseInt(String)}.</li>
-     *     <li>It tries to find and evaluate a method {@code int getOrdinal()}.</li>
-     *     <li>It tries to find and evaluate a static field {@code int ORDINAL}.</li>
-     *     <li>It tries to find and evaluate a class level {@link Priority} annotation.</li>
-     *     <li>It uses the default priority ({@code 0}.</li>
-     * </ol>
-     * @param propertySource the property source, not {@code null}.
-     * @return the ordinal value to compare the property source.
-     */
-    public static int getOrdinal(PropertySource propertySource) {
-        return propertySource.getOrdinal();
-    }
-
-    @Override
-    public int compare(PropertySource source1, PropertySource source2) {
-        return comparePropertySources(source1, source2);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/ReflectionUtil.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/ReflectionUtil.java b/code/core/src/main/java/org/apache/tamaya/core/internal/ReflectionUtil.java
deleted file mode 100644
index 6c7a1d2..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/ReflectionUtil.java
+++ /dev/null
@@ -1,42 +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.core.internal;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-
-/**
- * Small utility class used by other parts.
- */
-public final class ReflectionUtil {
-
-    private ReflectionUtil(){}
-
-    public static ParameterizedType getParametrizedType(Class<?> clazz) {
-        Type[] genericTypes = clazz.getGenericInterfaces();
-        for (Type type : genericTypes) {
-            if (type instanceof ParameterizedType) {
-                return (ParameterizedType) type;
-            }
-
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7917a9f3/code/core/src/main/java/org/apache/tamaya/core/internal/WrappedPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/WrappedPropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/internal/WrappedPropertySource.java
deleted file mode 100644
index 34f4361..0000000
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/WrappedPropertySource.java
+++ /dev/null
@@ -1,125 +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.core.internal;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Property source effectively managed by the configuration context, allowing resetting of ordinal and its
- * delegate (e.g. in case of refresh).
- */
-class WrappedPropertySource implements PropertySource{
-
-    private Integer ordinal;
-    private PropertySource delegate;
-    private long loaded = System.currentTimeMillis();
-
-    private WrappedPropertySource(PropertySource delegate) {
-        this(delegate, null);
-    }
-
-    private WrappedPropertySource(PropertySource delegate, Integer ordinal) {
-        this.delegate = Objects.requireNonNull(delegate);
-        this.ordinal = ordinal;
-    }
-
-    public static WrappedPropertySource of(PropertySource ps) {
-        if(ps instanceof  WrappedPropertySource){
-            return (WrappedPropertySource)ps;
-        }
-        return new WrappedPropertySource(ps);
-    }
-
-    public static WrappedPropertySource of(PropertySource ps, Integer ordinal) {
-        if(ps instanceof  WrappedPropertySource){
-            return new WrappedPropertySource(((WrappedPropertySource)ps).getDelegate(), ordinal);
-        }
-        return new WrappedPropertySource(ps, ordinal);
-    }
-
-    public int getOrdinal() {
-        if(this.ordinal!=null){
-            return this.ordinal;
-        }
-        return PropertySourceComparator.getOrdinal(delegate);
-    }
-
-    public void setOrdinal(Integer ordinal) {
-        this.ordinal = ordinal;
-    }
-
-    public void setDelegate(PropertySource delegate) {
-        this.delegate = Objects.requireNonNull(delegate);
-        this.loaded = System.currentTimeMillis();
-    }
-
-    @Override
-    public String getName() {
-        return delegate.getName();
-    }
-
-    @Override
-    public PropertyValue get(String key) {
-        return delegate.get(key);
-    }
-
-    @Override
-    public Map<String, PropertyValue> getProperties() {
-        return delegate.getProperties();
-    }
-
-    @Override
-    public boolean isScannable() {
-        return delegate.isScannable();
-    }
-
-    public PropertySource getDelegate() {
-        return delegate;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof WrappedPropertySource)) return false;
-
-        WrappedPropertySource that = (WrappedPropertySource) o;
-
-        return getDelegate().getName().equals(that.getDelegate().getName());
-    }
-
-    @Override
-    public int hashCode() {
-        return getDelegate().getName().hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return "WrappedPropertySource{" +
-                "name=" + getName() +
-                ", ordinal=" + getOrdinal() +
-                ", scannable=" + isScannable() +
-                ", loadedAt=" + loaded +
-                ", delegate-class=" + delegate.getClass().getName() +
-                '}';
-    }
-}