You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2014/12/24 02:12:12 UTC
[2/6] incubator-tamaya git commit: TAMAYA-19: - Moved out much of
unused/experimental code. - Reduced API (removing package private singletons)
- Aligned PropertySource with Deltaspike (mostly). - Moved Environment model
to separate metamodel module.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
deleted file mode 100644
index 3592434..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
+++ /dev/null
@@ -1,22 +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.core.internal.env.InitialEnvironmentProvider
-org.apache.tamaya.core.internal.env.SystemClassLoaderEnvironmentProvider
-org.apache.tamaya.core.internal.env.ClassLoaderDependentEarEnvironmentProvider
-org.apache.tamaya.core.internal.env.ClassLoaderDependentApplicationEnvironmentProvider
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecSpi
new file mode 100644
index 0000000..c0a61aa
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecSpi
@@ -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.core.internal.config.DefaultCodecSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecsSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecsSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecsSingletonSpi
deleted file mode 100644
index 599b50f..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.CodecsSingletonSpi
+++ /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.core.internal.properties.DefaultCodecsSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
deleted file mode 100644
index 1020ab5..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
+++ /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.core.internal.config.DefaultConfigurationManagerSingletonSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi
new file mode 100644
index 0000000..2764092
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi
@@ -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.core.internal.config.DefaultConfigurationSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.EnvironmentManagerSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.EnvironmentManagerSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.EnvironmentManagerSingletonSpi
deleted file mode 100644
index b1a7ea5..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.EnvironmentManagerSingletonSpi
+++ /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.core.internal.env.SingleEnvironmentManager
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
deleted file mode 100644
index 40575b2..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
+++ /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.core.internal.env.DefaultStagesSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
index 1c1559a..2ee83a9 100644
--- a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
+++ b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
@@ -25,18 +25,18 @@ import static org.junit.Assert.assertTrue;
import org.apache.tamaya.annotation.ConfiguredProperty;
import org.apache.tamaya.annotation.DefaultValue;
-import org.apache.tamaya.core.internal.config.DefaultConfigurationManagerSingletonSpi;
+import org.apache.tamaya.core.internal.config.DefaultConfigurationSpi;
import org.junit.Test;
/**
- * Test class for {@link org.apache.tamaya.core.internal.config.DefaultConfigurationManagerSingletonSpi}.
+ * Test class for {@link org.apache.tamaya.core.internal.config.DefaultConfigurationSpi}.
*/
public class DefaultConfigurationManagerSingletonSpiSingletonSpiTest {
@Test
public void testSEConfigurationService() {
- new DefaultConfigurationManagerSingletonSpi();
+ new DefaultConfigurationSpi();
}
@Test
@@ -44,41 +44,24 @@ public class DefaultConfigurationManagerSingletonSpiSingletonSpiTest {
Configuration config = Configuration.current("default");
assertNotNull(config);
assertTrue(config.toString().contains("default"));
- assertNotNull(config.getMetaInfo());
- assertTrue(config.getMetaInfo().toString().contains("default"));
+ assertNotNull(config.getName());
+ assertTrue(config.getName().contains("default"));
System.out.println("CONFIG: " + config);
assertEquals(System.getProperty("java.version"),
config.get("java.version").get());
config = Configuration.current("system.properties");
assertNotNull(config);
- assertNotNull(config.getMetaInfo());
- assertTrue(config.getMetaInfo().toString().contains("system.properties"));
+ assertNotNull(config.getName());
+ assertTrue(config.getName().contains("system.properties"));
assertEquals(System.getProperty("java.version"),
config.get("java.version").get());
}
@Test
public void testIsConfigurationDefined() {
- assertTrue(Configuration.isDefined("test"));
- assertFalse(Configuration.isDefined("sdksajdsajdlkasj dlkjaslkd"));
- }
-
- @Test
- public void testGetCurrentEnvironment() {
- Environment env = Environment.current();
- assertNotNull(env);
- assertEquals(System.getProperty("java.version"),
- env.get("java.version").get());
- }
-
- @Test
- public void testGetRootEnvironment() {
-// DefaultConfigurationManagerSingletonSpi s = new DefaultConfigurationManagerSingletonSpi();
- Environment env = Environment.root();
- assertNotNull(env);
- assertEquals(System.getProperty("java.version"),
- env.get("java.version").get());
+ assertTrue(Configuration.isAvailable("test"));
+ assertFalse(Configuration.isAvailable("sdksajdsajdlkasj dlkjaslkd"));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/JavaOneDemo.java b/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
index 4287e68..e4c93ef 100644
--- a/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
+++ b/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
+import org.apache.tamaya.core.config.ConfigFunctions;
import org.apache.tamaya.core.properties.PropertySourceBuilder;
import org.junit.Test;
@@ -56,13 +57,13 @@ public class JavaOneDemo {
"classpath:test.properties").addPaths("classpath:cfg/test.xml")
.addArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"})
.addMap(cfgMap).build().toConfiguration();
- System.out.println(config.getAreas());
+ System.out.println(config.query(ConfigFunctions.getAreas()));
System.out.println("---");
- System.out.println(config.getAreas(s -> s.startsWith("another")));
+ System.out.println(config.query(ConfigFunctions.getAreas(s -> s.startsWith("another"))));
System.out.println("---");
- System.out.println(config.getTransitiveAreas());
+ System.out.println(config.query(ConfigFunctions.getTransitiveAreas()));
System.out.println("---");
- System.out.println(config.getTransitiveAreas(s -> s.startsWith("another")));
+ System.out.println(config.query(ConfigFunctions.getTransitiveAreas(s -> s.startsWith("another"))));
System.out.println("---");
System.out.println(config);
System.out.print("--- b=");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/core/config/ConfiguredSystemPropertiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/config/ConfiguredSystemPropertiesTest.java b/core/src/test/java/org/apache/tamaya/core/config/ConfiguredSystemPropertiesTest.java
new file mode 100644
index 0000000..7790d8b
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/core/config/ConfiguredSystemPropertiesTest.java
@@ -0,0 +1,94 @@
+///*
+// * 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.core.config;
+//
+//import static org.junit.Assert.assertTrue;
+//
+//import java.util.Properties;
+//
+//import org.apache.tamaya.core.env.ConfiguredSystemProperties;
+//import org.junit.Test;
+//
+///**
+// * Created by Anatole on 02.10.2014.
+// */
+//public class ConfiguredSystemPropertiesTest {
+//
+// @Test
+// public void testInstall(){
+//// Configuration config = Configuration.current();
+// Properties props = System.getProperties();
+// assertTrue(props.getClass().getName().equals(Properties.class.getName()));
+// System.out.println("Props("+props.getClass().getName()+"): " + props);
+// ConfiguredSystemProperties.install();
+// props = System.getProperties();
+// System.out.println("Props("+props.getClass().getName()+"): " + props);
+// assertTrue(props.getClass().getName().equals(ConfiguredSystemProperties.class.getName()));
+// ConfiguredSystemProperties.uninstall();
+// props = System.getProperties();
+// assertTrue(props.getClass().getName().equals(Properties.class.getName()));
+// }
+//}
+///*
+// * 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.core.config;
+//
+//import static org.junit.Assert.assertTrue;
+//
+//import java.util.Properties;
+//
+//import org.apache.tamaya.core.env.ConfiguredSystemProperties;
+//import org.junit.Test;
+//
+///**
+// * Created by Anatole on 02.10.2014.
+// */
+//public class ConfiguredSystemPropertiesTest {
+//
+// @Test
+// public void testInstall(){
+//// Configuration config = Configuration.current();
+// Properties props = System.getProperties();
+// assertTrue(props.getClass().getName().equals(Properties.class.getName()));
+// System.out.println("Props("+props.getClass().getName()+"): " + props);
+// ConfiguredSystemProperties.install();
+// props = System.getProperties();
+// System.out.println("Props("+props.getClass().getName()+"): " + props);
+// assertTrue(props.getClass().getName().equals(ConfiguredSystemProperties.class.getName()));
+// ConfiguredSystemProperties.uninstall();
+// props = System.getProperties();
+// assertTrue(props.getClass().getName().equals(Properties.class.getName()));
+// }
+//}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/core/config/EnvironmentManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/config/EnvironmentManagerTest.java b/core/src/test/java/org/apache/tamaya/core/config/EnvironmentManagerTest.java
deleted file mode 100644
index d7ae7a4..0000000
--- a/core/src/test/java/org/apache/tamaya/core/config/EnvironmentManagerTest.java
+++ /dev/null
@@ -1,40 +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.core.config;
-
-import org.apache.tamaya.Environment;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Created by Anatole on 16.06.2014.
- */
-public class EnvironmentManagerTest{
-
- @Test
- public void testEnvironmentNotNull(){
- Assert.assertNotNull(Environment.current());
- }
-
- @Test
- public void testRootEnvironmentNotNull(){
- Assert.assertNotNull(Environment.root());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/core/env/ConfiguredSystemPropertiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/env/ConfiguredSystemPropertiesTest.java b/core/src/test/java/org/apache/tamaya/core/env/ConfiguredSystemPropertiesTest.java
deleted file mode 100644
index 8869ce4..0000000
--- a/core/src/test/java/org/apache/tamaya/core/env/ConfiguredSystemPropertiesTest.java
+++ /dev/null
@@ -1,46 +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.core.env;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-
-import org.junit.Test;
-
-/**
- * Created by Anatole on 02.10.2014.
- */
-public class ConfiguredSystemPropertiesTest {
-
- @Test
- public void testInstall(){
-// Configuration config = Configuration.current();
- Properties props = System.getProperties();
- assertTrue(props.getClass().getName().equals(Properties.class.getName()));
- System.out.println("Props("+props.getClass().getName()+"): " + props);
- ConfiguredSystemProperties.install();
- props = System.getProperties();
- System.out.println("Props("+props.getClass().getName()+"): " + props);
- assertTrue(props.getClass().getName().equals(ConfiguredSystemProperties.class.getName()));
- ConfiguredSystemProperties.uninstall();
- props = System.getProperties();
- assertTrue(props.getClass().getName().equals(Properties.class.getName()));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java b/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
deleted file mode 100644
index 3a6b033..0000000
--- a/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
+++ /dev/null
@@ -1,66 +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.core.env;
-
-import org.apache.tamaya.Environment;
-import org.junit.Test;
-
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for basic {@link org.apache.tamaya.EnvironmentManager} functionality.
- * Created by Anatole on 17.10.2014.
- */
-public class EnvironmentManagerTest {
-
- @Test
- public void testGetEnvironment(){
- Environment env = Environment.current();
- assertNotNull(env);
- Environment env2 = Environment.current();
- assertNotNull(env2);
- assertFalse("Current Environments requested in same context are not the same!", env==env2);
- }
-
- @Test
- public void testGetRootEnvironment(){
- Environment env = Environment.root();
- assertNotNull(env);
- Environment env2 = Environment.root();
- assertNotNull(env2);
- assertTrue("Root Environments requested in same context are not the same!", env==env2);
- }
-
- @Test
- public void testRootIsNotCurrentEnvironment(){
- Environment env1 = Environment.root();
- Environment env2 = Environment.current();
- assertNotNull(env1);
- assertNotNull(env2);
- // within this test environment these are always the same
- assertEquals(env1, env2);
- }
-
- @Test
- public void testEnvironmentOverride(){
- assertEquals(Environment.root().get("user.country").get(),System.getProperty("user.country"));
- assertEquals(Environment.current().get("user.country").get(), System.getProperty("user.country"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
index 2276a58..bdda4d1 100644
--- a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
+++ b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
@@ -50,7 +50,7 @@ public class MutableTestConfigProvider implements ConfigurationProviderSpi{
dataMap.put("sons.2", "Luke");
dataMap.put("sons.3", "Benjamin");
// PropertySource provider = PropertySourceBuilder.of(CONFIG_NAME).addMap(dataMap).build();
- testConfig = new MutableConfiguration(dataMap, MetaInfo.of(CONFIG_NAME));
+ testConfig = new MutableConfiguration(dataMap, CONFIG_NAME);
}
@Override
@@ -76,13 +76,13 @@ public class MutableTestConfigProvider implements ConfigurationProviderSpi{
private static final long serialVersionUID = 8811989470609598218L;
private final Map<String,String> data = new ConcurrentHashMap<>();
- MutableConfiguration(Map<String,String> data, MetaInfo metaInfo){
- super(metaInfo);
+ MutableConfiguration(Map<String,String> data, String name){
+ super(name);
this.data.putAll(data);
}
@Override
- public Map<String, String> toMap() {
+ public Map<String, String> getProperties() {
return Collections.unmodifiableMap(data);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/internal/TestEnvironmentProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/internal/TestEnvironmentProvider.java b/core/src/test/java/org/apache/tamaya/internal/TestEnvironmentProvider.java
deleted file mode 100644
index d1a6c3d..0000000
--- a/core/src/test/java/org/apache/tamaya/internal/TestEnvironmentProvider.java
+++ /dev/null
@@ -1,48 +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.internal;
-
-import org.apache.tamaya.core.spi.EnvironmentProvider;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Environment provider used by some tests.
- */
-public class TestEnvironmentProvider implements EnvironmentProvider {
- private Map<String, String> data = new HashMap<>();
-
- public TestEnvironmentProvider(){
- data.put("user.country", System.getProperty("user.country"));
- data.put("java.version", System.getProperty("java.version"));
- data = Collections.unmodifiableMap(data);
- }
-
- @Override
- public boolean isActive() {
- return true;
- }
-
- @Override
- public Map<String, String> getEnvironmentData() {
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredClass.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredClass.java b/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredClass.java
new file mode 100644
index 0000000..f18271a
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredClass.java
@@ -0,0 +1,91 @@
+/*
+ * 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.samples.annotations;
+
+import org.apache.tamaya.annotation.DefaultValue;
+import org.apache.tamaya.annotation.NoConfig;
+import org.apache.tamaya.annotation.ObservesConfigChange;
+
+import java.beans.PropertyChangeEvent;
+import java.math.BigDecimal;
+
+/**
+ * Test example of a configured tyĆ¼ that is using default config key resolution.
+ */
+public class AutoConfiguredClass {
+
+ private String testProperty;
+
+ @DefaultValue("The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.")
+ String value1;
+
+ @NoConfig
+ private String value2;
+
+ @DefaultValue("N/A")
+ private String runtimeVersion;
+
+ @DefaultValue("${java.version}")
+ private String javaVersion2;
+
+ @DefaultValue("5")
+ private Integer int1;
+
+ private int int2;
+
+ @ObservesConfigChange
+ public void changeListener1(PropertyChangeEvent configChange){
+ // will be called
+ }
+
+ public String getTestProperty() {
+ return testProperty;
+ }
+
+ public String getValue1() {
+ return value1;
+ }
+
+ public String getValue2() {
+ return value2;
+ }
+
+ public String getRuntimeVersion() {
+ return runtimeVersion;
+ }
+
+ public String getJavaVersion2() {
+ return javaVersion2;
+ }
+
+ public Integer getInt1() {
+ return int1;
+ }
+
+ public int getInt2() {
+ return int2;
+ }
+
+ public String toString(){
+ return super.toString() + ": testProperty="+testProperty+", value1="+value1+", value2="+value2
+ +", int1="+int1+", int2="+int2
+ +", runtimeVersion="+runtimeVersion+", javaVersion2="+javaVersion2;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredTest.java b/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredTest.java
new file mode 100644
index 0000000..2e29cff
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/samples/annotations/AutoConfiguredTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.samples.annotations;
+
+import jdk.nashorn.internal.runtime.regexp.joni.Config;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.core.config.ConfigurationBuilder;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeTrue;
+
+/**
+ * Created by Anatole on 08.09.2014.
+ */
+public class AutoConfiguredTest {
+
+
+ @Test
+ public void testTemplateWithEnvironmentVariableOnUnixoidSystem(){
+ AutoConfiguredClass config = new AutoConfiguredClass();
+ Configuration.configure(config, ConfigurationBuilder.of("default").addPaths("classpath:cfg/autoloaded.xml").build());
+ System.out.println(config);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
index b55f731..499017a 100644
--- a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
+++ b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.tamaya.Configuration;
+import org.apache.tamaya.core.config.ConfigFunctions;
import org.apache.tamaya.core.properties.PropertySourceBuilder;
import org.junit.Test;
@@ -50,13 +51,13 @@ public class SimplePropertiesAndCLISample {
"classpath:test.properties").addPaths("classpath:cfg/test.xml")
.addArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}).addMap(cfgMap)
.build().toConfiguration();
- System.out.println(config.getAreas());
+ System.out.println(config.query(ConfigFunctions.getAreas()));
System.out.println("---");
- System.out.println(config.getAreas(s -> s.startsWith("another")));
+ System.out.println(config.query(ConfigFunctions.getAreas(s -> s.startsWith("another"))));
System.out.println("---");
- System.out.println(config.getTransitiveAreas());
+ System.out.println(config.query(ConfigFunctions.getTransitiveAreas()));
System.out.println("---");
- System.out.println(config.getTransitiveAreas(s -> s.startsWith("another")));
+ System.out.println(config.query(ConfigFunctions.getTransitiveAreas(s -> s.startsWith("another"))));
System.out.println("---");
System.out.println(config);
System.out.print("--- b=");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
index 80ec280..7571c1e 100644
--- a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
+++ b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
@@ -43,7 +43,7 @@ import org.junit.Test;
* <li>access a keys by key (+get+)</li>
* <li>check if a keys is present (+containsKey+)</li>
* <li>get a set current all defined keys (+keySet+)</li>
- * <li>a property provider must be convertible to a +Map+, by calling +toMap()+</li>
+ * <li>a property provider must be convertible to a +Map+, by calling +getProperties()+</li>
* <li>a property provider must get access to its meta information.</li>
* </ul>
* Additionally there are other requirement important for ease current use:
@@ -74,7 +74,7 @@ public class UC1ReadProperties {
System.out.println(areaConfig2);
// iterator over an area, using streams only
- Map<String, String> areaMap = config.toMap().entrySet().stream()
+ Map<String, String> areaMap = config.getProperties().entrySet().stream()
.filter((e) -> e.getKey().startsWith("num."))
.collect(Collectors.toMap((e) -> e.getKey().substring("num.".length()), Map.Entry::getValue));
Configuration areaConfig = PropertySourceBuilder.of("Test").addMap(areaMap).build().toConfiguration();
@@ -87,7 +87,7 @@ public class UC1ReadProperties {
Configuration config = provider.toConfiguration();
assertNotNull(config);
assertTrue(config.isEmpty());
- assertTrue(config.keySet().isEmpty());
+ assertTrue(config.getProperties().isEmpty());
assertFalse(config.isMutable());
}
@@ -96,7 +96,7 @@ public class UC1ReadProperties {
PropertySource provider = PropertySourceBuilder.of("Test").addPaths("classpath:barFoo.properties").build();
assertNotNull(provider);
assertTrue(provider.isEmpty());
- assertTrue(provider.keySet().isEmpty());
+ assertTrue(provider.getProperties().isEmpty());
assertFalse(provider.isMutable());
}
@@ -155,7 +155,7 @@ public class UC1ReadProperties {
assertEquals(provider.get("a.b.b").get(), "abbValue-fromIni");
assertEquals(provider.get("a.b.a").get(), "abaValue-fromIni");
// fromMap properties
- assertTrue(provider.containsKey("num.BD"));
+ assertTrue(provider.get("num.BD").isPresent());
// fromMap xml properties
assertEquals(provider.get("a-xml").get(), "aFromXml");
assertEquals(provider.get("b-xml").get(), "bFromXml");
@@ -164,8 +164,8 @@ public class UC1ReadProperties {
@Test
public void checkForAValue() {
PropertySource provider = PropertySourceBuilder.of("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
- assertFalse(provider.containsKey("blabla"));
- assertTrue(provider.containsKey("num.BD"));
+ assertFalse(provider.get("blabla").isPresent());
+ assertTrue(provider.get("num.BD").isPresent());
assertFalse(provider.get("blabla").isPresent());
assertTrue(provider.get("num.BD").isPresent());
}
@@ -173,18 +173,18 @@ public class UC1ReadProperties {
@Test
public void checkKeys() {
PropertySource provider = PropertySourceBuilder.of("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
- assertEquals(provider.keySet().size(), 16);
- assertTrue(provider.keySet().contains("boolean"));
- assertFalse(provider.keySet().contains("blabla"));
+ assertEquals(provider.getProperties().size(), 16);
+ assertTrue(provider.getProperties().keySet().contains("boolean"));
+ assertFalse(provider.getProperties().keySet().contains("blabla"));
}
@Test
public void checkToMap() {
PropertySource provider = PropertySourceBuilder.of("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
- Map<String, String> map = provider.toMap();
+ Map<String, String> map = provider.getProperties();
assertNotNull(map);
assertEquals(map.size(), 16);
- assertEquals(provider.keySet(), map.keySet());
+ assertEquals(provider.getProperties().keySet(), map.keySet());
assertTrue(map.keySet().contains("boolean"));
assertFalse(map.keySet().contains("blabla"));
}
@@ -192,8 +192,7 @@ public class UC1ReadProperties {
@Test
public void checkMetaInfo() {
PropertySource provider = PropertySourceBuilder.of("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
- MetaInfo meta = provider.getMetaInfo();
- assertNotNull(meta);
+ assertNotNull(provider.getName());
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java b/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
index ba522a7..3a6e471 100644
--- a/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
+++ b/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
@@ -62,7 +62,7 @@ public class UC2CombineProperties {
public void dynamicAggregationTests() {
PropertySource props1 = PropertySourceBuilder.of().addPaths("classpath:ucs/UC2CombineProperties/props1.properties").build();
PropertySource props2 = PropertySourceBuilder.of().addPaths("classpath:ucs/UC2CombineProperties/props2.properties").build();
- PropertySource props = PropertySourceBuilder.of().withAggregationPolicy((k, v1, v2) -> (v1 != null ? v1 : "") + '[' + v2 + "]").withMetaInfo(MetaInfo.of("dynamicAggregationTests"))
+ PropertySource props = PropertySourceBuilder.of().withAggregationPolicy((k, v1, v2) -> (v1 != null ? v1 : "") + '[' + v2 + "]").withName("dynamicAggregationTests")
.aggregate(props1, props2).build();
System.out.println(props);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
----------------------------------------------------------------------
diff --git a/core/src/test/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider b/core/src/test/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
index d35127f..74382e7 100644
--- a/core/src/test/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
+++ b/core/src/test/resources/META-INF/services/org.apache.tamaya.core.spi.EnvironmentProvider
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.internal.TestEnvironmentProvider
\ No newline at end of file
+org.apache.tamaya.metamodel.environment.TestEnvironmentProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/resources/cfg/autoloaded.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/cfg/autoloaded.xml b/core/src/test/resources/cfg/autoloaded.xml
new file mode 100644
index 0000000..b64cb76
--- /dev/null
+++ b/core/src/test/resources/cfg/autoloaded.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy current the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties version="1.0">
+ <entry key="testFromXml">testValue</entry>
+ <entry key="b">Bill</entry>
+ <entry key="a.compound.area.entry">myCompundAreaVlaueFromXml</entry>
+ <entry key="an.area.entry">myCompundAreaVlaueFromXml2</entry>
+ <!-- DirectMapping test -->
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.value1">This \${JAVA_HOME} is cool!</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.value2">Should not be set because @NoConfig !</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.testProperty">a test property value</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.runtimeVersion">my RT 1-0-0--build-1234</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.int1">1</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.int2">22</entry>
+</properties>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/core/src/test/resources/cfg/test.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/cfg/test.xml b/core/src/test/resources/cfg/test.xml
index fc65101..b64cb76 100644
--- a/core/src/test/resources/cfg/test.xml
+++ b/core/src/test/resources/cfg/test.xml
@@ -23,4 +23,11 @@ under the License.
<entry key="b">Bill</entry>
<entry key="a.compound.area.entry">myCompundAreaVlaueFromXml</entry>
<entry key="an.area.entry">myCompundAreaVlaueFromXml2</entry>
+ <!-- DirectMapping test -->
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.value1">This \${JAVA_HOME} is cool!</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.value2">Should not be set because @NoConfig !</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.testProperty">a test property value</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.runtimeVersion">my RT 1-0-0--build-1234</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.int1">1</entry>
+ <entry key="org.apache.tamaya.samples.annotations.AutoConfiguredClass.int2">22</entry>
</properties>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java
----------------------------------------------------------------------
diff --git a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java
index 681c02b..b991690 100644
--- a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java
+++ b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.management;
+package org.apache.tamaya.se;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.AggregationPolicy;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
----------------------------------------------------------------------
diff --git a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
index 381d43a..c2ade13 100644
--- a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
+++ b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.management;
+package org.apache.tamaya.se;
import org.apache.tamaya.ConfigException;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironment.java b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironment.java
index 7caff90..e85b1c1 100644
--- a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironment.java
+++ b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironment.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.management;
+package org.apache.tamaya.se;
import org.apache.tamaya.Environment;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironmentMBean.java
----------------------------------------------------------------------
diff --git a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironmentMBean.java b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironmentMBean.java
index 5d86700..ef3b861 100644
--- a/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironmentMBean.java
+++ b/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedEnvironmentMBean.java
@@ -16,12 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.management;
+package org.apache.tamaya.se;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Managed bean interface for accessing environment data.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml
index 44d1a43..95f2b07 100644
--- a/modules/integration/pom.xml
+++ b/modules/integration/pom.xml
@@ -1,45 +1,20 @@
-<!--
-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"
+<?xml version="1.0" encoding="UTF-8"?>
+<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-ext-all</artifactId>
+ <groupId>org.apache.tamaya.ext</groupId>
<version>0.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
- <groupId>org.apache.tamaya.integration</groupId>
- <artifactId>tamaya-integration-all</artifactId>
- <name>Apache Tamaya Modules Integration</name>
- <packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
- <properties>
- <github.global.server>github</github.global.server>
- <jdkVersion>1.8</jdkVersion>
- <maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
- <maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>
- </properties>
+ <artifactId>org.apache.tamaya.metamodels.environment</artifactId>
<modules>
<module>cdi</module>
+ <module>se</module>
</modules>
-</project>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/integration/se/src/main/java/org/apache/tamaya/integration/se/ConfiguredSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/integration/se/src/main/java/org/apache/tamaya/integration/se/ConfiguredSystemProperties.java b/modules/integration/se/src/main/java/org/apache/tamaya/integration/se/ConfiguredSystemProperties.java
new file mode 100644
index 0000000..cdef5be
--- /dev/null
+++ b/modules/integration/se/src/main/java/org/apache/tamaya/integration/se/ConfiguredSystemProperties.java
@@ -0,0 +1,353 @@
+/*
+ * 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.integration.se;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.Environment;
+
+/**
+ * Properties implementation class that can be applied as current System properties by calling
+ * {@link ConfiguredSystemProperties#install()}. The system properties will
+ * then behave contextually depending on the current runtime configuration active.
+ */
+public class ConfiguredSystemProperties extends Properties {
+
+ private static final long serialVersionUID = 2152870929299226804L;
+
+ private static final Logger LOG = Logger.getLogger(ConfiguredSystemProperties.class.getName());
+ private Properties initialProperties;
+ private static volatile Map<String, Properties> contextualProperties = new ConcurrentHashMap<>();
+ private static volatile Supplier<String> contextProvider = () ->
+ Environment.current().get("context.id").orElse("<system>");
+
+
+ private final Object LOCK = new Object();
+
+
+ private ConfiguredSystemProperties(Properties initialProperties) {
+ super(initialProperties);
+ this.initialProperties = initialProperties;
+ }
+
+ public static void install() {
+ Properties props = System.getProperties();
+ if (props instanceof ConfiguredSystemProperties) {
+ return;
+ }
+ ConfiguredSystemProperties systemProps = new ConfiguredSystemProperties(props);
+ LOG.finest("Installing enhanced system properties...");
+ System.setProperties(systemProps);
+ LOG.info("Installed enhanced system properties successfully.");
+ }
+
+ public static void uninstall() {
+ Properties props = System.getProperties();
+ if (props instanceof ConfiguredSystemProperties) {
+ Properties initialProperties = ((ConfiguredSystemProperties) props).initialProperties;
+ LOG.finest("Uninstalling enhanced system properties...");
+ System.setProperties(initialProperties);
+ LOG.info("Uninstalled enhanced system properties successfully.");
+ }
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return getContextualProperties().getProperty(key);
+ }
+
+ @Override
+ public String getProperty(String key, String defaultValue) {
+ return getContextualProperties().getProperty(key, defaultValue);
+ }
+
+ @Override
+ public Enumeration<?> propertyNames() {
+ return getContextualProperties().propertyNames();
+ }
+
+ @Override
+ public Set<String> stringPropertyNames() {
+ return getContextualProperties().stringPropertyNames();
+ }
+
+ @Override
+ public synchronized int size() {
+ return getContextualProperties().size();
+ }
+
+ @Override
+ public synchronized Enumeration<Object> keys() {
+ return getContextualProperties().keys();
+ }
+
+ @Override
+ public synchronized Enumeration<Object> elements() {
+ return getContextualProperties().elements();
+ }
+
+ @Override
+ public synchronized boolean contains(Object value) {
+ return getContextualProperties().contains(value);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return getContextualProperties().containsValue(value);
+ }
+
+ @Override
+ public synchronized boolean containsKey(Object key) {
+ return getContextualProperties().containsKey(key);
+ }
+
+ @Override
+ public synchronized Object get(Object key) {
+ return getContextualProperties().get(key);
+ }
+
+ @Override
+ public synchronized Object clone() {
+ return getContextualProperties().clone();
+ }
+
+ @Override
+ public Set<Object> keySet() {
+ return getContextualProperties().keySet();
+ }
+
+ @Override
+ public Set<Map.Entry<Object, Object>> entrySet() {
+ return getContextualProperties().entrySet();
+ }
+
+ @Override
+ public Collection<Object> values() {
+ return getContextualProperties().values();
+ }
+
+
+ @Override
+ public Object getOrDefault(Object key, Object defaultValue) {
+ return getContextualProperties().getOrDefault(key, defaultValue);
+ }
+
+ @Override
+ public void forEach(BiConsumer<? super Object, ? super Object> action) {
+ getContextualProperties().forEach(action);
+ }
+
+
+ @Override
+ public Object computeIfAbsent(Object key, Function<? super Object, ?> mappingFunction) {
+ return getContextualProperties().computeIfAbsent(key, mappingFunction);
+ }
+
+ @Override
+ public synchronized Object computeIfPresent(Object key, BiFunction<? super Object, ? super Object, ?> remappingFunction) {
+ return getContextualProperties().computeIfPresent(key, remappingFunction);
+ }
+
+ @Override
+ public synchronized Object compute(Object key, BiFunction<? super Object, ? super Object, ?> remappingFunction) {
+ return getContextualProperties().compute(key, remappingFunction);
+ }
+
+ @Override
+ public String toString() {
+ return getContextualProperties().toString();
+ }
+
+ @Override
+ public synchronized Object setProperty(String key, String value) {
+ return getContextualProperties().setProperty(key, value);
+ }
+
+ @Override
+ public synchronized void load(Reader reader) throws IOException {
+ getContextualProperties().load(reader);
+ }
+
+ @Override
+ public synchronized void load(InputStream inStream) throws IOException {
+ getContextualProperties().load(inStream);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void save(OutputStream out, String comments) {
+ super.save(out, comments);
+ }
+
+ @Override
+ public void store(Writer writer, String comments) throws IOException {
+ getContextualProperties().store(writer, comments);
+ }
+
+ @Override
+ public void store(OutputStream out, String comments) throws IOException {
+ getContextualProperties().store(out, comments);
+ }
+
+ @Override
+ public void loadFromXML(InputStream in) throws IOException {
+ getContextualProperties().loadFromXML(in);
+ }
+
+ @Override
+ public void storeToXML(OutputStream os, String comment) throws IOException {
+ getContextualProperties().storeToXML(os, comment);
+ }
+
+ @Override
+ public void storeToXML(OutputStream os, String comment, String encoding) throws IOException {
+ getContextualProperties().storeToXML(os, comment, encoding);
+ }
+
+ @Override
+ public void list(PrintStream out) {
+ getContextualProperties().list(out);
+ }
+
+ @Override
+ public void list(PrintWriter out) {
+ getContextualProperties().list(out);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return getContextualProperties().isEmpty();
+ }
+
+ @Override
+ public Object put(Object key, Object value) {
+ return getContextualProperties().put(key, value);
+ }
+
+ @Override
+ public Object remove(Object key) {
+ return getContextualProperties().remove(key);
+ }
+
+ @Override
+ public void putAll(Map<?, ?> t) {
+ getContextualProperties().putAll(t);
+ }
+
+ @Override
+ public void clear() {
+ getContextualProperties().clear();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return getContextualProperties().equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return getContextualProperties().hashCode();
+ }
+
+ @Override
+ public void replaceAll(BiFunction<? super Object, ? super Object, ?> function) {
+ getContextualProperties().replaceAll(function);
+ }
+
+ @Override
+ public Object putIfAbsent(Object key, Object value) {
+ return getContextualProperties().putIfAbsent(key, value);
+ }
+
+ @Override
+ public boolean remove(Object key, Object value) {
+ return getContextualProperties().remove(key, value);
+ }
+
+ @Override
+ public boolean replace(Object key, Object oldValue, Object newValue) {
+ return getContextualProperties().replace(key, oldValue, newValue);
+ }
+
+ @Override
+ public Object replace(Object key, Object value) {
+ return getContextualProperties().replace(key, value);
+ }
+
+ @Override
+ public Object merge(Object key, Object value, BiFunction<? super Object, ? super Object, ?> remappingFunction) {
+ return getContextualProperties().merge(key, value, remappingFunction);
+ }
+
+ public Properties getInitialProperties() {
+ return initialProperties;
+ }
+
+ /**
+ * Uninstalls the contextual system properties for the current context, as determined by the current
+ * context provider active.
+ */
+ public static void resetProperties() {
+ String contextId = contextProvider == null ? "" : contextProvider.get();
+ contextualProperties.remove(contextId);
+ }
+
+ protected Properties getContextualProperties() {
+ String contextId = contextProvider == null ? "" : contextProvider.get();
+ Properties props = ConfiguredSystemProperties.contextualProperties.get(contextId);
+ if (props == null) {
+ synchronized (LOCK) {
+ props = ConfiguredSystemProperties.contextualProperties.get(contextId);
+ if (props == null) {
+ props = createNewProperties();
+ contextualProperties.put(contextId, props);
+ }
+ }
+ }
+ return props;
+ }
+
+ protected Properties createNewProperties() {
+ Properties props = new Properties(initialProperties);
+ Configuration config = Configuration.current();
+ Map<String, String> configMap = config.getProperties();
+ for (Map.Entry<String, String> en : configMap.entrySet()) {
+ props.put(en.getKey(), en.getValue());
+ }
+ return props;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java
new file mode 100644
index 0000000..3633c97
--- /dev/null
+++ b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java
@@ -0,0 +1,109 @@
+/*
+ * 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.metamodel.environment;
+
+import java.util.*;
+
+/**
+ * Environment class that is used by the {@link org.apache.tamaya.metamodel.environment.EnvironmentBuilder}.
+ */
+class BuildableEnvironment implements Environment {
+
+ /** The environment data. */
+ private Map<String,String> context = new TreeMap<>();
+
+ /**
+ * Constructor.
+ * @param builder the builder, not null.
+ */
+ BuildableEnvironment(EnvironmentBuilder builder){
+ Objects.requireNonNull(builder);
+ context.putAll(builder.contextData);
+ }
+
+ @Override
+ public Map<String, String> toMap() {
+ return context;
+ }
+
+ @Override
+ public Optional<String> get(String key){
+ return Optional.ofNullable(context.get(key));
+ }
+
+ @Override
+ public boolean containsKey(String key){
+ return context.containsKey(key);
+ }
+
+ @Override
+ public Set<String> keySet() {
+ return context.keySet();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ BuildableEnvironment that = (BuildableEnvironment) o;
+ return context.equals(that.context);
+ }
+
+ @Override
+ public int hashCode() {
+ return context.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString(){
+ return "Environment: " + getData();
+ }
+
+ /**
+ * Get the delta.
+ * @return
+ */
+ private String getData() {
+ StringBuilder b = new StringBuilder();
+ for(Map.Entry<String,String> en: this.context.entrySet()){
+ b.append(" ").append(en.getKey()).append('=').append(escape(en.getValue())).append('\n');
+ }
+ if(b.length()>0)
+ b.setLength(b.length()-1);
+ return b.toString();
+ }
+
+ /**
+ * Escapes several characters.
+ * @param value
+ * @return
+ */
+ private String escape(String value){
+ if(value==null)
+ return null;
+ return value.replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r").replaceAll("\t", "\\\\t")
+ .replaceAll("=", "\\\\=");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java
----------------------------------------------------------------------
diff --git a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java
new file mode 100644
index 0000000..8a8b157
--- /dev/null
+++ b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java
@@ -0,0 +1,86 @@
+/*
+ * 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.metamodel.environment;
+
+import org.apache.tamaya.metamodel.environment.spi.EnvironmentSpi;
+import org.apache.tamaya.spi.ServiceContext;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * Models a runtime environment. Instances current this class are used to
+ * evaluate the correct configuration artifacts.<br/>
+ * <h3>Implementation Requirements</h3>
+ * <p>
+ * Implementations current this interface must be
+ * <ul>
+ * <li>Thread safe.
+ * <li>Immutable
+ * <li>serializable
+ * </ul>
+ */
+public interface Environment{
+
+ /**
+ * Access a property.
+ * @param key the property's key, not null.
+ * @return the property's keys.
+ */
+ Optional<String> get(String key);
+
+ /**
+ * Checks if a property is defined.
+ * @param key the property's key, not null.
+ * @return true, if the property is existing.
+ */
+ boolean containsKey(String key);
+
+ /**
+ * Access the set current property keys, defined by this provider.
+ * @return the key set, never null.
+ */
+ Set<String> keySet();
+
+ /**
+ * Access the environment as Map.
+ * @return the Map instance containing the environments properties, never null.
+ */
+ Map<String,String> toMap();
+
+ /**
+ * Get the current {@link org.apache.tamaya.metamodel.environment.Environment}. The environment is used to determine the current runtime state, which
+ * is important for returning the correct configuration.
+ * @return the current Environment, never null.
+ */
+ public static Environment current(){
+ return ServiceContext.getInstance().getSingleton(EnvironmentSpi.class).getCurrentEnvironment();
+ }
+
+ /**
+ * Get the current {@link Environment}. The environment is used to determine the current runtime state, which
+ * is important for returning the correct configuration.
+ * @return the current Environment, never null.
+ */
+ public static Environment root(){
+ return ServiceContext.getInstance().getSingleton(EnvironmentSpi.class).getRootEnvironment();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/EnvironmentBuilder.java
----------------------------------------------------------------------
diff --git a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/EnvironmentBuilder.java b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/EnvironmentBuilder.java
new file mode 100644
index 0000000..17ec34b
--- /dev/null
+++ b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/EnvironmentBuilder.java
@@ -0,0 +1,97 @@
+/*
+ * 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.metamodel.environment;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+* Builder to create new {@link Environment instances.}
+*/
+public final class EnvironmentBuilder{
+
+ /** The property name for the stage property. */
+ public static final String STAGE_PROP = "stage";
+
+ /** THe environment data. */
+ Map<String,String> contextData = new HashMap<>();
+
+ /**
+ * Constructor.
+ */
+ private EnvironmentBuilder() {
+ }
+
+ /**
+ * Creates a new buildr instance.
+ * @return the new builder instance.
+ */
+ public static final EnvironmentBuilder of() {
+ return new EnvironmentBuilder();
+ }
+
+ /**
+ * Sets a new environment property.
+ * @param key the key, not null.
+ * @param value the keys, not null.
+ * @return the builder for chaining
+ */
+ public EnvironmentBuilder set(String key, String value){
+ this.contextData.put(key, value);
+ return this;
+ }
+
+ /**
+ * Sets new environment properties.
+ * @param values the key/values, not null.
+ * @return the builder for chaining
+ */
+ public EnvironmentBuilder setAll(Map<String,String> values){
+ this.contextData.putAll(values);
+ return this;
+ }
+
+ /**
+ * Sets the stage using the default stage key.
+ * @param stage The stage, not null.
+ * @return the builder for chaining.
+ */
+ public EnvironmentBuilder setStage(String stage){
+ this.contextData.put(STAGE_PROP, Objects.requireNonNull(stage));
+ return this;
+ }
+
+ /**
+ * Access a property
+ * @param key the key, not null.
+ * @return the builder for chaining.
+ */
+ public String getProperty(String key) {
+ return this.contextData.get(key);
+ }
+
+ /**
+ * Builds a new Environment.
+ * @return a new Environment, never null.
+ */
+ public Environment build() {
+ return new BuildableEnvironment(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a3c10d6e/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/internal/ClassLoaderDependentApplicationEnvironmentProvider.java
----------------------------------------------------------------------
diff --git a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/internal/ClassLoaderDependentApplicationEnvironmentProvider.java b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/internal/ClassLoaderDependentApplicationEnvironmentProvider.java
new file mode 100644
index 0000000..e2d1759
--- /dev/null
+++ b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/internal/ClassLoaderDependentApplicationEnvironmentProvider.java
@@ -0,0 +1,101 @@
+/*
+ * 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.metamodel.environment.internal;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tamaya.core.config.ConfigurationFormats;
+import org.apache.tamaya.core.resource.Resource;
+import org.apache.tamaya.core.resource.ResourceLoader;
+import org.apache.tamaya.core.config.ConfigurationFormat;
+import org.apache.tamaya.metamodel.environment.spi.EnvironmentProvider;
+import org.apache.tamaya.spi.ServiceContext;
+
+/**
+ * Application environment provider that is dependent on the current context classloader and tries to
+ * evaluate {@code META-INF/env/application.properties, META-INF/env/application.xml and META-INF/env/application.ini}.
+ * Only if a property named {@code org.apache.tamaya.env.applicationId} is found, it will
+ * be used as the {@code environmentId} and a corresponding {@link org.apache.tamaya.metamodel.environment.Environment} instance
+ * is created and attached.
+ */
+public class ClassLoaderDependentApplicationEnvironmentProvider implements EnvironmentProvider {
+
+ private static final Logger LOG = Logger.getLogger(ClassLoaderDependentApplicationEnvironmentProvider.class.getName());
+
+ private Map<ClassLoader, Map<String,String>> environments = new ConcurrentHashMap<>();
+ private Map<ClassLoader, Boolean> environmentAvailable = new ConcurrentHashMap<>();
+
+ @Override
+ public boolean isActive() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if(cl==null){
+ return false;
+ }
+ Boolean available = this.environmentAvailable.get(cl);
+ if(available!=null && !available){
+ return false;
+ }
+ List<Resource> propertyUris = ServiceContext.getInstance().getSingleton(ResourceLoader.class).getResources(cl,
+ "classpath:META-INF/env/application.properties", "classpath:META-INF/env/application.xml", "classpath:META-INF/env/application.ini");
+ available = !propertyUris.isEmpty();
+ this.environmentAvailable.put(cl, available);
+ return available;
+ }
+
+ @Override
+ public Map<String,String> getEnvironmentData() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if(cl==null){
+ return null;
+ }
+ Map<String,String> data = this.environments.get(cl);
+ if(data!=null){
+ return data;
+ }
+ List<Resource> propertyUris = ServiceContext.getInstance().getSingleton(ResourceLoader.class).getResources(cl,
+ "classpath:META-INF/env/application.properties", "classpath:META-INF/env/application.xml", "classpath:META-INF/env/application.ini");
+ data = new HashMap<>();
+
+ for(Resource resource:propertyUris){
+ try{
+ ConfigurationFormat format = ConfigurationFormats.getFormat(resource);
+ data.putAll(format.readConfiguration(resource));
+ }
+ catch(Exception e){
+ LOG.log(Level.SEVERE, e, () -> "Error reading application environment data fromMap " + resource);
+ }
+ }
+ data.put("classloader.type", cl.getClass().getName());
+ data.put("classloader.info", cl.toString());
+ Set<Resource> uris = new HashSet<>();
+ uris.addAll(propertyUris);
+ data.put("environment.sources", uris.toString());
+ data = Collections.unmodifiableMap(data);
+ this.environments.put(cl, data);
+ return data;
+ }
+}