You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/06 17:18:05 UTC

[09/50] [abbrv] incubator-tamaya-sandbox git commit: TAMAYA-115: Implemented multi classpath environment PropertySourceProvider, with relocation capability.

TAMAYA-115: Implemented multi classpath environment PropertySourceProvider, with relocation capability.


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

Branch: refs/heads/master
Commit: 7b9d4e69a6aa4c850b5d62e38c2c38a43853d9ef
Parents: cfbc38d
Author: anatole <an...@apache.org>
Authored: Wed Oct 7 23:00:18 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Mon Oct 12 08:01:47 2015 +0200

----------------------------------------------------------------------
 environment/pom.xml                             |  68 ---------
 .../BaseEnvironmentPropertySourceProvider.java  | 119 ----------------
 .../tamaya/environment/spi/package-info.java    |  23 ----
 ...org.apache.tamaya.spi.PropertySourceProvider |  19 ---
 .../src/test/resources/GLOBAL.properties        |  19 ---
 environment/src/test/resources/TEST.properties  |  19 ---
 metamodels/staged/pom.xml                       |  68 +++++++++
 .../spi/BaseStagedPropertySourceProvider.java   | 121 ++++++++++++++++
 .../spi/StagedConfigPropertiesProvider.java     | 137 +++++++++++++++++++
 .../apache/tamaya/staged/spi/package-info.java  |  23 ++++
 ...org.apache.tamaya.spi.PropertySourceProvider |  19 +++
 .../staged/src/test/resources/GLOBAL.properties |  19 +++
 .../staged/src/test/resources/TEST.properties   |  19 +++
 13 files changed, 406 insertions(+), 267 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/environment/pom.xml
