TAMAYA-59: Fixed existing simple model to work with current API and other deps.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/bfbaefa4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/bfbaefa4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/bfbaefa4 Branch: refs/heads/master Commit: bfbaefa4314ab36ae9fc1e25880268dc106ba44d Parents: dc022af Author: anatole <[email protected]> Authored: Sun Jan 18 01:08:58 2015 +0100 Committer: anatole <[email protected]> Committed: Sun Jan 18 01:09:28 2015 +0100 ---------------------------------------------------------------------- modules/metamodels/pom.xml | 2 +- modules/metamodels/simple/pom.xml | 24 ++++++++++- .../metamodel/simple/MapPropertySource.java | 44 ++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bfbaefa4/modules/metamodels/pom.xml ---------------------------------------------------------------------- diff --git a/modules/metamodels/pom.xml b/modules/metamodels/pom.xml index 4eecdc4..a42c287 100644 --- a/modules/metamodels/pom.xml +++ b/modules/metamodels/pom.xml @@ -23,7 +23,7 @@ under the License. <parent> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-extensions</artifactId> - <version>0.2-incubating-SNAPSHOT</version> + <version>0.1-incubating-SNAPSHOT</version> <relativePath>..</relativePath> </parent> <groupId>org.apache.tamaya.ext.metamodels</groupId> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bfbaefa4/modules/metamodels/simple/pom.xml ---------------------------------------------------------------------- diff --git a/modules/metamodels/simple/pom.xml b/modules/metamodels/simple/pom.xml index 898ab2f..6665762 100644 --- a/modules/metamodels/simple/pom.xml +++ b/modules/metamodels/simple/pom.xml @@ -23,7 +23,7 @@ under the License. <parent> <groupId>org.apache.tamaya.ext.metamodels</groupId> <artifactId>tamaya-metamodels</artifactId> - <version>0.1-SNAPSHOT</version> + <version>0.1-incubating-SNAPSHOT</version> <relativePath>..</relativePath> </parent> <artifactId>tamaya-metamodel-simple</artifactId> @@ -31,4 +31,26 @@ under the License. <description>Simple Tamaya Metamodel, e.g. feasible for SE commandline tools and simple use cases.</description> <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>org.apache.tamaya</groupId> + <artifactId>tamaya-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-resources</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-formats</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bfbaefa4/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java b/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java new file mode 100644 index 0000000..f2d237b --- /dev/null +++ b/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java @@ -0,0 +1,44 @@ +package org.apache.tamaya.metamodel.simple; + +import org.apache.tamaya.spi.PropertySource; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Created by Anatole on 17.01.2015. + */ +public class MapPropertySource implements PropertySource { + private int ordinal; + private String name; + private Map<String, String> properties = new HashMap<>(); + + public MapPropertySource(int ordinal, String name, Map<String, String> properties) { + this.ordinal = ordinal; + this.name = Objects.requireNonNull(name); + this.properties.putAll(properties); + this.properties = Collections.unmodifiableMap(this.properties); + } + + @Override + public int getOrdinal() { + return ordinal; + } + + @Override + public String getName() { + return name; + } + + @Override + public String get(String key) { + return properties.get(key); + } + + @Override + public Map<String, String> getProperties() { + return properties; + } +}
