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/02/26 23:05:14 UTC

[01/11] incubator-tamaya-extensions git commit: TAMAYA-197: Fixed bug not injecting properties in superclasses.

Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/master 946584592 -> abb34d651


TAMAYA-197: Fixed bug not injecting properties in superclasses.


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

Branch: refs/heads/master
Commit: abb34d65181d9be614cbba258dd0ee174a7f3b7d
Parents: d763fa0
Author: anatole <an...@apache.org>
Authored: Mon Feb 27 00:00:30 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../inject/internal/ConfiguredTypeImpl.java     |  9 ++++++
 .../annottext/InheritedAnnotatedConfigBean.java | 29 ++++++++++++++++++++
 .../tamaya/inject/TamayaInjectionTest.java      | 24 ++++++++++++++++
 .../tamaya/inject/TestPropertySource.java       |  1 +
 modules/pom.xml                                 |  2 ++
 5 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
index b40f6c9..c438348 100644
--- a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
+++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
@@ -81,6 +81,9 @@ public class ConfiguredTypeImpl implements ConfiguredType{
     }
 
     private void initFields(Class type, boolean autoConfigure) {
+        if (type.getSuperclass() != null) {
+            initFields(type.getSuperclass(), autoConfigure);
+        }
         for (Field f : type.getDeclaredFields()) {
             if (f.isAnnotationPresent(NoConfig.class)) {
                 LOG.finest("Ignored @NoConfig annotated field " + f.getClass().getName() + "#" +
@@ -112,6 +115,9 @@ public class ConfiguredTypeImpl implements ConfiguredType{
     }
 
     private void initMethods(Class type, boolean autoConfigure) {
+        if (type.getSuperclass() != null) {
+            initMethods(type.getSuperclass(), autoConfigure);
+        }
         // TODO revisit this logic here...
         for (Method m : type.getDeclaredMethods()) {
             if (m.isAnnotationPresent(NoConfig.class)) {
@@ -191,6 +197,9 @@ public class ConfiguredTypeImpl implements ConfiguredType{
                 return true;
             }
         }
+        if (type.getSuperclass() != null) {
+            return isConfigured(type.getSuperclass());
+        }
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java b/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java
new file mode 100644
index 0000000..9952b18
--- /dev/null
+++ b/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.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 annottext;
+
+import org.apache.tamaya.inject.api.Config;
+
+public class InheritedAnnotatedConfigBean extends AnnotatedConfigBean {
+
+    @Config("someMoreValue")
+    public String someMoreValue;
+    
+    public String notConfigured;
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
index d5a26c1..b95d491 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.inject;
 
 import annottext.AnnotatedConfigBean;
 import annottext.AnnotatedConfigTemplate;
+import annottext.InheritedAnnotatedConfigBean;
 import annottext.NonAnnotatedConfigBean;
 import org.junit.Test;
 
@@ -68,6 +69,29 @@ public class TamayaInjectionTest {
         assertEquals(testInstance.getHostName(), testInstance.getDynamicValue().get());
         assertEquals(testInstance.javaVersion, System.getProperty("java.version"));
     }
+    
+    @Test
+    public void testInjectionInheritedClass(){
+        assertNotNull(ConfigurationInjection.getConfigurationInjector());
+        InheritedAnnotatedConfigBean testInstance = new InheritedAnnotatedConfigBean();
+        assertEquals(testInstance.getHostName(), null);
+        assertEquals(testInstance.getAnotherValue(), null);
+        assertEquals(testInstance.myParameter, null);
+        assertEquals(testInstance.simpleValue, null);
+        assertEquals(testInstance.someMoreValue, null);
+        assertEquals(testInstance.notConfigured, null);
+        ConfigurationInjection.getConfigurationInjector().configure(testInstance);
+        assertEquals(testInstance.getHostName(), "tamaya01.incubator.apache.org");
+        assertEquals(testInstance.getAnotherValue(), "HALLO!");
+        assertEquals(testInstance.myParameter, "ET");
+        assertEquals(testInstance.simpleValue, "aSimpleValue");
+        assertNotNull(testInstance.getDynamicValue());
+        assertTrue(testInstance.getDynamicValue().isPresent());
+        assertEquals(testInstance.getDynamicValue().get(), "tamaya01.incubator.apache.org");
+        assertEquals(testInstance.getHostName(), testInstance.getDynamicValue().get());
+        assertEquals(testInstance.javaVersion, System.getProperty("java.version"));
+        assertEquals(testInstance.someMoreValue, "s'more");
+    }    
 
     @Test
     public void testConfigTemplate(){

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
index 321f7f4..4af2f33 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
@@ -39,6 +39,7 @@ public class TestPropertySource implements PropertySource {
         properties.put("NonAnnotatedConfigBean.classFieldKey", "Class-Field-Value");
         properties.put("NonAnnotatedConfigBean.fieldKey", "Field-Value");
         properties.put("annottext.NonAnnotatedConfigBean.fullKey", "Fullkey-Value");
+        properties.put("someMoreValue", "s'more");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/pom.xml
----------------------------------------------------------------------
diff --git a/modules/pom.xml b/modules/pom.xml
index c8be869..621ef44 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -32,6 +32,7 @@ under the License.
     <packaging>pom</packaging>
 
     <modules>
+        <module>features</module>
         <module>functions</module>
         <module>spi-support</module>
         <module>optional</module>
@@ -43,6 +44,7 @@ under the License.
         <module>resolver</module>
         <module>resources</module>
         <module>spring</module>
+        <module>jndi</module>
     </modules>
 
 </project>


[04/11] incubator-tamaya-extensions git commit: Added features module.

Posted by an...@apache.org.
Added features module.


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

Branch: refs/heads/master
Commit: e71203c9da8759da5162f1d2519ec96e16bce7ca
Parents: 9465845
Author: anatole <an...@apache.org>
Authored: Tue Feb 14 23:54:28 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 modules/features/bnd.bnd                        |   2 +
 modules/features/pom.xml                        |  62 +++++++
 .../org/apache/tamaya/features/Features.java    | 177 +++++++++++++++++++
 .../apache/tamaya/features/package-info.java    |   4 +
 4 files changed, 245 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/features/bnd.bnd b/modules/features/bnd.bnd
new file mode 100644
index 0000000..e0d0b58
--- /dev/null
+++ b/modules/features/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+	org.apache.tamaya.features
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/pom.xml
----------------------------------------------------------------------
diff --git a/modules/features/pom.xml b/modules/features/pom.xml
new file mode 100644
index 0000000..4bc274b
--- /dev/null
+++ b/modules/features/pom.xml
@@ -0,0 +1,62 @@
+<?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 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.ext</groupId>
+        <artifactId>tamaya-extensions</artifactId>
+        <version>0.3-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tamaya-features</artifactId>
+    <name>Apache Tamaya Feature Check</name>
+    <packaging>jar</packaging>
+
+    <properties>
+        <jdkVersion>1.7</jdkVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-api</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-core</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/src/main/java/org/apache/tamaya/features/Features.java
----------------------------------------------------------------------
diff --git a/modules/features/src/main/java/org/apache/tamaya/features/Features.java b/modules/features/src/main/java/org/apache/tamaya/features/Features.java
new file mode 100644
index 0000000..6abb6c5
--- /dev/null
+++ b/modules/features/src/main/java/org/apache/tamaya/features/Features.java
@@ -0,0 +1,177 @@
+/*
+ * 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.features;
+
+import javax.naming.InitialContext;
+import java.util.Objects;
+
+/**
+ * Simple Features singleton to check, which Tamaya modules are currently available.
+ */
+public final class Features {
+
+    /** Private singleton constructor. */
+    private Features(){}
+
+    /**
+     * Checks if <i>tamaya-events</i> is on the classpath.
+     * @return true, if <i>tamaya-events</i> is on the classpath.
+     */
+    public static boolean eventsAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.events.ConfigEventManager");
+    }
+
+    /**
+     * Checks if <i>tamaya-formats</i> is on the classpath.
+     * @return true, if <i>tamaya-formats</i> is on the classpath.
+     */
+    public static boolean formatsAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.format.ConfigurationFormats");
+    }
+
+    /**
+     * Checks if <i>tamaya-core</i> is on the classpath.
+     * @return true, if <i>tamaya-core</i> is on the classpath.
+     */
+    public static boolean tamayaCoreAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.core.internal.DefaultConfigurationProvider");
+    }
+
+    /**
+     * Checks if <i>tamaya-injection</i> is on the classpath.
+     * @return true, if <i>tamaya-injection</i> is on the classpath.
+     */
+    public static boolean injectionAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.inject.ConfigurationInjector");
+    }
+
+    /**
+     * Checks if <i>tamaya-injection-cdi</i> or <i>tamaya-injection-ee</i> is on the classpath.
+     * @return true, if <i>tamaya-injection-cdi</i> or <i>tamaya-injection-ee</i> is on the classpath.
+     */
+    public static boolean injectionCDIAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.integration.cdi.TamayaCDIIntegration");
+    }
+
+    /**
+     * Checks if <i>tamaya-mutableconfig</i> is on the classpath.
+     * @return true, if <i>tamaya-mutableconfig</i> is on the classpath.
+     */
+    public static boolean mutableConfigAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.mutableconfig.MutableConfigProvider");
+    }
+
+    /**
+     * Checks if <i>tamaya-optional</i> is on the classpath.
+     * @return true, if <i>tamaya-optional</i> is on the classpath.
+     */
+    public static boolean optionalAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.optional.OptionalConfiguration");
+    }
+
+    /**
+     * Checks if <i>tamaya-resolver</i> is on the classpath.
+     * @return true, if <i>tamaya-resolver</i> is on the classpath.
+     */
+    public static boolean resolverAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.resolver.ResourceResolver");
+    }
+
+    /**
+     * Checks if <i>tamaya-resources</i> is on the classpath.
+     * @return true, if <i>tamaya-respurces</i> is on the classpath.
+     */
+    public static boolean resourcesAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.resource.ConfigResources");
+    }
+
+    /**
+     * Checks if <i>tamaya-spisupport</i> is on the classpath.
+     * @return true, if <i>tamaya-spisupport</i> is on the classpath.
+     */
+    public static boolean spiSupportAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.spisupport.PropertySourceComparator");
+    }
+
+    /**
+     * Checks if <i>tamaya-filter</i> is on the classpath.
+     * @return true, if <i>tamaya-filter</i> is on the classpath.
+     */
+    public static boolean filterSupportAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.filter.ConfigurationFilter");
+    }
+
+    /**
+     * Checks if <i>tamaya-spring</i> is on the classpath.
+     * @return true, if <i>tamaya-spring</i> is on the classpath.
+     */
+    public static boolean springAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.integration.spring.TamayaEnvironment");
+    }
+
+    /**
+     * Checks if <i>tamaya-jndi</i> is on the classpath.
+     * @return true, if <i>tamaya-jndi</i> is on the classpath.
+     */
+    public static boolean jndiAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.jndi.JNDIPropertySource");
+    }
+
+    /**
+     * Checks if <i>spring-core</i> is on the classpath.
+     * @return true, if <i>spring-core</i> is on the classpath.
+     */
+    public static boolean extSpringCoreAvailable() {
+        return checkClassIsLoadable("org.springframework.core.env.Environment");
+    }
+
+    /**
+     * Checks if <i>OSGIe</i> is on the classpath.
+     * @return true, if <i>OSGI</i> is on the classpath.
+     */
+    public static boolean extOSGIAvailable() {
+        return checkClassIsLoadable("org.osgi.framework.BundleContext");
+    }
+
+    /**
+     * Checks if JNDI is working.
+     * @return true, if JNDI is working.
+     */
+    public static boolean extJndiAvailable() {
+        try{
+            new InitialContext();
+            return true;
+        }catch(Exception e){
+            return false;
+        }
+    }
+
+    /**
+     * Checks if the given class canm be loaded, using {@code Class.forName(classname)}.
+     * @return true, if the given class canm be loaded.
+     */
+    public static boolean checkClassIsLoadable(String classname) {
+        try{
+            Class.forName(Objects.requireNonNull(classname));
+            return true;
+        }catch(Exception e){
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
----------------------------------------------------------------------
diff --git a/modules/features/src/main/java/org/apache/tamaya/features/package-info.java b/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
new file mode 100644
index 0000000..eeb00e5
--- /dev/null
+++ b/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Tamaya Feature Module.
+ */
+package org.apache.tamaya.features;
\ No newline at end of file


[11/11] incubator-tamaya-extensions git commit: TAMAYA-222: Fixed/deprecated spelling errors.

Posted by an...@apache.org.
TAMAYA-222: Fixed/deprecated spelling errors.


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

Branch: refs/heads/master
Commit: e86db7dd67be78e70664e2aca8e4c00589c2d50d
Parents: 78be87e
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:36:47 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../integration/cdi/DefaultDynamicValue.java    | 10 ++++++----
 .../apache/tamaya/inject/api/UpdatePolicy.java  | 14 +++++++++++---
 .../inject/internal/DefaultDynamicValue.java    | 10 ++++++----
 .../internal/DefaultDynamicValueTest.java       | 20 ++++++++++----------
 4 files changed, 33 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e86db7dd/modules/injection/cdi-ee/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection/cdi-ee/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java b/modules/injection/cdi-ee/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
index 7015598..a06feb8 100644
--- a/modules/injection/cdi-ee/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
+++ b/modules/injection/cdi-ee/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
@@ -135,11 +135,11 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
     }
 
     public static DynamicValue of(Field annotatedField, Configuration configuration) {
-        return of(annotatedField, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
+        return of(annotatedField, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Field annotatedField, Configuration configuration, LoadPolicy loadPolicy) {
-        return of(annotatedField, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
+        return of(annotatedField, configuration, loadPolicy, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Field annotatedField, Configuration configuration, UpdatePolicy updatePolicy) {
@@ -179,7 +179,7 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
     }
 
     public static DynamicValue of(Method method, Configuration configuration) {
-        return of(method, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
+        return of(method, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Method method, Configuration configuration, UpdatePolicy updatePolicy) {
@@ -187,7 +187,7 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
     }
 
     public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy) {
-        return of(method, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
+        return of(method, configuration, loadPolicy, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy, UpdatePolicy updatePolicy) {
@@ -313,9 +313,11 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
             if(!Objects.equals(this.value, newLocalValue)){
                 switch (updatePolicy){
                     case IMMEDEATE:
+                    case IMMEDIATE:
                         commit();
                         break;
                     case EXPLCIT:
+                    case EXPLICIT:
                         this.newValue = new Object[]{newLocalValue};
                         break;
                     case LOG_ONLY:

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e86db7dd/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
----------------------------------------------------------------------
diff --git a/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java b/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
index 64e273a..1664b67 100644
--- a/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
+++ b/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
@@ -22,14 +22,22 @@ package org.apache.tamaya.inject.api;
  * Policy to control how new values are applied to a {@link DynamicValue}.
  */
 public enum UpdatePolicy {
-    /** New values are applied immedately and registered listeners are informed about the change. */
-    // REVIEW: typo IMMEDIATE
+    /**
+     * @deprecated Use {@link #IMMEDIATE} instead of.
+     */
+    @Deprecated
     IMMEDEATE,
+    /** New values are applied immedately and registered listeners are informed about the change. */
+    IMMEDIATE,
     /** New values or not applied, but stored in the newValue property. Explicit call to DynamicValue#commit
      of DynamicValue#commitAndGet are required to accept the change and inform the listeners about the change.
      * Registered listeners will be informed, when the commit was performed explicitly.
      */
-    // REVIEW: typo EXPLICIT
+    EXPLICIT,
+    /**
+     * @deprecated Use {@link #EXPLICIT} instead of.
+     */
+    @Deprecated
     EXPLCIT,
     /**
      * New values are always immedately discarded, listeners are not triggered.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e86db7dd/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
index 0c7bed4..4b091f6 100644
--- a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
+++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
@@ -135,11 +135,11 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
     }
 
     public static DynamicValue of(Field annotatedField, Configuration configuration) {
-        return of(annotatedField, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
+        return of(annotatedField, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Field annotatedField, Configuration configuration, LoadPolicy loadPolicy) {
-        return of(annotatedField, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
+        return of(annotatedField, configuration, loadPolicy, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Field annotatedField, Configuration configuration, UpdatePolicy updatePolicy) {
@@ -179,7 +179,7 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
     }
 
     public static DynamicValue of(Method method, Configuration configuration) {
-        return of(method, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
+        return of(method, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Method method, Configuration configuration, UpdatePolicy updatePolicy) {
@@ -187,7 +187,7 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
     }
 
     public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy) {
-        return of(method, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
+        return of(method, configuration, loadPolicy, UpdatePolicy.IMMEDIATE);
     }
 
     public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy, UpdatePolicy updatePolicy) {
@@ -313,9 +313,11 @@ final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
             if(!Objects.equals(this.value, newLocalValue)){
                 switch (updatePolicy){
                     case IMMEDEATE:
+                    case IMMEDIATE:
                         commit();
                         break;
                     case EXPLCIT:
+                    case EXPLICIT:
                         this.newValue = new Object[]{newLocalValue};
                         break;
                     case LOG_ONLY:

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e86db7dd/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
index 26ea2de..16cc265 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
@@ -117,7 +117,7 @@ public class DefaultDynamicValueTest {
         properties.put("a","aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
+        val.setUpdatePolicy(UpdatePolicy.EXPLICIT);
         assertNotNull(val);
         assertEquals("aValue",val.evaluateValue());
         // change config
@@ -132,7 +132,7 @@ public class DefaultDynamicValueTest {
         properties.put("a", "aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
+        val.setUpdatePolicy(UpdatePolicy.EXPLICIT);
         assertNotNull(val);
         assertEquals("aValue", val.evaluateValue());
         // change config
@@ -159,7 +159,7 @@ public class DefaultDynamicValueTest {
         properties.put("a","aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
+        val.setUpdatePolicy(UpdatePolicy.IMMEDIATE);
         val.addListener(consumer);
         // change config
         val.get();
@@ -178,7 +178,7 @@ public class DefaultDynamicValueTest {
         properties.put("a", "aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
+        val.setUpdatePolicy(UpdatePolicy.IMMEDIATE);
         properties.put("a", "aValue2");
         val.updateValue();
         assertEquals("aValue2", val.get());
@@ -189,12 +189,12 @@ public class DefaultDynamicValueTest {
         properties.put("a","aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
+        val.setUpdatePolicy(UpdatePolicy.EXPLICIT);
         assertNotNull(val.get());
         assertEquals("aValue", val.get());
         val.updateValue();
         assertEquals("aValue", val.get());
-        val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
+        val.setUpdatePolicy(UpdatePolicy.IMMEDIATE);
         val.updateValue();
         assertEquals("aValue",val.get());
     }
@@ -204,7 +204,7 @@ public class DefaultDynamicValueTest {
         properties.put("a","aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
+        val.setUpdatePolicy(UpdatePolicy.EXPLICIT);
         assertNotNull(val.get());
         assertEquals("aValue",val.evaluateValue());
         properties.put("a", "aValue2");
@@ -216,7 +216,7 @@ public class DefaultDynamicValueTest {
         properties.put("a","aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
+        val.setUpdatePolicy(UpdatePolicy.EXPLICIT);
         val.get();
         assertNull(val.getNewValue());
         properties.put("a", "aValue2");
@@ -237,7 +237,7 @@ public class DefaultDynamicValueTest {
         properties.put("a","aValue");
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
+        val.setUpdatePolicy(UpdatePolicy.IMMEDIATE);
         assertTrue(val.isPresent());
         properties.remove("a");
         val.updateValue();
@@ -248,7 +248,7 @@ public class DefaultDynamicValueTest {
     public void testOrElse() throws Exception {
         DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
                 config);
-        val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
+        val.setUpdatePolicy(UpdatePolicy.IMMEDIATE);
         assertEquals("bla", val.orElse("bla"));
         properties.put("a","aValue");
         val.updateValue();


[05/11] incubator-tamaya-extensions git commit: Added JNDI module.

Posted by an...@apache.org.
Added JNDI module.


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

Branch: refs/heads/master
Commit: a315ab4ca127c4fdc8c642d4a1b85a75c44bdac3
Parents: e71203c
Author: anatole <an...@apache.org>
Authored: Tue Feb 14 23:54:48 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 modules/jndi/bnd.bnd                            |   2 +
 modules/jndi/pom.xml                            |  73 ++++++++
 .../apache/tamaya/jndi/JNDIPropertySource.java  | 176 +++++++++++++++++++
 .../tamaya/jndi/JNDIPropertySourceTest.java     |  74 ++++++++
 modules/jndi/src/test/jndi-dir/a/test1          |  19 ++
 modules/jndi/src/test/jndi-dir/b/test2          |  19 ++
 modules/jndi/src/test/jndi-dir/c/c1/test5       |  19 ++
 modules/jndi/src/test/jndi-dir/c/test3          |  19 ++
 modules/jndi/src/test/jndi-dir/c/test4          |  19 ++
 9 files changed, 420 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/jndi/bnd.bnd b/modules/jndi/bnd.bnd
new file mode 100644
index 0000000..f426059
--- /dev/null
+++ b/modules/jndi/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+	org.apache.tamaya.jndi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jndi/pom.xml b/modules/jndi/pom.xml
new file mode 100644
index 0000000..dc79e34
--- /dev/null
+++ b/modules/jndi/pom.xml
@@ -0,0 +1,73 @@
+<?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 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.ext</groupId>
+        <artifactId>tamaya-extensions</artifactId>
+        <version>0.3-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tamaya-jndi</artifactId>
+    <name>Apache Tamaya JNDI Support</name>
+    <packaging>jar</packaging>
+
+    <properties>
+        <jdkVersion>1.7</jdkVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-api</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-core</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-spisupport</artifactId>
+            <version>0.3-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.messaging.mq</groupId>
+            <artifactId>fscontext</artifactId>
+            <version>4.6-b01</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java b/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java
new file mode 100644
index 0000000..307f096
--- /dev/null
+++ b/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.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.jndi;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.BasePropertySource;
+
+import javax.naming.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Propertysource that accesses JNDI as source for configuration entries.
+ */
+public class JNDIPropertySource extends BasePropertySource {
+    /** The logger used. */
+    private static final Logger LOG = Logger.getLogger(JNDIPropertySource.class.getName());
+    /** The root context, not null. */
+    private Context context;
+    /** The scannable property, default is {@code false}. */
+    private boolean scannable = false;
+
+    /**
+     * Creates a new instance.
+     * @param name the name of the property source, see {@link PropertySource#getName()}.
+     * @param context the root context to be used, not null.
+     */
+    public JNDIPropertySource(String name, Context context){
+        super(name);
+        this.context = Objects.requireNonNull(context);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param name the name of the property source, see {@link PropertySource#getName()}.
+     * @throws NamingException if {@code new InitialContext()} throws an exception.
+     */
+    public JNDIPropertySource(String name) throws NamingException {
+        super(name);
+        this.context = new InitialContext();
+    }
+
+    /**
+     * Creates a new instance, using {@code "jndi"} as property source name.
+     * @throws NamingException if {@code new InitialContext()} throws an exception.
+     */
+    public JNDIPropertySource() throws NamingException {
+        this("jndi");
+    }
+
+    /**
+     * If the property source is not scannable, an empty map is returned, otherwise
+     * the current JNDI context is mapped to configuration map:
+     * <ul>
+     *   <li>For each leave entry one entry is created.</li>
+     *   <li>The key is the fully path of parent contexts, separated by a '.'.</li>
+     *   <li>The value is the value returned from {@code String.valueOf(leaveObject)}.</li>
+     * </ul>
+     * @return a map representation of the JNDI tree.
+     */
+    @Override
+    public Map<String, String> getProperties() {
+        if(scannable){
+            try {
+                return toMap(this.context);
+            } catch (NamingException e) {
+                LOG.log(Level.WARNING, "Error scanning JNDI tree.", e);
+            }
+        }
+        return Collections.emptyMap();
+    }
+
+    @Override
+    public boolean isScannable() {
+        return scannable;
+    }
+
+    /**
+     * If set to true, the property source will return a String representation of the JNDI
+     * tree when calling {@code getProperties()}.
+     * @see #getProperties()
+     * @param val true, to activate scannable (default is false).
+     */
+    public void setScannable(boolean val){
+        this.scannable = val;
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        try {
+            key = key.replace('.', '/');
+            Object o = context.lookup(key);
+            return PropertyValue.of(key, o.toString(), getName());
+        } catch (NamingException e) {
+            LOG.log(Level.FINER, "Failed to lookup key in JNDI: " + key, e);
+            return null;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "JNDIPropertySource{" +
+                "name=" + getName() +
+                ", context=" + context +
+                '}';
+    }
+
+    /**
+     * Maps the given JNDI Context to a {@code Map<String,String>}:
+     *  mapped to configuration map:
+     * <ul>
+     *   <li>For each leave entry one entry is created.</li>
+     *   <li>The key is the fully path of parent contexts, separated by a '.'.</li>
+     *   <li>The value is the value returned from {@code String.valueOf(leaveObject)}.</li>
+     * </ul>
+     * @param ctx the JNDI context, not null.
+     * @return the corresponding map, never null.
+     * @throws NamingException If some JNDI issues occur.
+     */
+    public static Map<String,String> toMap(Context ctx) throws NamingException {
+        String namespace = ctx instanceof InitialContext ? ctx.getNameInNamespace() : "";
+        Map<String, String> map = new HashMap<>();
+        NamingEnumeration<NameClassPair> list = ctx.list(namespace);
+        while (list.hasMoreElements()) {
+            NameClassPair next = list.next();
+            String name = next.getName();
+            String jndiPath = namespace + name;
+            try {
+                Object lookup = ctx.lookup(jndiPath);
+                if (namespace.isEmpty()) {
+                    if (lookup instanceof Context) {
+                        Map<String, String> childMap = toMap((Context) lookup);
+                        for (Map.Entry<String, String> en : childMap.entrySet()) {
+                            map.put(name + "." + en.getKey(), en.getValue());
+                        }
+                    } else {
+                        map.put(name, String.valueOf(lookup));
+                    }
+                }else{
+                    if (lookup instanceof Context) {
+                        Map<String, String> childMap = toMap((Context) lookup);
+                        for (Map.Entry<String, String> en : childMap.entrySet()) {
+                            map.put(namespace + "." + name + "." + en.getKey(), en.getValue());
+                        }
+                    } else {
+                        map.put(namespace + "." + name, String.valueOf(lookup));
+                    }
+                }
+            } catch (Exception t) {
+                map.put(namespace + "." + name, "ERROR: " + t.getMessage());
+            }
+        }
+        return map;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/test/java/org/apache/tamaya/jndi/JNDIPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/jndi/src/test/java/org/apache/tamaya/jndi/JNDIPropertySourceTest.java b/modules/jndi/src/test/java/org/apache/tamaya/jndi/JNDIPropertySourceTest.java
new file mode 100644
index 0000000..00b3514
--- /dev/null
+++ b/modules/jndi/src/test/java/org/apache/tamaya/jndi/JNDIPropertySourceTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.jndi;
+
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Hashtable;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class JNDIPropertySourceTest{
+
+    private InitialContext createFSContext() throws NamingException, MalformedURLException {
+        Hashtable env = new Hashtable();
+        env.put (Context.INITIAL_CONTEXT_FACTORY,
+                "com.sun.jndi.fscontext.RefFSContextFactory");
+        return new InitialContext(env);
+    }
+
+    private Context getTestDirContext(InitialContext ctx) throws NamingException {
+        return (Context)ctx.lookup(new File("./src/test/jndi-dir").getAbsolutePath());
+    }
+
+    @Test
+    public void testCreateWithContext() throws NamingException, MalformedURLException {
+        new JNDIPropertySource("jndi-test", createFSContext());
+    }
+
+    @Test
+    public void testScanContext() throws NamingException, MalformedURLException {
+        JNDIPropertySource ps = new JNDIPropertySource("jndi-test", getTestDirContext(createFSContext()));
+        assertFalse(ps.isScannable());
+        Map<String,String> props = ps.getProperties();
+        assertNotNull(props);
+        assertTrue(props.isEmpty());
+        ps.setScannable(true);
+        assertTrue(ps.isScannable());
+        props = ps.getProperties();
+        assertNotNull(props);
+        assertFalse(props.isEmpty());
+        assertEquals(props.size(), 5);
+        assertNotNull(props.get("c.c1.test5"));
+        assertNotNull(props.get("c.test3"));
+        assertNotNull(props.get("c.test4"));
+        assertNotNull(props.get("b.test2"));
+        assertNotNull(props.get("a.test1"));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/test/jndi-dir/a/test1
----------------------------------------------------------------------
diff --git a/modules/jndi/src/test/jndi-dir/a/test1 b/modules/jndi/src/test/jndi-dir/a/test1
new file mode 100644
index 0000000..0355740
--- /dev/null
+++ b/modules/jndi/src/test/jndi-dir/a/test1
@@ -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.
+#
+test1Value
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/test/jndi-dir/b/test2
----------------------------------------------------------------------
diff --git a/modules/jndi/src/test/jndi-dir/b/test2 b/modules/jndi/src/test/jndi-dir/b/test2
new file mode 100644
index 0000000..8aadc3a
--- /dev/null
+++ b/modules/jndi/src/test/jndi-dir/b/test2
@@ -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.
+#
+test2Value
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/test/jndi-dir/c/c1/test5
----------------------------------------------------------------------
diff --git a/modules/jndi/src/test/jndi-dir/c/c1/test5 b/modules/jndi/src/test/jndi-dir/c/c1/test5
new file mode 100644
index 0000000..bfb7c6b
--- /dev/null
+++ b/modules/jndi/src/test/jndi-dir/c/c1/test5
@@ -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.
+#
+test5Value
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/test/jndi-dir/c/test3
----------------------------------------------------------------------
diff --git a/modules/jndi/src/test/jndi-dir/c/test3 b/modules/jndi/src/test/jndi-dir/c/test3
new file mode 100644
index 0000000..c3f4519
--- /dev/null
+++ b/modules/jndi/src/test/jndi-dir/c/test3
@@ -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.
+#
+test3Value
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a315ab4c/modules/jndi/src/test/jndi-dir/c/test4
----------------------------------------------------------------------
diff --git a/modules/jndi/src/test/jndi-dir/c/test4 b/modules/jndi/src/test/jndi-dir/c/test4
new file mode 100644
index 0000000..7ece03d
--- /dev/null
+++ b/modules/jndi/src/test/jndi-dir/c/test4
@@ -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.
+#
+test4Value
\ No newline at end of file


[10/11] incubator-tamaya-extensions git commit: TAMAYA-235: Added tests for section method. Fixed invalid key mapping.

Posted by an...@apache.org.
TAMAYA-235: Added tests for section method. Fixed invalid key mapping.


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

Branch: refs/heads/master
Commit: d763fa0422fbe9f66f261c810dbbd3bdc1092654
Parents: 6805cba
Author: anatole <an...@apache.org>
Authored: Sun Feb 26 23:47:40 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../functions/ConfigurationFunctions.java       |  2 +-
 .../functions/ConfigurationFunctionsTest.java   | 46 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/d763fa04/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
index 97934f6..ccb6396 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
@@ -240,7 +240,7 @@ public final class ConfigurationFunctions {
                             if(key.startsWith(areaKey)) {
                                 return key.substring(areaKey.length());
                             }
-                            return null;
+                            return areaKey + key;
                         }
                     }, "stripped");
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/d763fa04/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java b/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
index 93a7da9..5aa6995 100644
--- a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
+++ b/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
@@ -19,8 +19,16 @@
 package org.apache.tamaya.functions;
 
 import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.junit.Test;
 
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.TreeMap;
+
 import static org.junit.Assert.*;
 
 /**
@@ -140,4 +148,42 @@ public class ConfigurationFunctionsTest {
         assertNotNull(ps.getProperties());
         assertTrue(ps.getProperties().isEmpty());
     }
+
+    /**
+     * See https://issues.apache.org/jira/browse/TAMAYA-235
+     */
+    @Test
+    public void testSection_StripKeys() {
+        testSection(true);
+    }
+
+    /**
+     * See https://issues.apache.org/jira/browse/TAMAYA-235
+     */
+    @Test
+    public void testSection_NoStripKeys() {
+        testSection(false);
+    }
+
+    private void testSection(boolean stripKeys){
+        ConfigurationContextBuilder b = ConfigurationProvider.getConfigurationContextBuilder();
+        b.addPropertySources(new EnvironmentPropertySource(), new SystemPropertySource());
+        Configuration cfg = ConfigurationProvider.createConfiguration(b.build()).with(
+                ConfigurationFunctions.section("java.", stripKeys));
+        System.out.println("*****************************************************");
+        System.out.println("stripKeys: " + stripKeys);
+        System.out.println("*****************************************************");
+        dump(cfg.getProperties(), System.out);
+        System.out.println();
+        System.out.println("Example Metadata:");
+        System.out.println("\tjava.version         :  " + cfg.get("java.version"));
+        System.out.println("\tversion                 :  " + cfg.get("version"));
+    }
+
+    private void dump(Map<String, String> properties, PrintStream stream) {
+        stream.println("FULL DUMP:");
+        for (Map.Entry<String, String> en : new TreeMap<>(properties).entrySet()) {
+            stream.println("\t" + en.getKey() + " = " + en.getValue());
+        }
+    }
 }
\ No newline at end of file


[08/11] incubator-tamaya-extensions git commit: TAMAYA-238: OSGI improvements and service loading.

Posted by an...@apache.org.
TAMAYA-238: OSGI improvements and service loading.


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

Branch: refs/heads/master
Commit: 364604b07504572705bf7e3f4dd310ecf70d0693
Parents: 01610f6
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:08:12 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../tamaya/events/ConfigEventManager.java       | 51 ++++++++------------
 modules/formats/base/bnd.bnd                    |  4 +-
 modules/formats/json/bnd.bnd                    |  4 +-
 modules/formats/yaml/bnd.bnd                    |  4 +-
 modules/functions/bnd.bnd                       |  4 +-
 modules/injection/injection-api/bnd.bnd         |  5 +-
 modules/injection/standalone/bnd.bnd            |  4 +-
 modules/optional/bnd.bnd                        |  4 +-
 modules/resolver/bnd.bnd                        |  4 +-
 modules/resources/bnd.bnd                       |  4 +-
 modules/spi-support/bnd.bnd                     |  4 +-
 modules/spring/bnd.bnd                          |  4 +-
 12 files changed, 55 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
index f6bd3da..b5cb0ae 100644
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ b/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -32,8 +32,15 @@ public final class ConfigEventManager {
     /**
      * The backing SPI.
      */
-    private static final ConfigEventManagerSpi SPI = ServiceContextManager.getServiceContext()
-            .getService(ConfigEventManagerSpi.class);
+    private static final ConfigEventManagerSpi spi(){
+        ConfigEventManagerSpi spi = ServiceContextManager.getServiceContext()
+                .getService(ConfigEventManagerSpi.class);
+        if(spi==null){
+            throw new ConfigException("No SPI registered for " +
+                    ConfigEventManager.class.getName());
+        }
+        return spi;
+    }
 
     /**
      * Private singleton constructor.
@@ -46,11 +53,7 @@ public final class ConfigEventManager {
      * @param l the listener not null.
      */
     public static void addListener(ConfigEventListener l) {
-        if (SPI == null) {
-            throw new ConfigException("No SPI registered for " +
-                    ConfigEventManager.class.getName());
-        }
-        SPI.addListener(l);
+        spi().addListener(l);
     }
 
     /**
@@ -60,11 +63,7 @@ public final class ConfigEventManager {
      * @param eventType the event type to which this listener listens to.
      */
     public static <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType) {
-        if (SPI == null) {
-            throw new ConfigException("No SPI registered for " +
-                    ConfigEventManager.class.getName());
-        }
-        SPI.addListener(l);
+        spi().addListener(l);
     }
 
     /**
@@ -73,11 +72,7 @@ public final class ConfigEventManager {
      * @param l the listener not null.
      */
     public static void removeListener(ConfigEventListener l) {
-        if (SPI == null) {
-            throw new ConfigException("No SPI registered for " +
-                    ConfigEventManager.class.getName());
-        }
-        SPI.removeListener(l);
+        spi().removeListener(l);
     }
 
     /**
@@ -88,11 +83,7 @@ public final class ConfigEventManager {
      * @param eventType the event type to which this listener listens to.
      */
     public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
-        if (SPI == null) {
-            throw new ConfigException("No SPI registered for " +
-                    ConfigEventManager.class.getName());
-        }
-        SPI.removeListener(l);
+        spi().removeListener(l);
     }
 
     /**
@@ -103,7 +94,7 @@ public final class ConfigEventManager {
      */
     public static <T extends ConfigEvent>
         Collection<? extends ConfigEventListener> getListeners(Class<T> type) {
-        return SPI.getListeners(type);
+        return spi().getListeners(type);
     }
 
     /**
@@ -114,7 +105,7 @@ public final class ConfigEventManager {
      */
     public static <T extends ConfigEvent>
     Collection<? extends ConfigEventListener> getListeners() {
-        return SPI.getListeners();
+        return spi().getListeners();
     }
 
     /**
@@ -124,7 +115,7 @@ public final class ConfigEventManager {
      * @param event the event, not null.
      */
     public static <T> void fireEvent(ConfigEvent<?> event) {
-        SPI.fireEvent(event);
+        spi().fireEvent(event);
     }
 
     /**
@@ -134,7 +125,7 @@ public final class ConfigEventManager {
      * @param event the event, not null.
      */
     public static <T> void fireEventAsynch(ConfigEvent<?> event) {
-        SPI.fireEventAsynch(event);
+        spi().fireEventAsynch(event);
     }
 
     /**
@@ -150,7 +141,7 @@ public final class ConfigEventManager {
      * @see #getChangeMonitoringPeriod()
      */
     public static void enableChangeMonitoring(boolean enable) {
-        SPI.enableChangeMonitor(enable);
+        spi().enableChangeMonitor(enable);
     }
 
     /**
@@ -160,7 +151,7 @@ public final class ConfigEventManager {
      * @see #enableChangeMonitoring(boolean)
      */
     public static boolean isChangeMonitoring() {
-        return SPI.isChangeMonitorActive();
+        return spi().isChangeMonitorActive();
     }
 
     /**
@@ -169,7 +160,7 @@ public final class ConfigEventManager {
      * @return the check period in ms.
      */
     public static long getChangeMonitoringPeriod(){
-        return SPI.getChangeMonitoringPeriod();
+        return spi().getChangeMonitoringPeriod();
     }
 
     /**
@@ -180,7 +171,7 @@ public final class ConfigEventManager {
      * @see #isChangeMonitoring()
      */
     public static void setChangeMonitoringPeriod(long millis){
-        SPI.setChangeMonitoringPeriod(millis);
+        spi().setChangeMonitoringPeriod(millis);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/formats/base/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/formats/base/bnd.bnd b/modules/formats/base/bnd.bnd
index 2f8a324..0d351d1 100644
--- a/modules/formats/base/bnd.bnd
+++ b/modules/formats/base/bnd.bnd
@@ -1,3 +1,5 @@
 Export-Package: \
 	org.apache.tamaya.format,\
-	org.apache.tamaya.format.formats
\ No newline at end of file
+	org.apache.tamaya.format.formats
+Bundle-SymbolicName: org.apache.tamaya.formats
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/formats/json/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/formats/json/bnd.bnd b/modules/formats/json/bnd.bnd
index 45ee7d7..62cd3f9 100644
--- a/modules/formats/json/bnd.bnd
+++ b/modules/formats/json/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.json
\ No newline at end of file
+	org.apache.tamaya.json
+Bundle-SymbolicName: org.apache.tamaya.formats.json
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/formats/yaml/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/bnd.bnd b/modules/formats/yaml/bnd.bnd
index 325dbc7..fc92b02 100644
--- a/modules/formats/yaml/bnd.bnd
+++ b/modules/formats/yaml/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.yaml
\ No newline at end of file
+	org.apache.tamaya.yaml
+Bundle-SymbolicName: org.apache.tamaya.formats.yaml
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/functions/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/functions/bnd.bnd b/modules/functions/bnd.bnd
index 3951e26..62bda5d 100644
--- a/modules/functions/bnd.bnd
+++ b/modules/functions/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.functions
\ No newline at end of file
+	org.apache.tamaya.functions
+Bundle-SymbolicName: org.apache.tamaya.functions
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/injection/injection-api/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/injection/injection-api/bnd.bnd b/modules/injection/injection-api/bnd.bnd
index c68fb11..ea781a8 100644
--- a/modules/injection/injection-api/bnd.bnd
+++ b/modules/injection/injection-api/bnd.bnd
@@ -1,3 +1,6 @@
 Export-Package: \
 	org.apache.tamaya.inject.api,\
-	org.apache.tamaya.inject.spi
\ No newline at end of file
+	org.apache.tamaya.inject.spi
+Bundle-SymbolicName: org.apache.tamaya.inject.api
+Import-Package: org.apache.tamaya;version="[0.3,1)",\
+ org.apache.tamaya.inject.api,org.apache.tamaya.spi;version="[0.3,1)"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/injection/standalone/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/bnd.bnd b/modules/injection/standalone/bnd.bnd
index 8bfdf02..e886fba 100644
--- a/modules/injection/standalone/bnd.bnd
+++ b/modules/injection/standalone/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.inject
\ No newline at end of file
+	org.apache.tamaya.inject
+Bundle-SymbolicName: org.apache.tamaya.inject-se
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/optional/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/optional/bnd.bnd b/modules/optional/bnd.bnd
index 9463045..5c1ba27 100644
--- a/modules/optional/bnd.bnd
+++ b/modules/optional/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.optional
\ No newline at end of file
+	org.apache.tamaya.optional
+Bundle-SymbolicName: org.apache.tamaya.optional
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/resolver/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/resolver/bnd.bnd b/modules/resolver/bnd.bnd
index 21965e8..ea2ed8a 100644
--- a/modules/resolver/bnd.bnd
+++ b/modules/resolver/bnd.bnd
@@ -1,3 +1,5 @@
 Export-Package: \
 	org.apache.tamaya.resolver,\
-	org.apache.tamaya.resolver.spi
\ No newline at end of file
+	org.apache.tamaya.resolver.spi
+Bundle-SymbolicName: org.apache.tamaya.resolver
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/resources/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/resources/bnd.bnd b/modules/resources/bnd.bnd
index 44ece01..98f60ff 100644
--- a/modules/resources/bnd.bnd
+++ b/modules/resources/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.resource
\ No newline at end of file
+	org.apache.tamaya.resource
+Bundle-SymbolicName: org.apache.tamaya.resources
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/spi-support/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/spi-support/bnd.bnd b/modules/spi-support/bnd.bnd
index 37c99b7..6dafaa7 100644
--- a/modules/spi-support/bnd.bnd
+++ b/modules/spi-support/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.spisupport
\ No newline at end of file
+	org.apache.tamaya.spisupport
+Bundle-SymbolicName: org.apache.tamaya.spisupport
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/364604b0/modules/spring/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/spring/bnd.bnd b/modules/spring/bnd.bnd
index eb0c2fb..6ee583f 100644
--- a/modules/spring/bnd.bnd
+++ b/modules/spring/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.integration.spring
\ No newline at end of file
+	org.apache.tamaya.integration.spring
+Bundle-SymbolicName: org.apache.tamaya.spring
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file


[07/11] incubator-tamaya-extensions git commit: Added licence header.

Posted by an...@apache.org.
Added licence header.


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

Branch: refs/heads/master
Commit: 2c977a07d4c5ad2a715837726f7c25a759338ade
Parents: b06105f
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:19:01 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/features/package-info.java  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2c977a07/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
----------------------------------------------------------------------
diff --git a/modules/features/src/main/java/org/apache/tamaya/features/package-info.java b/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
index eeb00e5..78978c1 100644
--- a/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
+++ b/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 /**
  * Tamaya Feature Module.
  */


[09/11] incubator-tamaya-extensions git commit: Deprecated LoadPolicy, which is not really used.

Posted by an...@apache.org.
Deprecated LoadPolicy, which is not really used.


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

Branch: refs/heads/master
Commit: 78be87e5f7f6b604fc6a70084e59a86ca6c272ab
Parents: 2c977a0
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:19:33 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java     | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/78be87e5/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java b/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
index 31df739..b445e14 100644
--- a/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
+++ b/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
@@ -23,7 +23,9 @@ package org.apache.tamaya.inject.api;
  * for a {@link DynamicValue}.
  * The policy also affects the cases were any configured listeners/listener methods are called for
  * propagation current configuration changes.
+ * @deprecated Currently only used internally. Future usage unclear.
  */
+@Deprecated
 public enum LoadPolicy {
     /**
      * The configuration keys is evaluated once, when the owning component is loaded/configured, but never updated later.


[06/11] incubator-tamaya-extensions git commit: TAMAYA-236: improve ordinal handling.

Posted by an...@apache.org.
TAMAYA-236: improve ordinal handling.


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

Branch: refs/heads/master
Commit: 01610f6c794e41b366882f17396cbb6b05167699
Parents: a315ab4
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:01:37 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../tamaya/events/FrozenPropertySource.java     |   4 +-
 .../tamaya/events/FrozenPropertySourceTest.java |   4 +-
 .../tamaya/events/RandomPropertySource.java     |   5 -
 modules/functions/pom.xml                       |   5 +
 .../functions/ConfigWrappingPropertySource.java |   1 -
 .../functions/EnrichedPropertySource.java       |   4 +-
 .../functions/FilteredPropertySource.java       |   4 +-
 .../tamaya/functions/MappedPropertySource.java  |   4 +-
 .../functions/PropertySourceFunctions.java      |   4 -
 .../functions/ValueMappedPropertySource.java    |   4 +-
 .../cdi/DefaultConfigurationContext.java        |  89 +-------
 .../cdi/cfg/ProvidedPropertySource.java         |   1 -
 .../integration/cdi/cfg/TestPropertySource.java |   1 -
 .../tamaya/inject/TestPropertySource.java       |   5 -
 .../internal/DefaultDynamicValueTest.java       |   5 -
 modules/mutable-config/bnd.bnd                  |   4 +-
 .../MutableConfigurationProvider.java           |  21 +-
 .../tamaya/mutableconfig/Refreshable.java       |  33 ---
 .../RefreshablePropertySource.java              |  27 ---
 .../LazyRefreshablePropertySource.java          | 219 -------------------
 .../LazyRefreshablePropertySourceTest.java      | 162 --------------
 .../org/apache/tamaya/resolver/Resolver.java    |  18 +-
 .../internal/DefaultExpressionEvaluator.java    |  19 +-
 .../internal/ExpressionResolutionFilter.java    |  11 +-
 .../tamaya/resolver/MyTestPropertySource.java   |   5 -
 .../AbstractPathPropertySourceProvider.java     |   1 -
 .../PathBasedPropertySourceProvider.java        |   5 -
 .../tamaya/spisupport/BasePropertySource.java   |   1 -
 .../spisupport/DefaultConfigurationContext.java |   2 +-
 .../spisupport/PropertySourceComparator.java    |  39 +++-
 .../spisupport/BasePropertySourceTest.java      |   2 +-
 31 files changed, 103 insertions(+), 606 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
index 81e6dca..53f1dda 100644
--- a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ b/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.events;
 
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
 import java.io.Serializable;
 import java.util.Collections;
@@ -54,7 +55,7 @@ public final class FrozenPropertySource implements PropertySource, Serializable
         this.properties.putAll(propertySource.getProperties());
         this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
         this.properties = Collections.unmodifiableMap(this.properties);
-        this.ordinal = propertySource.getOrdinal();
+        this.ordinal = PropertySourceComparator.getOrdinal(propertySource);
         this.name = propertySource.getName();
     }
 
@@ -76,7 +77,6 @@ public final class FrozenPropertySource implements PropertySource, Serializable
         return this.name;
     }
 
-    @Override
     public int getOrdinal() {
         return this.ordinal;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java b/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
index 1431228..dc02127 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.events;
 
 import org.apache.tamaya.core.propertysource.SystemPropertySource;
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 import org.junit.Test;
 
 import java.util.Map;
@@ -50,7 +51,8 @@ public class FrozenPropertySourceTest {
     @Test
     public void testGetOrdinal() throws Exception {
         PropertySource ps = FrozenPropertySource.of(myPS);
-        assertEquals(myPS.getOrdinal(), ps.getOrdinal());
+        assertEquals(PropertySourceComparator.getOrdinal(myPS),
+                PropertySourceComparator.getOrdinal(ps));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java b/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
index dead0d9..c4414f1 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
@@ -32,11 +32,6 @@ public class RandomPropertySource implements PropertySource{
     private Map<String, String> data = new HashMap<>();
 
     @Override
-    public int getOrdinal() {
-        return 0;
-    }
-
-    @Override
     public String getName() {
         return "random";
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/pom.xml
----------------------------------------------------------------------
diff --git a/modules/functions/pom.xml b/modules/functions/pom.xml
index 2162fc4..3bd96cc 100644
--- a/modules/functions/pom.xml
+++ b/modules/functions/pom.xml
@@ -49,6 +49,11 @@ under the License.
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-spisupport</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.hamcrest</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
index 83a628a..a4bf810 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
@@ -48,7 +48,6 @@ final class ConfigWrappingPropertySource implements PropertySource {
         this.config = Objects.requireNonNull(config);
     }
 
-    @Override
     public int getOrdinal() {
         return ordinal;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
index de48fa8..d00e446 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.functions;
 
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -50,9 +51,8 @@ class EnrichedPropertySource implements PropertySource {
     }
 
 
-    @Override
     public int getOrdinal() {
-        return basePropertySource.getOrdinal();
+        return PropertySourceComparator.getOrdinal(basePropertySource);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
index 7eccdee..92c6946 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.functions;
 
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -43,9 +44,8 @@ class FilteredPropertySource implements PropertySource {
         this.filter = Objects.requireNonNull(filter);
     }
 
-    @Override
     public int getOrdinal(){
-        return baseSource.getOrdinal();
+        return PropertySourceComparator.getOrdinal(baseSource);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
index 3f85f53..793c62e 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.functions;
 
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -52,9 +53,8 @@ class MappedPropertySource implements PropertySource {
         this.keyMapper = Objects.requireNonNull(keyMapper);
     }
 
-    @Override
     public int getOrdinal() {
-        return this.propertySource.getOrdinal();
+        return PropertySourceComparator.getOrdinal(this.propertySource);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
index 93ff699..c3128c4 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
@@ -40,10 +40,6 @@ public final class PropertySourceFunctions {
      * Implementation of an empty propertySource.
      */
     private static final PropertySource EMPTY_PROPERTYSOURCE = new PropertySource() {
-        @Override
-        public int getOrdinal() {
-            return 0;
-        }
 
         @Override
         public String getName() {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java
index a06b8b6..eb212f5 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.functions;
 
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -41,9 +42,8 @@ class ValueMappedPropertySource implements PropertySource{
         this.source = Objects.requireNonNull(current);
     }
 
-    @Override
     public int getOrdinal() {
-        return source.getOrdinal();
+        return PropertySourceComparator.getOrdinal(source);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/injection/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/injection/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java b/modules/injection/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
index ae1f0bf..49f61a4 100644
--- a/modules/injection/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
+++ b/modules/injection/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
@@ -28,15 +28,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.apache.tamaya.spisupport.PropertyFilterComparator;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
-import javax.annotation.Priority;
 import javax.enterprise.inject.Vetoed;
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.locks.Lock;
@@ -77,13 +76,6 @@ public class DefaultConfigurationContext implements ConfigurationContext {
      */
     private final ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
 
-    /** Comparator used for ordering property sources. */
-    private final PropertySourceComparator propertySourceComparator = new PropertySourceComparator();
-
-    /** Comparator used for ordering property filters. */
-    private final PropertyFilterComparator propertyFilterComparator = new PropertyFilterComparator();
-
-
     /**
      * The first time the Configuration system gets invoked we do initialize
      * all our {@link PropertySource}s and
@@ -99,7 +91,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         propertySources.addAll(evaluatePropertySourcesFromProviders());
 
         // now sort them according to their ordinal values
-        Collections.sort(propertySources, new PropertySourceComparator());
+        Collections.sort(propertySources, PropertySourceComparator.getInstance());
 
         immutablePropertySources = Collections.unmodifiableList(propertySources);
         LOG.info("Registered " + immutablePropertySources.size() + " property sources: " +
@@ -108,7 +100,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         // as next step we pick up the PropertyFilters pretty much the same way
         List<PropertyFilter> propertyFilters = new ArrayList<>();
         propertyFilters.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
-        Collections.sort(propertyFilters, new PropertyFilterComparator());
+        Collections.sort(propertyFilters, PropertyFilterComparator.getInstance());
         immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
         LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
                 immutablePropertyFilters);
@@ -128,7 +120,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         // first we load all PropertySources which got registered via java.util.ServiceLoader
         propertySources.addAll(builder.getPropertySources());
         // now sort them according to their ordinal values
-        Collections.sort(propertySources, propertySourceComparator);
+        Collections.sort(propertySources, PropertySourceComparator.getInstance());
         immutablePropertySources = Collections.unmodifiableList(propertySources);
         LOG.info("Registered " + immutablePropertySources.size() + " property sources: " +
                 immutablePropertySources);
@@ -136,7 +128,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         // as next step we pick up the PropertyFilters pretty much the same way
         List<PropertyFilter> propertyFilters = new ArrayList<>();
         propertyFilters.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
-        Collections.sort(propertyFilters, propertyFilterComparator);
+        Collections.sort(propertyFilters, PropertyFilterComparator.getInstance());
         immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
         LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
                 immutablePropertyFilters);
@@ -163,10 +155,10 @@ public class DefaultConfigurationContext implements ConfigurationContext {
                     " provided the following property sources: " + sources);
                 propertySources.addAll(sources);
         }
-
         return propertySources;
     }
 
+    @Deprecated
     @Override
     public void addPropertySources(PropertySource... propertySourcesToAdd) {
         Lock writeLock = propertySourceLock.writeLock();
@@ -174,7 +166,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
             writeLock.lock();
             List<PropertySource> newPropertySources = new ArrayList<>(this.immutablePropertySources);
             newPropertySources.addAll(Arrays.asList(propertySourcesToAdd));
-            Collections.sort(newPropertySources, new PropertySourceComparator());
+            Collections.sort(newPropertySources, PropertySourceComparator.getInstance());
 
             this.immutablePropertySources = Collections.unmodifiableList(newPropertySources);
         } finally {
@@ -182,71 +174,6 @@ public class DefaultConfigurationContext implements ConfigurationContext {
         }
     }
 
-    /**
-     * Comparator used for ordering PropertySources.
-     */
-    private static class PropertySourceComparator implements Comparator<PropertySource>, Serializable {
-
-        private static final long serialVersionUID = 1L;
-
-        /**
-         * Order property source reversely, the most important come first.
-         *
-         * @param source1 the first PropertySource
-         * @param source2 the second PropertySource
-         * @return the comparison result.
-         */
-        private int comparePropertySources(PropertySource source1, PropertySource source2) {
-            if (source1.getOrdinal() < source2.getOrdinal()) {
-                return -1;
-            } else if (source1.getOrdinal() > source2.getOrdinal()) {
-                return 1;
-            } else {
-                return source1.getClass().getName().compareTo(source2.getClass().getName());
-            }
-        }
-
-        @Override
-        public int compare(PropertySource source1, PropertySource source2) {
-            return comparePropertySources(source1, source2);
-        }
-    }
-
-    /**
-     * Comparator used for ordering PropertyFilters.
-     */
-    private static class PropertyFilterComparator implements Comparator<PropertyFilter>, Serializable{
-
-        private static final long serialVersionUID = 1L;
-
-        /**
-         * 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);
-        }
-    }
-
     @Override
     public List<PropertySource> getPropertySources() {
         return immutablePropertySources;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java b/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
index f7e3c6d..a5a1755 100644
--- a/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
+++ b/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
@@ -40,7 +40,6 @@ class ProvidedPropertySource implements PropertySource{
         config.put("{meta}source.type:"+getClass().getName(), "PropertySourceProvider");
     }
 
-    @Override
     public int getOrdinal() {
         return 10;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java b/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
index 75c55ca..ca09065 100644
--- a/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
+++ b/modules/injection/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
@@ -52,7 +52,6 @@ public class TestPropertySource implements PropertySource{
         config.put("{meta}source.type:"+getClass().getName(), "PropertySource");
     }
 
-    @Override
     public int getOrdinal() {
         return 10;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
index 0853fd1..321f7f4 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
@@ -42,11 +42,6 @@ public class TestPropertySource implements PropertySource {
     }
 
     @Override
-    public int getOrdinal() {
-        return 0;
-    }
-
-    @Override
     public String getName() {
         return getClass().getName();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
index b3117fc..26ea2de 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
@@ -68,11 +68,6 @@ public class DefaultDynamicValueTest {
             ConfigurationProvider.getConfigurationContextBuilder().addPropertySources(
             new PropertySource() {
                 @Override
-                public int getOrdinal() {
-                    return 0;
-                }
-
-                @Override
                 public String getName() {
                     return "test";
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/mutable-config/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/mutable-config/bnd.bnd b/modules/mutable-config/bnd.bnd
index 89222d7..7df7f7e 100644
--- a/modules/mutable-config/bnd.bnd
+++ b/modules/mutable-config/bnd.bnd
@@ -1,2 +1,4 @@
 Export-Package: \
-	org.apache.tamaya.mutableconfig
\ No newline at end of file
+	org.apache.tamaya.mutableconfig
+Bundle-SymbolicName: org.apache.tamaya.mutableconfig
+Bundle-Version: 0.3-INCUBATING-SNAPSHOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
index 2e167a1..1198c09 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
@@ -42,21 +42,14 @@ public final class MutableConfigurationProvider {
     /**
      * URIs used by this query instance to identify the backends to use for write operations.
      */
-    private static MutableConfigurationProviderSpi mutableConfigurationProviderSpi = loadSpi();
-
-    /**
-     * SPI loader method.
-     * @throws ConfigException if loading fails.
-     * @return the SPI, never null.
-     */
-    private static MutableConfigurationProviderSpi loadSpi() {
-        try{
-            return ServiceContextManager.getServiceContext().getService(
+    private static MutableConfigurationProviderSpi spi(){
+            MutableConfigurationProviderSpi spi = ServiceContextManager.getServiceContext().getService(
                     MutableConfigurationProviderSpi.class)  ;
-        } catch(Exception e){
+        if(spi==null){
             throw new ConfigException("Failed to initialize MutableConfigurationProviderSpi - " +
                     "mutable configuration support.");
         }
+        return spi;
     }
 
 
@@ -70,7 +63,7 @@ public final class MutableConfigurationProvider {
      * @return a new MutableConfiguration instance
      */
     public static MutableConfiguration createMutableConfiguration(){
-        return mutableConfigurationProviderSpi.createMutableConfiguration(
+        return spi().createMutableConfiguration(
                 ConfigurationProvider.getConfiguration(), getApplyMostSignificantOnlyChangePolicy());
     }
 
@@ -82,7 +75,7 @@ public final class MutableConfigurationProvider {
      * @return a new MutableConfiguration instance, with the given change policy active.
      */
     public static MutableConfiguration createMutableConfiguration(ChangePropagationPolicy changePropgationPolicy){
-        return mutableConfigurationProviderSpi.createMutableConfiguration(
+        return spi().createMutableConfiguration(
                 ConfigurationProvider.getConfiguration(), changePropgationPolicy);
     }
 
@@ -109,7 +102,7 @@ public final class MutableConfigurationProvider {
      * @return a new MutableConfiguration instance
      */
     public static MutableConfiguration createMutableConfiguration(Configuration configuration, ChangePropagationPolicy changePropagationPolicy){
-        return mutableConfigurationProviderSpi.createMutableConfiguration(configuration, changePropagationPolicy);
+        return spi().createMutableConfiguration(configuration, changePropagationPolicy);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/Refreshable.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/Refreshable.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/Refreshable.java
deleted file mode 100644
index 685e5e5..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/Refreshable.java
+++ /dev/null
@@ -1,33 +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.mutableconfig;
-
-/**
- * Interface to be implemented by items that can be refreshed. By default
- * these are property sources, but more types may be supported at a later
- * point in time.
- */
-public interface Refreshable {
-
-    /**
-     * Refreshes the item by reloading its internal state.
-     */
-    void refresh();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/RefreshablePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/RefreshablePropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/RefreshablePropertySource.java
deleted file mode 100644
index 573f6d3..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/RefreshablePropertySource.java
+++ /dev/null
@@ -1,27 +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.mutableconfig;
-
-import org.apache.tamaya.spi.PropertySource;
-
-/**
- * Simple implementation of a mutable {@link org.apache.tamaya.spi.PropertySource} for .properties files.
- */
-public interface RefreshablePropertySource extends PropertySource, Refreshable{
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySource.java
deleted file mode 100644
index d5fce6f..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySource.java
+++ /dev/null
@@ -1,219 +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.mutableconfig.propertysources;
-
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.FrozenPropertySource;
-import org.apache.tamaya.events.PropertySourceChange;
-import org.apache.tamaya.events.PropertySourceChangeBuilder;
-import org.apache.tamaya.functions.Supplier;
-import org.apache.tamaya.mutableconfig.RefreshablePropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Simple implementation of a mutable {@link PropertySource} for .properties files.
- */
-public class LazyRefreshablePropertySource extends BasePropertySource
-implements RefreshablePropertySource {
-
-    /**
-     * The logger.
-     */
-    private static final Logger LOG = Logger.getLogger(LazyRefreshablePropertySource.class.getName());
-
-    /**
-     * Default update interval is 1 minute.
-     */
-    private static final long DEFAULT_UPDATE_INTERVAL = 60000L;
-
-    /**
-     * The property source name.
-     */
-    private Supplier<PropertySource> propertySourceSupplier;
-
-    /**
-     * The current propertySource.
-     */
-    private PropertySource propertySource;
-
-    /**
-     * Timestamp of last read.
-     */
-    private long lastRead;
-
-    /**
-     * Interval, when the resource should try to update its contents.
-     */
-    private long updateInterval = DEFAULT_UPDATE_INTERVAL;
-
-    private static boolean eventSupportLoaded = checkEventSupport();
-
-    private static boolean checkEventSupport() {
-        try{
-            Class.forName("org.apache.tamaya.events.ConfigEventManager");
-            return true;
-        }catch(Exception e){
-            return false;
-        }
-    }
-
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param defaultOrdinal the default ordinal to be used.
-     * @param propertySourceSupplier the property source supplier, not null.
-     */
-    private LazyRefreshablePropertySource(Supplier<PropertySource> propertySourceSupplier, int defaultOrdinal) {
-        super(defaultOrdinal);
-        this.propertySourceSupplier = Objects.requireNonNull(propertySourceSupplier);
-        this.propertySource = Objects.requireNonNull(propertySourceSupplier.get());
-    }
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param propertySourceSupplier the property source supplier, not null.
-     */
-    private LazyRefreshablePropertySource(Supplier<PropertySource> propertySourceSupplier) {
-        this.propertySourceSupplier = Objects.requireNonNull(propertySourceSupplier);
-        this.propertySource = Objects.requireNonNull(propertySourceSupplier.get());
-    }
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param defaultOrdinal the default ordinal to be used.
-     * @param propertySourceSupplier the property source supplier, not null.
-     */
-    public static LazyRefreshablePropertySource of(Supplier<PropertySource> propertySourceSupplier, int defaultOrdinal) {
-        return new LazyRefreshablePropertySource(propertySourceSupplier, defaultOrdinal);
-    }
-
-    /**
-     * Creates a new Properties based PropertySource based on the given URL.
-     *
-     * @param propertySourceSupplier the property source supplier, not null.
-     */
-    public static LazyRefreshablePropertySource of(Supplier<PropertySource> propertySourceSupplier) {
-        return new LazyRefreshablePropertySource(propertySourceSupplier);
-    }
-
-    /**
-     * Sets the current refreh interval.
-     * @param millis the new refreh interval in millis.
-     */
-    public void setUpdateInterval(long millis){
-        this.updateInterval = millis;
-    }
-
-    /**
-     * Access the current refresh interval.
-     * @return the current refresh interval.
-     */
-    public long getDefaultUpdateInterval(){
-        return this.updateInterval;
-    }
-
-    @Override
-    public PropertyValue get(String key) {
-        checkLoad();
-        return this.propertySource.get(key);
-    }
-
-    @Override
-    public String getName() {
-        return this.propertySource.getName();
-    }
-
-    @Override
-    public Map<String, String> getProperties() {
-        checkLoad();
-        return this.propertySource.getProperties();
-    }
-
-
-    private void checkLoad() {
-        if((lastRead+updateInterval)<System.currentTimeMillis()){
-            refresh();
-        }
-    }
-
-    /**
-     * Reloads the property source from its supplier. If Tamaya's event module is loaded corresoinding
-     * change events are triggered if changes were detected.
-     */
-    @Override
-    public void refresh() {
-        try{
-            Object previous = null;
-            if(eventSupportLoaded){
-                previous = FrozenPropertySource.of(this.propertySource);
-            }
-            this.propertySource = Objects.requireNonNull(propertySourceSupplier.get());
-            if(eventSupportLoaded){
-                PropertySourceChange changeEvent = PropertySourceChangeBuilder.of(
-                        (PropertySource)previous)
-                        .addChanges(this.propertySource).build();
-                if(!changeEvent.isEmpty()) {
-                    ConfigEventManager.fireEvent(changeEvent);
-                }
-            }
-        } catch (Exception e) {
-            LOG.log(Level.WARNING, "Cannot refresh property source " + propertySource.getName(), e);
-        }
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o){
-            return true;
-        }
-        if (!(o instanceof LazyRefreshablePropertySource)){
-            return false;
-        }
-
-        LazyRefreshablePropertySource that = (LazyRefreshablePropertySource) o;
-
-        return propertySource.getName().equals(that.propertySource.getName());
-
-    }
-
-    @Override
-    public int hashCode() {
-        return propertySource.getName().hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return "RefreshablePropertySource{" +
-                "\n  name=" + getName() +
-                "\n  delegate=" + propertySource +
-                "\n  lastRead=" + lastRead +
-                "\n  updateInterval=" + updateInterval +
-                "\n}";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySourceTest.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySourceTest.java
deleted file mode 100644
index e67ca59..0000000
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/propertysources/LazyRefreshablePropertySourceTest.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.mutableconfig.propertysources;
-
-import org.apache.tamaya.functions.Supplier;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spisupport.SimplePropertySource;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link LazyRefreshablePropertySource}. Created by atsticks on 11.11.16.
- */
-public class LazyRefreshablePropertySourceTest {
-
-    private SimplePropertySource simplePropertySource = new SimplePropertySource(
-        getClass().getClassLoader().getResource("test.properties")
-    );
-    private SimplePropertySource simplePropertySource2 = new SimplePropertySource(
-            getClass().getClassLoader().getResource("test2.properties")
-    );
-    private volatile boolean selectFirst;
-
-    @Test
-    public void of() throws Exception {
-        assertNotNull(LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }
-        ));
-    }
-
-    @Test
-    public void of_WithDefaultOrdinal() throws Exception {
-        assertNotNull(LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }, 100
-        ));
-    }
-
-    @Test
-    public void get() throws Exception {
-        LazyRefreshablePropertySource ps = LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }
-        );
-        assertEquals(ps.get("test1").getValue(), "test1");
-        assertEquals(ps.get("test2").getValue(), "test2");
-        assertNull(ps.get("test3"));
-    }
-
-    @Test
-    public void getName() throws Exception {
-        LazyRefreshablePropertySource ps = LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }
-        );
-        assertEquals(ps.getName(), simplePropertySource.getName());
-    }
-
-    @Test
-    public void getProperties() throws Exception {
-        LazyRefreshablePropertySource ps = LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }
-        );
-        assertEquals(ps.getProperties(), simplePropertySource.getProperties());
-    }
-
-    @Test
-    public void refresh() throws Exception {
-        LazyRefreshablePropertySource ps1 = LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        try {
-                            if (selectFirst) {
-                                return simplePropertySource;
-                            } else {
-                                return simplePropertySource2;
-                            }
-                        }finally{
-                            selectFirst = !selectFirst;
-                        }
-                    }
-                }
-        );
-        // Simulate a refresh with the switching provider created above...
-        ps1.setUpdateInterval(1L);
-        if(ps1.get("test3")!=null){
-            Thread.sleep(5L); //  NOSONAR
-            assertEquals("test4", ps1.get("test4").getValue());
-        }else{
-            Thread.sleep(5L); //  NOSONAR
-            assertNull("test3", ps1.get("test3"));
-        }
-    }
-
-    @Test
-    public void testEqualsAndHashCode() throws Exception {
-        LazyRefreshablePropertySource ps1 = LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }
-        );
-        LazyRefreshablePropertySource ps2 = LazyRefreshablePropertySource.of(
-                new Supplier<PropertySource>() {
-                    @Override
-                    public PropertySource get() {
-                        return simplePropertySource;
-                    }
-                }
-        );
-        assertEquals(ps1, ps2);
-        assertEquals(ps1.hashCode(), ps2.hashCode());
-    }
-
-    @Test
-    public void testToString() throws Exception {
-
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
index eadb547..c2bc908 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.resolver;
 
+import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
 import org.apache.tamaya.resolver.spi.ExpressionResolver;
 import org.apache.tamaya.spi.ServiceContextManager;
@@ -41,8 +42,15 @@ public final class Resolver {
      * @return the filtered/evaluated value, including null.
      */
     public static String evaluateExpression(String key, String value){
-        return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class)
-                .evaluateExpression(key, value, true);
+        return evaluator().evaluateExpression(key, value, true);
+    }
+
+    private static ExpressionEvaluator evaluator() {
+        ExpressionEvaluator evaluator = ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class);
+        if(evaluator==null){
+            throw new ConfigException("No ExpressionEvaluator registered.");
+        }
+        return evaluator;
     }
 
     /**
@@ -62,8 +70,7 @@ public final class Resolver {
      * @return the filtered/evaluated value, including null.
      */
     public static String evaluateExpression(String value, boolean maskNotFound){
-        return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class)
-                .evaluateExpression(null, value, maskNotFound);
+        return evaluator().evaluateExpression(null, value, maskNotFound);
     }
 
     /**
@@ -71,7 +78,6 @@ public final class Resolver {
      * @return the resolvers currently known, never null.
      */
     public static Collection<ExpressionResolver> getResolvers(){
-        return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class)
-                .getResolvers();
+        return evaluator().getResolvers();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
index 85fe845..20e289b 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
@@ -37,7 +37,6 @@ public class DefaultExpressionEvaluator implements ExpressionEvaluator {
 
     private static final Logger LOG = Logger.getLogger(DefaultExpressionEvaluator.class.getName());
 
-    private final List<ExpressionResolver> resolvers = new ArrayList<>();
 
     /**
      * Comparator used (not needed with Java8).
@@ -50,16 +49,6 @@ public class DefaultExpressionEvaluator implements ExpressionEvaluator {
     };
 
     /**
-     * Default constructor.
-     */
-    public DefaultExpressionEvaluator() {
-        for (ExpressionResolver resolver : ServiceContextManager.getServiceContext().getServices(ExpressionResolver.class)) {
-            resolvers.add(resolver);
-        }
-        Collections.sort(resolvers, RESOLVER_COMPARATOR);
-    }
-
-    /**
      * Order ExpressionResolver reversely, the most important come first.
      *
      * @param res1 the first ExpressionResolver
@@ -161,7 +150,12 @@ public class DefaultExpressionEvaluator implements ExpressionEvaluator {
 
     @Override
     public Collection<ExpressionResolver> getResolvers() {
-        return new ArrayList<>(this.resolvers);
+        List<ExpressionResolver> resolvers = new ArrayList<>();
+        for (ExpressionResolver resolver : ServiceContextManager.getServiceContext().getServices(ExpressionResolver.class)) {
+            resolvers.add(resolver);
+        }
+        Collections.sort(resolvers, RESOLVER_COMPARATOR);
+        return resolvers;
     }
 
     /**
@@ -229,6 +223,7 @@ public class DefaultExpressionEvaluator implements ExpressionEvaluator {
     private String evaluateInternal(String unresolvedExpression, boolean maskUnresolved) {
         String value = null;
         // 1 check for explicit prefix
+        Collection<ExpressionResolver> resolvers = getResolvers();
         for(ExpressionResolver resolver:resolvers){
             if(unresolvedExpression.startsWith(resolver.getResolverPrefix())){
                 value = resolver.evaluate(unresolvedExpression.substring(resolver.getResolverPrefix().length()));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
index 20e2c7a..bd90083 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.resolver.internal;
 
+import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
 import org.apache.tamaya.spi.FilterContext;
 import org.apache.tamaya.spi.PropertyFilter;
@@ -36,7 +37,13 @@ public class ExpressionResolutionFilter implements PropertyFilter {
 
     private static final Logger LOG = Logger.getLogger(ExpressionResolutionFilter.class.getName());
 
-    private final ExpressionEvaluator evaluator = ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class);
+    private final ExpressionEvaluator evaluator(){
+        ExpressionEvaluator evaluator = ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class);
+        if(evaluator==null){
+            throw new ConfigException("No ExpressionEvaluator registered.");
+        }
+        return evaluator;
+    }
 
     /**
      * Resolves an expression in the form current <code>${resolverId:expression}</code> or
@@ -79,7 +86,7 @@ public class ExpressionResolutionFilter implements PropertyFilter {
     @Override
     public String filterProperty(String valueToBeFiltered, FilterContext context){
         LOG.finest("Resolving " + valueToBeFiltered + "(key=" + context.getKey() + ")");
-        return evaluator.evaluateExpression(context.getKey(), valueToBeFiltered, true);
+        return evaluator().evaluateExpression(context.getKey(), valueToBeFiltered, true);
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
index 7d99cbc..1c26f31 100644
--- a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
+++ b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
@@ -76,11 +76,6 @@ public class MyTestPropertySource implements PropertySource{
     }
 
     @Override
-    public int getOrdinal() {
-        return 0;
-    }
-
-    @Override
     public String getName() {
         return "test";
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java b/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
index 791f2c2..6a6398a 100644
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
+++ b/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
@@ -150,7 +150,6 @@ public abstract class AbstractPathPropertySourceProvider implements PropertySour
             this.properties.putAll(props);
         }
 
-        @Override
         public int getOrdinal() {
             PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
             if (configuredOrdinal != null) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
index 7ea9b4c..1299a0c 100644
--- a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
+++ b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
@@ -70,11 +70,6 @@ public class PathBasedPropertySourceProvider extends AbstractPathPropertySourceP
         }
 
         @Override
-        public int getOrdinal() {
-            return 0;
-        }
-
-        @Override
         public String getName() {
             return name;
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
index 30ff90d..9ae130a 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
@@ -106,7 +106,6 @@ public abstract class BasePropertySource implements PropertySource{
         this.defaultOrdinal = defaultOrdinal;
     }
 
-    @Override
     public int getOrdinal() {
         Integer ordinal = this.ordinal;
         if(ordinal!=null){

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
index 7b177a2..f5c97d6 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
@@ -178,7 +178,7 @@ public class DefaultConfigurationContext implements ConfigurationContext {
                 b.append("  ");
                 appendFormatted(b, ps.getClass().getSimpleName(), 30);
                 appendFormatted(b, ps.getName(), 70);
-                appendFormatted(b, String.valueOf(ps.getOrdinal()), 8);
+                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);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
index 71e3ffb..96fffad 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
@@ -19,9 +19,14 @@
 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.
@@ -30,6 +35,8 @@ public class PropertySourceComparator implements Comparator<PropertySource>, Ser
     /** 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 PropertySourceComparator(){}
@@ -51,15 +58,43 @@ public class PropertySourceComparator implements Comparator<PropertySource>, Ser
      * @return the comparison result.
      */
     private int comparePropertySources(PropertySource source1, PropertySource source2) {
-        if (source1.getOrdinal() < source2.getOrdinal()) {
+        if (getOrdinal(source1) < getOrdinal(source2)) {
             return -1;
-        } else if (source1.getOrdinal() > source2.getOrdinal()) {
+        } else if (getOrdinal(source1) > getOrdinal(source2)) {
             return 1;
         } else {
             return source1.getClass().getName().compareTo(source2.getClass().getName());
         }
     }
 
+    public static int getOrdinal(PropertySource propertySource) {
+        PropertyValue ordinalValue = propertySource.get(PropertySource.TAMAYA_ORDINAL);
+        if(ordinalValue!=null){
+            try{
+                return Integer.parseInt(ordinalValue.getValue().trim());
+            }catch(Exception e){
+                LOG.finest("Failed to parse ordinal from " + PropertySource.TAMAYA_ORDINAL +
+                        " in " + propertySource.getName()+": "+ordinalValue.getValue());
+            }
+        }
+        try {
+            Method method = propertySource.getClass().getMethod("getOrdinal");
+            if(int.class.equals(method.getReturnType())){
+                try {
+                    return (int)method.invoke(propertySource);
+                } catch (Exception e) {
+                    LOG.log(Level.FINEST, "Error calling int getOrdinal() on " + propertySource.getName(), e);
+                }
+            }
+        } catch (NoSuchMethodException e) {
+            LOG.finest("No int getOrdinal() method found in " + propertySource.getName());
+        }
+        Priority prio = propertySource.getClass().getAnnotation(Priority.class);
+        if(prio!=null){
+            return prio.value();
+        }
+        return 0;
+    }
     @Override
     public int compare(PropertySource source1, PropertySource source2) {
         return comparePropertySources(source1, source2);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/01610f6c/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
index dc24165..2cdac70 100644
--- a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
@@ -47,7 +47,7 @@ public class BasePropertySourceTest {
             }
         };
 
-        Assert.assertEquals(56, defaultPropertySource.getOrdinal());
+        Assert.assertEquals(56, PropertySourceComparator.getOrdinal(defaultPropertySource));
         Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
 
         // propertySource with invalid ordinal


[02/11] incubator-tamaya-extensions git commit: Renamed pom project name.

Posted by an...@apache.org.
Renamed pom project name.


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

Branch: refs/heads/master
Commit: 6805cba419d92756900947cf81c1de8f23b20558
Parents: e86db7d
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:38:09 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6805cba4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 860068c..371a3e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@ under the License.
     <version>0.3-incubating-SNAPSHOT</version>
     <packaging>pom</packaging>
 
-    <name>Apache Tamaya Extensions - all</name>
+    <name>Apache Tamaya Extensions</name>
     <description>Extension modules for Apache Tamaya</description>
     <url>https://tamaya.incubator.apache.org</url>
     <inceptionYear>2016</inceptionYear>


[03/11] incubator-tamaya-extensions git commit: TAMAYA-240: ConfigFormat. readXX should throw IOException instead of ConfigException

Posted by an...@apache.org.
TAMAYA-240: ConfigFormat. readXX should throw IOException instead of ConfigException


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

Branch: refs/heads/master
Commit: b06105f8eac8a00d4da30daf0cef84c7f79d358d
Parents: 364604b
Author: anatole <an...@apache.org>
Authored: Thu Feb 23 01:15:24 2017 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../BaseFormatPropertySourceProvider.java       | 39 ++------
 .../tamaya/format/ConfigurationFormat.java      |  9 +-
 .../tamaya/format/ConfigurationFormats.java     | 99 +++++++++++++++++++-
 .../format/formats/IniConfigurationFormat.java  | 12 ++-
 .../tamaya/format/formats/PropertiesFormat.java | 12 +--
 .../format/formats/PropertiesXmlFormat.java     | 22 ++---
 .../java/org/apache/tamaya/json/JSONFormat.java | 13 ++-
 .../apache/tamaya/json/JSONPropertySource.java  | 15 +--
 .../yaml/CommonJSONTestCaseCollection.java      | 12 ++-
 .../tamaya/yaml/JSONPropertySourceTest.java     |  3 +-
 .../java/org/apache/tamaya/yaml/YAMLFormat.java | 35 +++----
 .../apache/tamaya/yaml/YAMLPropertySource.java  |  5 +-
 12 files changed, 164 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/base/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
index 49f05df..e0e39d3 100644
--- a/modules/formats/base/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
+++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
@@ -140,39 +140,20 @@ public abstract class BaseFormatPropertySourceProvider implements PropertySource
     @Override
     public Collection<PropertySource> getPropertySources() {
         List<PropertySource> propertySources = new ArrayList<>();
-        byte[] buff = new byte[512];
         for (URL res : this.paths) {
-            byte[] dataBytes = null;
-            int read = 0;
-            try(InputStream is = res.openStream();
-                ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
-                read = is.read(buff);
-                while (read > 0) {
-                    bos.write(buff, 0, read);
-                    read = is.read(buff);
-                }
-                bos.flush();
-                dataBytes = bos.toByteArray();
-            } catch (Exception e) {
-                LOG.log(Level.WARNING, "Failed to read resource based config: " + res, e);
-            }
-            if(dataBytes!=null) {
-                try (InputStream is = new ByteArrayInputStream(dataBytes);) {
-                    for (ConfigurationFormat format : configFormats) {
-                        try {
-                            if (format.accepts(res)) {
-                                ConfigurationData data = format.readConfiguration(res.toString(), is);
-                                propertySources.addAll(getPropertySources(data));
-                            }
-                        } catch (Exception e) {
-                            LOG.log(Level.WARNING, "Failed to put resource based config: " + res, e);
-                        } finally {
-                            is.reset();
+            try{
+                for (ConfigurationFormat format : configFormats) {
+                    try (InputStream inputStream = res.openStream()){
+                        if (format.accepts(res)) {
+                            ConfigurationData data = format.readConfiguration(res.toString(), inputStream);
+                            propertySources.addAll(getPropertySources(data));
                         }
+                    } catch (Exception e) {
+                        LOG.log(Level.WARNING, "Failed to put resource based config: " + res, e);
                     }
-                } catch (Exception e) {
-                    LOG.log(Level.WARNING, "Failed to put resource based config: " + res, e);
                 }
+            } catch (Exception e) {
+                LOG.log(Level.WARNING, "Failed to put resource based config: " + res, e);
             }
         }
         return propertySources;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
index ee11207..e8e48a2 100644
--- a/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
+++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.format;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 
@@ -53,6 +54,7 @@ public interface ConfigurationFormat {
      */
     boolean accepts(URL url);
 
+
     /**
      * Reads a configuration from an URL, hereby parsing the given {@link java.io.InputStream}. Dependening on
      * the capabilities of the format the returned {@link org.apache.tamaya.format.ConfigurationData} may contain
@@ -89,12 +91,11 @@ public interface ConfigurationFormat {
      * ladder case multiple PropertySources can be returned, each one with its own ordinal and the corresponding
      * entries.
      * @see org.apache.tamaya.spi.PropertySource
-     * @param resource a descriptive name for the resource, since an InputStream does not have any)
-     * @param inputStream the inputStream to read the configuration data from (could be a file, a server location, a classpath
-     *            resource or something else.
+     * @param inputStream the inputStream to read from, not null.
+     * @param resource the resource id, not null.
      * @return the corresponding {@link ConfigurationData} containing sections/properties read, never {@code null}.
      * @throws org.apache.tamaya.ConfigException if parsing of the input fails.
      */
-    ConfigurationData readConfiguration(String resource, InputStream inputStream);
+    ConfigurationData readConfiguration(String resource, InputStream inputStream) throws IOException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
----------------------------------------------------------------------
diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
index 5b2d819..f08e967 100644
--- a/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
+++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
@@ -21,10 +21,18 @@ package org.apache.tamaya.format;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.ServiceContextManager;
 
 /**
@@ -191,13 +199,12 @@ public final class ConfigurationFormats {
      * @param inputStream the inputStream from where to read, not null.
      * @param formats     the formats to try.
      * @return the ConfigurationData read, or null.
-     * @throws IOException if the resource cannot be read.
+     * @throws ConfigException if the resource cannot be read.
      */
     public static ConfigurationData readConfigurationData(String resource, InputStream inputStream,
                                                           Collection<ConfigurationFormat> formats) throws IOException {
-        Objects.requireNonNull(inputStream);
-        Objects.requireNonNull(resource);
-        try(InputStreamFactory isFactory = new InputStreamFactory(inputStream)) {
+        Objects.requireNonNull(resource, "Config resource required for traceability.");
+        try(InputStreamFactory isFactory = new InputStreamFactory(Objects.requireNonNull(inputStream))) {
             for (final ConfigurationFormat format : formats) {
                 try (InputStream is = isFactory.createInputStream()) {
                     final ConfigurationData data = format.readConfiguration(resource, is);
@@ -213,5 +220,87 @@ public final class ConfigurationFormats {
         return null;
     }
 
+    /**
+     * Tries to read configuration data from a given URL, hereby explicitly trying all given formats
+     * in order and transforms it into a {@link PropertySource} using a default mapping.
+     *
+     * @param url    the URL to read, not null.
+     * @param formats     the formats to try. If not formats are passed explicitly, all known formats
+     *                    are tried.
+     * @return a corresponding property source, or null.
+     * @throws ConfigException if the resource cannot be read.
+     * @throws IOException if the URL's stream can not be opened.
+     */
+    public static PropertySource createPropertySource(URL url, ConfigurationFormat... formats)throws IOException{
+        return createPropertySource(url.toString(), url.openStream(), formats);
+    }
+
+    /**
+     * Tries to read configuration data from a given URL, hereby explicitly trying all given formats
+     * in order and transforms it into a {@link PropertySource} using a default mapping.
+     *
+     * @param url    the URL to read, not null.
+     * @param formats     the formats to try. If not formats are passed explicitly, all known formats
+     *                    are tried.
+     * @return a corresponding property source, or null.
+     * @throws ConfigException if the resource cannot be read.
+     * @throws IOException if the URL's stream can not be opened.
+     */
+    public static PropertySource createPropertySource(URL url, Collection<ConfigurationFormat> formats)throws IOException{
+        return createPropertySource(url.toString(), url.openStream(), formats);
+    }
+
+    /**
+     * Tries to read configuration data from a given URL, hereby explicitly trying all given formats
+     * in order and transforms it into a {@link PropertySource} using a default mapping.
+     *
+     * @param resource    a descriptive name for the resource, since an InputStream does not have any
+     * @param inputStream the inputStream from where to read, not null.
+     * @param formats     the formats to try. If not formats are passed explicitly, all known formats
+     *                    are tried.
+     * @return a corresponding property source, or null.
+     * @throws ConfigException if the resource cannot be read.
+     */
+    public static PropertySource createPropertySource(String resource, InputStream inputStream,
+                                                      ConfigurationFormat... formats){
+        return createPropertySource(resource, inputStream, Arrays.asList(formats));
+    }
+
+
+    /**
+     * Tries to read configuration data from a given URL, hereby explicitly trying all given formats
+     * in order and transforms it into a {@link PropertySource} using a default mapping.
+     *
+     * @param resource    a descriptive name for the resource, since an InputStream does not have any
+     * @param inputStream the inputStream from where to read, not null.
+     * @param formats     the formats to try. If not formats are passed explicitly, all known formats
+     *                    are tried.
+     * @return a corresponding property source, or null.
+     * @throws ConfigException if the resource cannot be read.
+     */
+    public static PropertySource createPropertySource(String resource, InputStream inputStream,
+                                                       Collection<ConfigurationFormat> formats) {
+        Objects.requireNonNull(resource, "Config resource required for traceability.");
+        try(InputStreamFactory isFactory = new InputStreamFactory(Objects.requireNonNull(inputStream))) {
+            if(formats.isEmpty()){
+                formats = getFormats();
+            }
+            for (final ConfigurationFormat format : formats) {
+                try (InputStream is = isFactory.createInputStream()) {
+                    final ConfigurationData data = format.readConfiguration(resource, is);
+                    if (data != null) {
+                        return new MappedConfigurationDataPropertySource(data);
+                    }
+                } catch (final Exception e) {
+                    LOG.log(Level.INFO,
+                            "Format " + format.getClass().getName() + " failed to read resource " + resource, e);
+                }
+            }
+        }catch(IOException ioe){
+            throw new ConfigException("Failed to read from input stream for "+resource, ioe);
+        }
+        throw new ConfigException("No matching format found for "+resource+", tried: "+ formats);
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
index ea52367..af2cd94 100644
--- a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
+++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
@@ -24,10 +24,10 @@ import org.apache.tamaya.format.ConfigurationDataBuilder;
 import org.apache.tamaya.format.ConfigurationFormat;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -52,7 +52,8 @@ public class IniConfigurationFormat implements ConfigurationFormat {
     }
 
     @Override
-    public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
+    public ConfigurationData readConfiguration(String resource, InputStream inputStream)
+    throws IOException{
         ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(resource, this);
         try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) {
             String line = reader.readLine();
@@ -88,8 +89,11 @@ public class IniConfigurationFormat implements ConfigurationFormat {
             }
             return builder.build();
         } catch (Exception e) {
-            LOG.log(Level.SEVERE, "Could not read configuration: " + resource, e);
+            if(e instanceof IOException){
+                throw (IOException)e;
+            }else{
+                throw new IOException("Could not read configuration: " + resource, e);
+            }
         }
-        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
index c45185b..42388c3 100644
--- a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
+++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
@@ -22,12 +22,11 @@ import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationDataBuilder;
 import org.apache.tamaya.format.ConfigurationFormat;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Properties;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -56,16 +55,9 @@ public class PropertiesFormat implements ConfigurationFormat {
 
     @SuppressWarnings("unchecked")
     @Override
-    public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
-        Objects.requireNonNull(inputStream);
-        Objects.requireNonNull(resource);
-        try {
+    public ConfigurationData readConfiguration(String resource, InputStream inputStream)throws IOException {
             final Properties p = new Properties();
             p.load(inputStream);
             return ConfigurationDataBuilder.of(resource, this).addDefaultProperties(Map.class.cast(p)).build();
-        } catch (Exception e) {
-            LOG.log(Level.FINEST, "Failed to read config from resource: " + resource, e);
-        }
-        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java
index df150ea..61b45f1 100644
--- a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java
+++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java
@@ -22,10 +22,11 @@ import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationDataBuilder;
 import org.apache.tamaya.format.ConfigurationFormat;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
+import java.util.Map;
+import java.util.Properties;
 import java.util.logging.Logger;
 
 /**
@@ -53,17 +54,10 @@ public class PropertiesXmlFormat implements ConfigurationFormat {
 
     @SuppressWarnings("unchecked")
     @Override
-    public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
-        Objects.requireNonNull(inputStream);
-        Objects.requireNonNull(resource);
-
-        try {
-            final Properties p = new Properties();
-            p.loadFromXML(inputStream);
-            return ConfigurationDataBuilder.of(resource, this).addDefaultProperties(Map.class.cast(p)).build();
-        } catch (Exception e) {
-            LOG.log(Level.FINEST, "Failed to read config from resource: " + resource, e);
-        }
-        return null;
+    public ConfigurationData readConfiguration(String resource, InputStream inputStream)
+    throws IOException{
+        final Properties p = new Properties();
+        p.loadFromXML(inputStream);
+        return ConfigurationDataBuilder.of(resource, this).addDefaultProperties(Map.class.cast(p)).build();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
index 66f684e..5902cbd 100644
--- a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
+++ b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
@@ -18,11 +18,11 @@
  */
 package org.apache.tamaya.json;
 
-import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationDataBuilder;
 import org.apache.tamaya.format.ConfigurationFormat;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.nio.charset.Charset;
@@ -31,7 +31,6 @@ import java.util.Map;
 import java.util.Objects;
 
 import javax.json.Json;
-import javax.json.JsonException;
 import javax.json.JsonObject;
 import javax.json.JsonReader;
 import javax.json.JsonReaderFactory;
@@ -68,9 +67,9 @@ public class JSONFormat implements ConfigurationFormat {
     }
 
     @Override
-    public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
-
-        try {
+    public ConfigurationData readConfiguration(String resource, InputStream inputStream)
+    throws IOException{
+        try{
             final JsonReader reader = this.readerFactory.createReader(inputStream, Charset.forName("UTF-8"));
             JsonObject root = reader.readObject();
             HashMap<String, String> values = new HashMap<>();
@@ -78,8 +77,8 @@ public class JSONFormat implements ConfigurationFormat {
             visitor.run();
             return ConfigurationDataBuilder.of(resource, this).addDefaultProperties(values)
                                            .build();
-        } catch (JsonException e) {
-            throw new ConfigException("Failed to read data from " + resource, e);
+        } catch(Exception e) {
+            throw new IOException("Failed to read data from " + resource, e);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
index 18d64ce..1ac5ee7 100644
--- a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
+++ b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
@@ -22,6 +22,7 @@ import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.nio.charset.Charset;
@@ -66,7 +67,7 @@ public class JSONPropertySource implements PropertySource {
      * Constructor, hereby using 0 as the default ordinal.
      * @param resource the resource modelled as URL, not null.
      */
-    public JSONPropertySource(URL resource) {
+    public JSONPropertySource(URL resource)throws IOException {
         this(resource, 0);
     }
 
@@ -75,7 +76,7 @@ public class JSONPropertySource implements PropertySource {
      * @param resource the resource modelled as URL, not null.
      * @param defaultOrdinal the defaultOrdinal to be used.
      */
-    public JSONPropertySource(URL resource, int defaultOrdinal) {
+    public JSONPropertySource(URL resource, int defaultOrdinal)throws IOException {
         urlResource = Objects.requireNonNull(resource);
         this.ordinal = defaultOrdinal; // may be overriden by read...
         this.values = readConfig(urlResource);
@@ -88,7 +89,6 @@ public class JSONPropertySource implements PropertySource {
     }
 
 
-    @Override
     public int getOrdinal() {
         PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
         if(configuredOrdinal!=null){
@@ -123,7 +123,7 @@ public class JSONPropertySource implements PropertySource {
      * @return the configuration read from the given resource URL.
      * @throws ConfigException if resource URL cannot be read.
      */
-    protected Map<String, String> readConfig(URL urlResource) {
+    protected Map<String, String> readConfig(URL urlResource) throws IOException{
         try (InputStream is = urlResource.openStream()) {
             JsonStructure root = this.readerFactory.createReader(is, Charset.forName("UTF-8")).read();
 
@@ -136,9 +136,10 @@ public class JSONPropertySource implements PropertySource {
             JSONVisitor visitor = new JSONVisitor((JsonObject)root, values);
             visitor.run();
             return values;
-        }
-        catch (Throwable t) {
-            throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
+        }catch(IOException ioe){
+            throw ioe;
+        }catch (Exception t) {
+            throw new IOException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
index 297c7cf..1d93d20 100644
--- a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
+++ b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
@@ -21,10 +21,12 @@ package org.apache.tamaya.yaml;
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 import org.hamcrest.CoreMatchers;
 import org.hamcrest.Matchers;
 import org.junit.Test;
 
+import java.io.IOException;
 import java.net.URL;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -107,7 +109,7 @@ public abstract class CommonJSONTestCaseCollection {
         assertThat(keyDP.getValue(), is("P"));
     }
 
-    @Test(expected = ConfigException.class)
+    @Test(expected = IOException.class)
     public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception {
         URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/with-array.json");
 
@@ -116,7 +118,7 @@ public abstract class CommonJSONTestCaseCollection {
         getPropertiesFrom(configURL).getProperties();
     }
 
-    @Test(expected = ConfigException.class)
+    @Test(expected = IOException.class)
     public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception {
         URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/only-opening-bracket.json");
 
@@ -125,7 +127,7 @@ public abstract class CommonJSONTestCaseCollection {
         getPropertiesFrom(configURL).getProperties();
     }
 
-    @Test(expected = ConfigException.class)
+    @Test(expected = IOException.class)
     public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception {
         URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
 
@@ -142,7 +144,7 @@ public abstract class CommonJSONTestCaseCollection {
 
         PropertySource properties = getPropertiesFrom(configURL);
 
-        assertThat(properties.getOrdinal(), is(16784));
+        assertThat(PropertySourceComparator.getOrdinal(properties), is(16784));
     }
 
     @Test
@@ -167,7 +169,7 @@ public abstract class CommonJSONTestCaseCollection {
         assertThat(keyC.getValue(), is("C"));
     }
 
-    @Test(expected = ConfigException.class)
+    @Test(expected = IOException.class)
     public void emptyJSONFileResultsInConfigException() throws Exception {
         URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
index 83944f5..015ad0a 100644
--- a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
+++ b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
@@ -24,6 +24,7 @@ import org.apache.tamaya.spi.PropertySource;
 import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 
+import java.io.IOException;
 import java.net.URL;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -41,7 +42,7 @@ public class JSONPropertySourceTest extends CommonJSONTestCaseCollection {
         assertEquals(source.get(PropertySource.TAMAYA_ORDINAL).getValue(), "16784");
     }
     
-    @Test(expected=ConfigException.class)
+    @Test(expected=IOException.class)
     public void testDoNotAcceptJsonArrays() throws Exception {
         URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/array.json");
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
index bdb83aa..adf7b34 100644
--- a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
+++ b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
@@ -48,12 +48,6 @@ public class YAMLFormat implements ConfigurationFormat {
      */
     private static final Logger LOG = Logger.getLogger(YAMLFormat.class.getName());
 
-    /**
-     * Constructor, itniaitlizing zhe JSON reader factory.
-     */
-    public YAMLFormat(){
-    }
-
     @Override
     public String getName() {
         return "yaml";
@@ -66,13 +60,9 @@ public class YAMLFormat implements ConfigurationFormat {
 
     @Override
     public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
-        try( InputStream in = inputStream;) {
-            Map<String, String> values = readConfig(resource, inputStream);
-            return ConfigurationDataBuilder.of(resource, this).addProperties(values)
-                .build();
-        } catch (Exception e) {
-            throw new ConfigException("Failed to read data from " + resource, e);
-        }
+        Map<String, String> values = readConfig(resource, inputStream);
+        return ConfigurationDataBuilder.of(resource, this).addProperties(values)
+            .build();
     }
 
     /**
@@ -83,19 +73,16 @@ public class YAMLFormat implements ConfigurationFormat {
      * @throws ConfigException if resource URI cannot be read.
      */
     protected Map<String, String> readConfig(String resource, InputStream inputStream) {
-        try{
-            Yaml yaml = new Yaml();
-            HashMap<String, String> values = new HashMap<>();
-            Object config = yaml.load(inputStream);
-            mapYamlIntoProperties(config, values);
-            if(LOG.isLoggable(Level.FINEST)){
-                LOG.finest("Read data from " + resource + " : " + values);
-            }
-            return values;
-        }catch (Throwable t) {
-            throw new ConfigException(format("Failed to read properties from %s", resource), t);
+        Yaml yaml = new Yaml();
+        HashMap<String, String> values = new HashMap<>();
+        Object config = yaml.load(inputStream);
+        mapYamlIntoProperties(config, values);
+        if(LOG.isLoggable(Level.FINEST)){
+            LOG.finest("Read data from " + resource + " : " + values);
         }
+        return values;
     }
+
     /**
      * Reads the configuration.
      * @param urlResource soure of the configuration.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b06105f8/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
index 9edc15b..ae54624 100644
--- a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
+++ b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
@@ -22,7 +22,9 @@ import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
 
 import java.net.URL;
-import java.util.*;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -63,7 +65,6 @@ public class YAMLPropertySource implements PropertySource {
         }
     }
 
-    @Override
     public int getOrdinal() {
         PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
         if(configuredOrdinal!=null){