Repository: incubator-tamaya-extensions Updated Branches: refs/heads/master 773526d6c -> 02cf6e69d
TAMAYA-182: Added additional constructors for better support for programmtic configuration context composition using the builder API and explicit ordinal overriding. 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/02cf6e69 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/02cf6e69 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/02cf6e69 Branch: refs/heads/master Commit: 02cf6e69d5bfed2e4bd70cc726c11b8851674df9 Parents: 773526d Author: anatole <[email protected]> Authored: Fri Nov 11 09:52:16 2016 +0100 Committer: anatole <[email protected]> Committed: Fri Nov 11 09:52:16 2016 +0100 ---------------------------------------------------------------------- modules/functions/pom.xml | 5 ++++ .../tamaya/functions/SimplePropertySource.java | 30 ++++---------------- 2 files changed, 11 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/02cf6e69/modules/functions/pom.xml ---------------------------------------------------------------------- diff --git a/modules/functions/pom.xml b/modules/functions/pom.xml index f8c27f2..9d40858 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/02cf6e69/modules/functions/src/main/java/org/apache/tamaya/functions/SimplePropertySource.java ---------------------------------------------------------------------- diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/SimplePropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/SimplePropertySource.java index 5dad7bb..c6fc4b3 100644 --- a/modules/functions/src/main/java/org/apache/tamaya/functions/SimplePropertySource.java +++ b/modules/functions/src/main/java/org/apache/tamaya/functions/SimplePropertySource.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.BasePropertySource; import java.util.HashMap; import java.util.Map; @@ -30,35 +31,21 @@ import java.util.logging.Logger; /** * Simple property source implementation using a map. */ -public class SimplePropertySource implements PropertySource { +public class SimplePropertySource extends BasePropertySource { /** The properties. */ private final Map<String, String> properties; /** The source's name. */ private final String name; - /** The default ordinal. */ - private int defaultOrdinal; public SimplePropertySource(String name, Map<String, String> properties){ this.properties = new HashMap<>(properties); this.name = Objects.requireNonNull(name); } - @Override - public int getOrdinal(){ - PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); - if(configuredOrdinal!=null){ - try{ - return Integer.parseInt(configuredOrdinal.getValue()); - } catch(Exception e){ - Logger.getLogger(getClass().getName()).log(Level.WARNING, - "Configured Ordinal is not an int number: " + configuredOrdinal, e); - } - } - return getDefaultOrdinal(); - } - - public int getDefaultOrdinal(){ - return defaultOrdinal; + public SimplePropertySource(String name, Map<String, String> properties, int defaultOrdinal){ + super(defaultOrdinal); + this.properties = new HashMap<>(properties); + this.name = Objects.requireNonNull(name); } @Override @@ -78,11 +65,6 @@ public class SimplePropertySource implements PropertySource { } @Override - public boolean isScannable() { - return false; - } - - @Override public String toString(){ return "SimplePropertySource(name="+name+", numProps="+properties.size()+")"; }