----------------------------------------------------------------------
diff --git a/environment/pom.xml b/environment/pom.xml
deleted file mode 100644
index c2e1745..0000000
--- a/environment/pom.xml
+++ /dev/null
@@ -1,68 +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 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-sandbox</artifactId>
-        <version>0.2-incubating-SNAPSHOT</version>
-        <relativePath>..</relativePath>
-    </parent>
-
-    <artifactId>tamaya-environment</artifactId>
-    <name>Apache Tamaya Modules - Environment Manager</name>
-    <packaging>jar</packaging>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tamaya</groupId>
-            <artifactId>tamaya-core</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tamaya</groupId>
-            <artifactId>tamaya-api</artifactId>
-            <version>${project.version}</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tamaya.ext</groupId>
-            <artifactId>tamaya-functions</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tamaya.ext</groupId>
-            <artifactId>tamaya-spisupport</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tamaya.ext</groupId>
-            <artifactId>tamaya-resources</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-        </dependency>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/environment/src/main/java/org/apache/tamaya/environment/spi/BaseEnvironmentPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/environment/src/main/java/org/apache/tamaya/environment/spi/BaseEnvironmentPropertySourceProvider.java b/environment/src/main/java/org/apache/tamaya/environment/spi/BaseEnvironmentPropertySourceProvider.java
deleted file mode 100644
index 5924640..0000000
--- a/environment/src/main/java/org/apache/tamaya/environment/spi/BaseEnvironmentPropertySourceProvider.java
+++ /dev/null
@@ -1,119 +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.environment.spi;
-
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * Implements a base property source that defines a multilayered environment setup.
- */
-public abstract class BaseEnvironmentPropertySourceProvider implements PropertySourceProvider {
-
-    private static final Logger LOGGER = Logger.getLogger(BaseEnvironmentPropertySourceProvider.class.getName());
-
-    private int basePriority;
-
-    private int priorityIncrease;
-
-    private List<String> environmentIds = new ArrayList<>();
-
-    private String environmentRootContext;
-
-    private List<PropertySource> propertySources = new ArrayList<>();
-
-
-    /**
-     * Creates a new Environment provider, hereby using 10 for basePriority and priorityIncrease.
-     * @param environmentRootContext the environment target root context, e.g. ENV. or null
-     *                               for not remapping the environment properties.
-     * @param environmentIds the context ids, that build up the environment.
-     */
-    public BaseEnvironmentPropertySourceProvider(String environmentRootContext,
-                                                 String... environmentIds) {
-        this(environmentRootContext, 10,10,environmentIds);
-    }
-        /**
-         * Creates a new Environment provider.
-         * @param environmentRootContext the environment target root context, e.g. ENV. or null
-         *                               for not remapping the environment properties.
-         * @param basePriority the base priority used for the weakest environment properties set.
-         * @param priorityIncrease the value the property source's priority should be increased with each
-         *                         environment context level added.
-         * @param environmentIds the context ids, that build up the environment.
-         */
-    public BaseEnvironmentPropertySourceProvider(String environmentRootContext, int basePriority, int priorityIncrease,
-                                                 String... environmentIds) {
-        this.basePriority = basePriority;
-        this.priorityIncrease = priorityIncrease;
-        if (environmentIds.length == 0) {
-            throw new ConfigException("At least one environment context id must be defined.");
-        }
-        if (environmentRootContext == null) {
-            LOGGER.finest("No environment mapping is applied.");
-        }
-        this.environmentRootContext = environmentRootContext;
-        this.environmentIds.addAll(Arrays.asList(environmentIds));
-        int priority = basePriority;
-        for (String contextId : environmentIds) {
-            propertySources.addAll(loadEnvProperties(environmentRootContext, contextId, priority));
-            priority += priorityIncrease;
-        }
-    }
-
-    /**
-     * Method that loads the environment properties for the given contextId.
-     * @param environmentRootContext the root context, where entries should be mapped to.
-     * @param contextId the contextId.
-     * @param priority  the target priority the created PropertySource should have. This priority is important, since it reflects the
-     *                  environment context overriding rules for the environment part created.
-     * @return the corresponding PrioritySources to be added, never null.
-     */
-    protected abstract Collection<PropertySource> loadEnvProperties(
-            String environmentRootContext, String contextId, int priority);
-
-    /**
-     * Get the environment context ids that define how this environment configuration
-     * is setup, in order of priority increasing.
-     * @return the ordered list of context ids.
-     */
-    public List<String> getEnvironmentIds() {
-        return environmentIds;
-    }
-
-    @Override
-    public String toString() {
-        return "EnvironmentPropertySourceProvider{" +
-                "environmentIds=" + environmentIds +
-                ", environmentRootContext='" + environmentRootContext + '\'' +
-                '}';
-    }
-
-    @Override
-    public Collection<PropertySource> getPropertySources() {
-        return propertySources;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/environment/src/main/java/org/apache/tamaya/environment/spi/package-info.java
----------------------------------------------------------------------
diff --git a/environment/src/main/java/org/apache/tamaya/environment/spi/package-info.java b/environment/src/main/java/org/apache/tamaya/environment/spi/package-info.java
deleted file mode 100644
index 9037c2b..0000000
--- a/environment/src/main/java/org/apache/tamaya/environment/spi/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Main API of the environment module, containing the base class for implementing adapted
- * environment parts in your configuration.
- */
-package org.apache.tamaya.environment.spi;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/environment/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/environment/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/environment/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
deleted file mode 100644
index 233448a..0000000
--- a/environment/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
+++ /dev/null
@@ -1,19 +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 current the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.environment.internal.ClasspathPropertiesEnvironmentProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/environment/src/test/resources/GLOBAL.properties
----------------------------------------------------------------------
diff --git a/environment/src/test/resources/GLOBAL.properties b/environment/src/test/resources/GLOBAL.properties
deleted file mode 100644
index 9f39f75..0000000
--- a/environment/src/test/resources/GLOBAL.properties
+++ /dev/null
@@ -1,19 +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 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.
-#
-aKey=aValue.GLOBAL

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/environment/src/test/resources/TEST.properties
----------------------------------------------------------------------
diff --git a/environment/src/test/resources/TEST.properties b/environment/src/test/resources/TEST.properties
deleted file mode 100644
index 2b31cb3..0000000
--- a/environment/src/test/resources/TEST.properties
+++ /dev/null
@@ -1,19 +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 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.
-#
-aKey=aValue.TEST

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/pom.xml
----------------------------------------------------------------------
diff --git a/metamodels/staged/pom.xml b/metamodels/staged/pom.xml
new file mode 100644
index 0000000..325e4ec
--- /dev/null
+++ b/metamodels/staged/pom.xml
@@ -0,0 +1,68 @@
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy 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.metamodels</groupId>
+        <artifactId>tamaya-metamodels</artifactId>
+        <version>0.2-incubating-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>tamaya-metamodel-staged</artifactId>
+    <name>Apache Tamaya Modules - Staged Configuration</name>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-core</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-api</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-functions</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-spisupport</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-resources</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
new file mode 100644
index 0000000..36fcd11
--- /dev/null
+++ b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
@@ -0,0 +1,121 @@
+/*
+ * 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.staged.spi;
+
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+/**
+ * Implements a base property source provider that defines a multilayered
+ * stage setup.
+ */
+public abstract class BaseStagedPropertySourceProvider implements PropertySourceProvider {
+
+    /** The logger used. */
+    private static final Logger LOGGER = Logger.getLogger(BaseStagedPropertySourceProvider.class.getName());
+
+    /** the current environment stages in order of precedence (weakest first). */
+    private List<String> contextIds = new ArrayList<>();
+
+    /** Optional root context of the environment in the config tree. All entries loaded will be mapped into
+     * this root conztext.
+     */
+    private String rootContext;
+
+    /** List of PropertySources evaluated and returned to the current ConfigurationContext on load. */
+    private List<PropertySource> propertySources = new ArrayList<>();
+
+
+    /**
+     * Creates a new Environment provider, hereby using 10 for basePriority and priorityIncrease.
+     * @param rootContext the environment target root context, e.g. ENV. or null
+     *                               for not remapping the environment properties.
+     * @param contextIds the context ids, that build up the environment.
+     */
+    public BaseStagedPropertySourceProvider(String rootContext,
+                                            String... contextIds) {
+        this(rootContext, 10,10, contextIds);
+    }
+        /**
+         * Creates a new Environment provider.
+         * @param rootContext the environment target root context, e.g. ENV. or null
+         *                               for not remapping the environment properties.
+         * @param basePriority the base priority used for the weakest environment properties set.
+         * @param priorityIncrease the value the property source's priority should be increased with each
+         *                         environment context level added.
+         * @param contextIds the context ids, that build up the environment.
+         */
+    public BaseStagedPropertySourceProvider(String rootContext, int basePriority, int priorityIncrease,
+                                            String... contextIds) {
+        if (contextIds.length == 0) {
+            throw new ConfigException("At least one environment context id must be defined.");
+        }
+        if (rootContext == null) {
+            LOGGER.finest("No environment mapping is applied.");
+        }
+        this.rootContext = rootContext;
+        this.contextIds.addAll(Arrays.asList(contextIds));
+        int priority = basePriority;
+        for (String contextId : contextIds) {
+            propertySources.addAll(loadStageProperties(rootContext, contextId, priority));
+            priority += priorityIncrease;
+        }
+    }
+
+    /**
+     * Method that loads the environment properties for the given contextId.
+     * @param rootContext the root context, where entries read should be mapped to.
+     * @param contextId the contextId.
+     * @param priority  the target priority the created PropertySource should have. This priority is
+     *                  important, since it reflects the order as defined
+     *                  when configuring this class. Therefore it should not be overridden normally.
+     * @return the corresponding PrioritySources to be added, never null.
+     */
+    protected abstract Collection<PropertySource> loadStageProperties(
+            String rootContext, String contextId, int priority);
+
+    /**
+     * Get the environment context ids that define how this environment configuration
+     * is setup, in order of their increasing priority.
+     * @return the ordered list of context ids.
+     */
+    public List<String> getContextIds() {
+        return contextIds;
+    }
+
+    @Override
+    public String toString() {
+        return "EnvironmentPropertySourceProvider{" +
+                "contextIds=" + contextIds +
+                ", rootContext='" + rootContext + '\'' +
+                '}';
+    }
+
+    @Override
+    public Collection<PropertySource> getPropertySources() {
+        return propertySources;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
new file mode 100644
index 0000000..e224d52
--- /dev/null
+++ b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tamaya.staged.spi;
+
+
+import org.apache.tamaya.spisupport.MapPropertySource;
+import org.apache.tamaya.spisupport.PropertiesResourcePropertySource;
+import org.apache.tamaya.resource.ConfigResources;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+/**
+ * Configuration provider that resolves to a location in the classpath.
+ * Hereby the following system properties can be set to configure the provider
+ * (all entries are optional):
+ * <pre>
+ *     env.STAGE   :   ordered list of configs to be loaded, e.g. sys-env,GLOBAL,TEST,DEV
+ * </pre>
+ * Adding {@code sys-env} as stage maps the current environment properties using
+ * the priority to be aliged with the context ordering, defined by {@code env.STAGE}.
+ * Similarly the same thing can be done by passing {@code sys-props} as context id for
+ * adding the current System properties to the configuration tree.
+ *
+ * The rootContext can be used to remap the whole property space to an alternate subtree in
+ * the configuration tree overall. This is very handy, if multiple instances of this class
+ * are registered into the same configuration, but with different location setups. Remapping
+ * configuration allows to separate these entries clearly.<br/>
+ * Finally the resource location can be adapted by overriding {@link #getBaseResourcePath()}.
+ * Different formats and loading mechanisms can be implemented by overriding
+ * {@link #loadProperties(String, String, int, List)}.
+ */
+public class StagedConfigPropertiesProvider extends BaseStagedPropertySourceProvider {
+
+    /** The system property to define the stages used. */
+    private static final String STAGE_PROP = "env.STAGE";
+    /** The logger used. */
+
+    private static final Logger LOGGER = Logger.getLogger(StagedConfigPropertiesProvider.class.getName());
+
+    /** The context id for adding the system's environment properties. */
+    private static final String DEFAULT_ENV = "sys-env";
+
+    /** The context id for adding the system's properties. */
+    private static final String DEFAULT_SYSPROPS = "sys-props";
+
+    /**
+     * Creates a new instance.
+     * @param rootContext the (optional) root context, can be null.
+     * @param stages the comma separated list of stages.
+     */
+    public StagedConfigPropertiesProvider(String rootContext, String... stages){
+        super(rootContext, evaluateStages(stages));
+    }
+
+    /**
+     * Creates a default instance. the stages are read from the {@code env.STAGE} system�propertx
+     * or a default is applied.
+     */
+    public StagedConfigPropertiesProvider(){
+        super(null, evaluateStages(null));
+    }
+
+    /**
+     * Evaluates the stages or returns the default STAGE entry.
+     * @return the stages to be used, never null.
+     */
+    private static String[] evaluateStages(String[] stages) {
+        if(stages!=null && stages.length>0){
+            return stages.clone();
+        }
+        String value = System.getProperty(STAGE_PROP);
+        if(value==null) {
+            value = System.getenv(STAGE_PROP);
+        }
+        if(value==null){
+            value = "sys-env,GLOBAL,DEVELOPMENT,sys-props";
+        }
+        return value.split(",");
+    }
+
+    @Override
+    protected Collection<PropertySource> loadStageProperties(
+            String rootContext, String contextId, int priority) {
+        List<PropertySource> result = new ArrayList<>();
+        if (DEFAULT_ENV.equals(contextId)){
+            result.add(new MapPropertySource(DEFAULT_ENV, System.getenv(),
+                    rootContext, priority));
+        }else if (DEFAULT_SYSPROPS.equals(contextId)){
+            result.add(new MapPropertySource(DEFAULT_SYSPROPS, System.getProperties(),
+                    rootContext, priority));
+        }
+        else{
+            loadProperties(rootContext, contextId, priority, result);
+        }
+        return result;
+    }
+
+    private void loadProperties(String rootContext, String contextId, int priority,
+                                List<PropertySource> result) {
+        String cpExp = getBaseResourcePath()+'/' +contextId+".properties";
+        if(cpExp.startsWith("/")){
+            cpExp = cpExp.substring(1);
+        }
+        for(URL url: ConfigResources.getResourceResolver().getResources(cpExp)){
+            result.add(new PropertiesResourcePropertySource(rootContext, url, priority));
+        }
+    }
+
+    /**
+     * Get the basic resource path used for lookup of properties files.
+     * @return the basic resource path, never null.
+     */
+    protected String getBaseResourcePath() {
+        return "";
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
new file mode 100644
index 0000000..9037c2b
--- /dev/null
+++ b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Main API of the environment module, containing the base class for implementing adapted
+ * environment parts in your configuration.
+ */
+package org.apache.tamaya.environment.spi;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
new file mode 100644
index 0000000..2bdf843
--- /dev/null
+++ b/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy current the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.staged.spi.StagedConfigPropertiesProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/src/test/resources/GLOBAL.properties
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/resources/GLOBAL.properties b/metamodels/staged/src/test/resources/GLOBAL.properties
new file mode 100644
index 0000000..9f39f75
--- /dev/null
+++ b/metamodels/staged/src/test/resources/GLOBAL.properties
@@ -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.
+#
+aKey=aValue.GLOBAL

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7b9d4e69/metamodels/staged/src/test/resources/TEST.properties
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/resources/TEST.properties b/metamodels/staged/src/test/resources/TEST.properties
new file mode 100644
index 0000000..2b31cb3
--- /dev/null
+++ b/metamodels/staged/src/test/resources/TEST.properties
@@ -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.
+#
+aKey=aValue.TEST