tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [06/11] incubator-tamaya-extensions git commit: TAMAYA-236: improve ordinal handling.
Date Sun, 26 Feb 2017 23:05:19 GMT
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 <anatole@apache.org>
Authored: Thu Feb 23 01:01:37 2017 +0100
Committer: anatole <anatole@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


Mime
View raw message