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 2015/08/21 02:41:47 UTC
[5/6] incubator-tamaya git commit: Implemented,
moved experimental modules and added them to non experimental parts:
- functions (operators and queries) - model (validation and documentation) -
management (jmx bean support)
Implemented, moved experimental modules and added them to non experimental parts:
- functions (operators and queries)
- model (validation and documentation)
- management (jmx bean support)
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c5343410
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c5343410
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c5343410
Branch: refs/heads/master
Commit: c53434105c76adc324eca6eadf7520e68336b62b
Parents: 069ec36
Author: anatole <an...@apache.org>
Authored: Fri Aug 21 02:40:04 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Fri Aug 21 02:40:04 2015 +0200
----------------------------------------------------------------------
modules/functions/pom.xml | 57 ++++
.../apache/tamaya/functions/BiPredicate.java | 47 +++
.../functions/ConfigurationFunctions.java | 332 +++++++++++++++++++
.../tamaya/functions/FilteredConfiguration.java | 72 ++++
.../functions/FilteredPropertySource.java | 73 ++++
.../org/apache/tamaya/functions/Function.java | 42 +++
.../tamaya/functions/MappedConfiguration.java | 67 ++++
.../tamaya/functions/MappedPropertySource.java | 83 +++++
.../functions/MetaEnrichedPropertySource.java | 81 +++++
.../org/apache/tamaya/functions/Predicate.java | 42 +++
.../functions/PropertySourceFunctions.java | 240 ++++++++++++++
.../apache/tamaya/functions/UnaryOperator.java | 39 +++
.../functions/ValueFilteredPropertySource.java | 78 +++++
.../apache/tamaya/functions/package-info.java | 22 ++
modules/management/pom.xml | 57 ++++
.../apache/tamaya/management/ManagedConfig.java | 106 ++++++
.../tamaya/management/ManagedConfigMBean.java | 97 ++++++
.../src/main/resources/META-INF/beans.xml | 24 ++
....apache.tamaya.management.ManagedConfigMBean | 19 ++
.../tamaya/management/ManagedConfigTest.java | 77 +++++
.../src/test/resources/META-INF/beans.xml | 24 ++
modules/model/pom.xml | 85 +++++
.../apache/tamaya/model/ConfigValidator.java | 239 +++++++++++++
.../org/apache/tamaya/model/Validation.java | 78 +++++
.../apache/tamaya/model/ValidationResult.java | 191 +++++++++++
.../apache/tamaya/model/ValidationState.java | 59 ++++
.../org/apache/tamaya/model/ValidationType.java | 49 +++
.../model/internal/ConfigDocumentationBean.java | 197 +++++++++++
.../ConfiguredInlineModelProviderSpi.java | 67 ++++
...nfiguredPropertiesValidationProviderSpi.java | 153 +++++++++
.../ConfiguredResourcesModelProviderSpi.java | 137 ++++++++
.../tamaya/model/spi/AbstractValidation.java | 89 +++++
.../apache/tamaya/model/spi/AreaValidation.java | 204 ++++++++++++
.../model/spi/ConfigDocumentationMBean.java | 52 +++
.../model/spi/ConfigValidationsReader.java | 183 ++++++++++
.../tamaya/model/spi/ParameterValidation.java | 236 +++++++++++++
.../tamaya/model/spi/ValidationGroup.java | 112 +++++++
.../tamaya/model/spi/ValidationProviderSpi.java | 39 +++
.../resources/META-INF/configmodel.properties | 35 ++
...he.tamaya.model.spi.ConfigDocumentationMBean | 19 ++
...pache.tamaya.model.spi.ValidationProviderSpi | 21 ++
.../model/TestConfigValidationProvider.java | 66 ++++
.../apache/tamaya/model/ValidationTests.java | 42 +++
.../internal/ConfigDocumentationBeanTest.java | 112 +++++++
.../resources/META-INF/configmodel.properties | 96 ++++++
.../META-INF/javaconfiguration.properties | 22 ++
...pache.tamaya.model.spi.ValidationProviderSpi | 19 ++
.../src/test/resources/examples/configmodel.ini | 76 +++++
.../test/resources/examples/configmodel.json | 113 +++++++
.../resources/examples/configmodel.properties | 96 ++++++
.../src/test/resources/examples/configmodel.xml | 97 ++++++
.../test/resources/examples/configmodel.yaml | 106 ++++++
modules/pom.xml | 3 +
sandbox/functions/pom.xml | 52 ---
.../functions/ConfigurationFunctions.java | 238 -------------
.../tamaya/functions/FilteredConfiguration.java | 70 ----
.../functions/FilteredPropertySource.java | 66 ----
.../tamaya/functions/MappedConfiguration.java | 66 ----
.../tamaya/functions/MappedPropertySource.java | 78 -----
.../functions/MetaEnrichedPropertySource.java | 80 -----
.../functions/PropertySourceFunctions.java | 226 -------------
.../functions/ValueFilteredPropertySource.java | 75 -----
.../apache/tamaya/functions/package-info.java | 22 --
sandbox/management/pom.xml | 42 ---
.../apache/tamaya/management/ManagedConfig.java | 62 ----
.../tamaya/management/ManagedConfigMBean.java | 97 ------
.../tamaya/management/ManagedEnvironment.java | 69 ----
.../management/ManagedEnvironmentMBean.java | 88 -----
.../src/main/resources/META-INF/beans.xml | 24 --
.../src/test/resources/META-INF/beans.xml | 24 --
sandbox/model/pom.xml | 70 ----
.../apache/tamaya/model/ConfigValidator.java | 109 ------
.../org/apache/tamaya/model/Validation.java | 66 ----
.../apache/tamaya/model/ValidationResult.java | 191 -----------
.../apache/tamaya/model/ValidationState.java | 59 ----
.../ConfiguredInlineModelProviderSpi.java | 68 ----
...nfiguredPropertiesValidationProviderSpi.java | 139 --------
.../ConfiguredResourcesModelProviderSpi.java | 125 -------
.../tamaya/model/spi/AbstractValidation.java | 48 ---
.../apache/tamaya/model/spi/AreaValidation.java | 138 --------
.../model/spi/ConfigValidationsReader.java | 169 ----------
.../tamaya/model/spi/ParameterValidation.java | 153 ---------
.../tamaya/model/spi/ValidationGroup.java | 97 ------
.../tamaya/model/spi/ValidationProviderSpi.java | 39 ---
...pache.tamaya.model.spi.ValidationProviderSpi | 21 --
.../model/TestConfigValidationProvider.java | 49 ---
.../apache/tamaya/model/ValidationTests.java | 24 --
.../resources/META-INF/configmodel.properties | 96 ------
.../META-INF/javaconfiguration.properties | 22 --
...pache.tamaya.model.spi.ValidationProviderSpi | 19 --
.../src/test/resources/examples/configmodel.ini | 76 -----
.../test/resources/examples/configmodel.json | 113 -------
.../resources/examples/configmodel.properties | 96 ------
.../src/test/resources/examples/configmodel.xml | 97 ------
.../test/resources/examples/configmodel.yaml | 106 ------
95 files changed, 4772 insertions(+), 3569 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/pom.xml
----------------------------------------------------------------------
diff --git a/modules/functions/pom.xml b/modules/functions/pom.xml
new file mode 100644
index 0000000..2410f1b
--- /dev/null
+++ b/modules/functions/pom.xml
@@ -0,0 +1,57 @@
+<!--
+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-extensions</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>tamaya-functions</artifactId>
+ <name>Apache Tamaya Common Functional Extensions</name>
+ <packaging>jar</packaging>
+
+ <properties>
+ <jdkVersion>1.7</jdkVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- Test scope only, do not create a code dependency! -->
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/BiPredicate.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/BiPredicate.java b/modules/functions/src/main/java/org/apache/tamaya/functions/BiPredicate.java
new file mode 100644
index 0000000..dcc3c35
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/BiPredicate.java
@@ -0,0 +1,47 @@
+/*
+ * 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.functions;
+
+/**
+ * Represents a predicate (boolean-valued function) of two arguments. This is
+ * the two-arity specialization of {@link Predicate}.
+ *
+ * <p>This is a <a href="package-summary.html">functional interface</a>
+ * whose functional method is {@link #test(Object, Object)}.
+ *
+ * @param <T> the type of the first argument to the predicate
+ * @param <U> the type of the second argument the predicate
+ *
+ * @see Predicate
+ */
+@FunctionalInterface
+public interface BiPredicate<T, U> {
+
+ /**
+ * Evaluates this predicate on the given arguments.
+ *
+ * @param t the first input argument
+ * @param u the second input argument
+ * @return {@code true} if the input arguments match the predicate,
+ * otherwise {@code false}
+ */
+ boolean test(T t, U u);
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
new file mode 100644
index 0000000..5bf68d8
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
@@ -0,0 +1,332 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.ConfigOperator;
+import org.apache.tamaya.ConfigQuery;
+import org.apache.tamaya.Configuration;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Accessor that provides useful functions along with configuration.
+ */
+public final class ConfigurationFunctions {
+
+ private static final ConfigQuery<String> INFO_QUERY = new ConfigQuery<String>(){
+ @Override
+ public String query(Configuration config) {
+ StringBuilder builder = new StringBuilder();
+ Map<String,String> props = new TreeMap<>(config.getProperties());
+ builder.append("Configuration: {\n")
+ .append(" \"class\": \n"+ config.getClass().getName() + ",\n")
+ .append(" \"properties\": {\n");
+ for(Map.Entry<String,String> en: props.entrySet()){
+ builder.append(" \"" + escape(en.getKey()) +"\": \""+escape(en.getValue())+"\",\n");
+ }
+ builder.append(" }\n}");
+ return builder.toString();
+ }
+ };
+
+
+ /**
+ * Replaces new lines, returns, tabs and '"' with escaped variants.
+ * @param text the input text, not null
+ * @return the escaped text.
+ */
+ private static String escape(String text){
+ return text.replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t").replace("\"", "\\\"");
+ }
+
+ /**
+ * Private singleton constructor.
+ */
+ private ConfigurationFunctions() {
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ *
+ * @param filter the filter, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator filter(final BiPredicate<String, String> filter) {
+ return new ConfigOperator() {
+ @Override
+ public Configuration operate(Configuration config) {
+ return new FilteredConfiguration(config, filter, null);
+ }
+ };
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration with keys mapped as
+ * defined by the given keyMapper.
+ *
+ * @param keyMapper the keyMapper, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator map(final Function<String, String> keyMapper) {
+ return new ConfigOperator() {
+ @Override
+ public Configuration operate(Configuration config) {
+ return new MappedConfiguration(config, keyMapper, null);
+ }
+ };
+ }
+
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ *
+ * @param areaKey the area key, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator area(String areaKey) {
+ return area(areaKey, true);
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive).
+ *
+ * @param areaKey the area key, not null
+ * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator area(final String areaKey, final boolean stripKeys) {
+ return new ConfigOperator() {
+ @Override
+ public Configuration operate(Configuration config) {
+ Configuration filtered = new FilteredConfiguration(config,
+ new BiPredicate<String, String>() {
+ @Override
+ public boolean test(String k, String v) {
+ return isKeyInArea(k, areaKey);
+ }
+ }, "area: " + areaKey);
+ if(stripKeys){
+ return new MappedConfiguration(filtered, new Function<String, String>() {
+ @Override
+ public String apply(String k) {
+ return k.substring(areaKey.length() + 1);
+ }
+ }, "stripped");
+ }
+ return filtered;
+ }
+ };
+ }
+
+ /**
+ * Calculates the current area key and compares it with the given key.
+ *
+ * @param key the fully qualified entry key, not null
+ * @param areaKey the area key, not null
+ * @return true, if the entry is exact in this area
+ */
+ public static boolean isKeyInArea(String key, String areaKey) {
+ int lastIndex = key.lastIndexOf('.');
+ String curAreaKey = lastIndex > 0 ? key.substring(0, lastIndex) : "";
+ return curAreaKey.equals(areaKey);
+ }
+
+ /**
+ * Calculates the current area key and compares it with the given area keys.
+ *
+ * @param key the fully qualified entry key, not null
+ * @param areaKeys the area keys, not null
+ * @return true, if the entry is exact in this area
+ */
+ public static boolean isKeyInAreas(String key, String... areaKeys) {
+ for(String areaKey:areaKeys){
+ if(isKeyInArea(key, areaKey)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualifies area names. This method should return the areas as accurate as possible,
+ * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
+ * does not support key iteration.
+ *
+ * @return s set with all areas, never {@code null}.
+ */
+ public static ConfigQuery<Set<String>> areas() {
+ return new ConfigQuery<Set<String>>() {
+ @Override
+ public Set<String> query(Configuration config) {
+ final Set<String> areas = new HashSet<>();
+ for(String s: config.getProperties().keySet()) {
+ int index = s.lastIndexOf('.');
+ if (index > 0) {
+ areas.add(s.substring(0, index));
+ } else {
+ areas.add("<root>");
+ }
+ }
+ return areas;
+ }
+ };
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
+ * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate
+ * as possible, but may not provide a complete set of areas that are finally accessible, especially when the
+ * underlying storage does not support key iteration.
+ *
+ * @return s set with all transitive areas, never {@code null}.
+ */
+ public static ConfigQuery<Set<String>> transitiveAreas() {
+ return new ConfigQuery<Set<String>>() {
+ @Override
+ public Set<String> query(Configuration config) {
+ final Set<String> transitiveAreas = new HashSet<>();
+ for (String s : config.query(areas())) {
+ int index = s.lastIndexOf('.');
+ if (index < 0) {
+ transitiveAreas.add("<root>");
+ } else {
+ while (index > 0) {
+ s = s.substring(0, index);
+ transitiveAreas.add(s);
+ index = s.lastIndexOf('.');
+ }
+ }
+ }
+ return transitiveAreas;
+ }
+ };
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualified area names, containing only the
+ * areas that match the predicate and have properties attached. This method should return the areas as accurate as possible,
+ * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
+ * does not support key iteration.
+ *
+ * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
+ * @return s set with all areas, never {@code null}.
+ */
+ public static ConfigQuery<Set<String>> areas(final Predicate<String> predicate) {
+ return new ConfigQuery<Set<String>>(){
+ @Override
+ public Set<String> query(Configuration config) {
+ Set<String> result = new TreeSet<>();
+ for(String s: areas().query(config)){
+ if(predicate.test(s)){
+ result.add(s);
+ }
+ }
+ return result;
+ }
+ };
+
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
+ * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate as possible,
+ * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
+ * does not support key iteration.
+ *
+ * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
+ * @return s set with all transitive areas, never {@code null}.
+ */
+ public static ConfigQuery<Set<String>> transitiveAreas(final Predicate<String> predicate) {
+ return new ConfigQuery<Set<String>>(){
+ @Override
+ public Set<String> query(Configuration config) {
+ Set<String> result = new TreeSet<>();
+ for(String s: transitiveAreas().query(config)){
+ if(predicate.test(s)){
+ result.add(s);
+ }
+ }
+ return result;
+ }
+ };
+ }
+
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ *
+ * @param areaKeys the area keys, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator areasRecursive(String... areaKeys) {
+ return areaRecursive(true, areaKeys);
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (recursive).
+ *
+ * @param areaKeys the area keys, not null
+ * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator areaRecursive(final boolean stripKeys, final String... areaKeys) {
+ return new ConfigOperator(){
+ @Override
+ public Configuration operate(Configuration config) {
+ Configuration filtered = new FilteredConfiguration(config, new BiPredicate<String, String>() {
+ @Override
+ public boolean test(final String k, String v) {
+ return isKeyInAreas(k, areaKeys);
+ }
+ } , "areas: " + Arrays.toString(areaKeys));
+ if(stripKeys){
+ return new MappedConfiguration(filtered, new Function<String, String>() {
+ @Override
+ public String apply(String s) {
+ return PropertySourceFunctions.stripAreaKeys(s, areaKeys);
+ }
+ }, "stripped");
+ }
+ return filtered;
+ }
+ };
+ }
+
+ /**
+ * Creates a ConfigQuery that creates a JSON formatted ouitput of all properties in the given configuration.
+ * @return the given query.
+ */
+ public static ConfigQuery<String> info() {
+ return INFO_QUERY;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
new file mode 100644
index 0000000..8797211
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
@@ -0,0 +1,72 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.TypeLiteral;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Configuration that filters part of the entries defined by a filter predicate.
+ */
+class FilteredConfiguration implements Configuration {
+
+ private final Configuration baseConfiguration;
+ private final BiPredicate<String, String> filter;
+ private String filterType;
+
+ FilteredConfiguration(Configuration baseConfiguration, BiPredicate<String, String> filter, String filterType) {
+ this.baseConfiguration = Objects.requireNonNull(baseConfiguration);
+ this.filter = Objects.requireNonNull(filter);
+ this.filterType = Optional.ofNullable(filterType).orElse(this.filter.toString());
+ }
+
+ @Override
+ public <T> T get(String key, TypeLiteral<T> type) {
+ String value = baseConfiguration.get(key);
+ if (filter.test(key, value)) {
+ return baseConfiguration.get(key, type);
+ }
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> result = new HashMap<>();
+ for(Map.Entry<String,String> en:baseConfiguration.getProperties().entrySet()){
+ if(filter.test(en.getKey(), en.getValue())){
+ result.put(en.getKey(), en.getValue());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "FilteredConfiguration{" +
+ "baseConfiguration=" + baseConfiguration +
+ ", filter=" + filter +
+ '}';
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
new file mode 100644
index 0000000..119ec71
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
@@ -0,0 +1,73 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * PropertySource that on the fly filters out part of the key/values of the underlying PropertySource.
+ */
+class FilteredPropertySource implements PropertySource {
+
+ private PropertySource baseSource;
+ private Predicate<String> filter;
+
+ /**
+ * Creates a new instance
+ * @param baseSource the underlying PropertySource
+ * @param filter the filter to be applied.
+ */
+ public FilteredPropertySource(PropertySource baseSource, Predicate<String> filter){
+ this.baseSource = Objects.requireNonNull(baseSource);
+ this.filter = Objects.requireNonNull(filter);
+ }
+
+ @Override
+ public int getOrdinal(){
+ return baseSource.getOrdinal();
+ }
+
+ @Override
+ public String getName() {
+ return baseSource.getName();
+ }
+
+ @Override
+ public Map<String,String> getProperties(){
+ final Map<String,String> result = new HashMap<>();
+ for(Map.Entry<String,String> en: this.baseSource.getProperties().entrySet()) {
+ if (filter.test(en.getKey())) {
+ result.put(en.getKey(), en.getValue());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "FilteredPropertySource{" +
+ "baseSource=" + baseSource +
+ ", filter=" + filter +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/Function.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/Function.java b/modules/functions/src/main/java/org/apache/tamaya/functions/Function.java
new file mode 100644
index 0000000..94b0e2f
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/Function.java
@@ -0,0 +1,42 @@
+/*
+ * 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.functions;
+
+/**
+ * Represents a function that accepts one argument and produces a result.
+ * <p>
+ * <p>This is a <a href="package-summary.html">functional interface</a>
+ * whose functional method is {@link #apply(Object)}.
+ *
+ * @param <T> the type of the input to the function
+ * @param <R> the type of the result of the function
+ */
+//@FunctionalInterface
+public interface Function<T, R> {
+
+ /**
+ * Applies this function to the given argument.
+ *
+ * @param t the function argument
+ * @return the function result
+ */
+ R apply(T t);
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
new file mode 100644
index 0000000..a4b729b
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
@@ -0,0 +1,67 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.TypeLiteral;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Configuration that filters part of the entries defined by a filter predicate.
+ */
+class MappedConfiguration implements Configuration {
+
+ private final Configuration baseConfiguration;
+ private final Function<String, String> keyMapper;
+ private final String mapType;
+
+ MappedConfiguration(Configuration baseConfiguration, Function<String, String> keyMapper, String mapType) {
+ this.baseConfiguration = Objects.requireNonNull(baseConfiguration);
+ this.keyMapper = Objects.requireNonNull(keyMapper);
+ this.mapType = Optional.ofNullable(mapType).orElse(this.keyMapper.toString());
+ }
+
+ @Override
+ public <T> T get(String key, TypeLiteral<T> type) {
+ return baseConfiguration.get(this.keyMapper.apply(key), type);
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> baseProps = baseConfiguration.getProperties();
+ Map<String, String> props = new HashMap<>(baseProps.size());
+ for(Map.Entry<String,String> en:baseProps.entrySet()){
+ props.put(keyMapper.apply(en.getKey()), en.getValue());
+ }
+ return props;
+ }
+
+ @Override
+ public String toString() {
+ return "FilteredConfiguration{" +
+ "baseConfiguration=" + baseConfiguration +
+ ", mapping=" + mapType +
+ '}';
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
new file mode 100644
index 0000000..f1395bc
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
@@ -0,0 +1,83 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.UnaryOperator;
+
+/**
+ * PropertySource implementation that maps certain parts (defined by an {@code UnaryOperator<String>}) to alternate areas.
+ */
+class MappedPropertySource implements PropertySource {
+
+ private static final long serialVersionUID = 8690637705511432083L;
+
+ /**
+ * The mapping operator.
+ */
+ private UnaryOperator<String> keyMapper;
+ /**
+ * The base configuration.
+ */
+ private PropertySource propertySource;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param config the base configuration, not null
+ * @param keyMapper The mapping operator, not null
+ */
+ public MappedPropertySource(PropertySource config, UnaryOperator<String> keyMapper) {
+ this.propertySource = Objects.requireNonNull(config);
+ this.keyMapper = Objects.requireNonNull(keyMapper);
+ }
+
+ @Override
+ public int getOrdinal() {
+ return this.propertySource.getOrdinal();
+ }
+
+ @Override
+ public String getName() {
+ return this.propertySource.getName() + "[mapped]";
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> result = new HashMap<>();
+ Map<String, String> map = this.propertySource.getProperties();
+ for (Map.Entry<String, String> en : map.entrySet()) {
+ String targetKey = keyMapper.apply(en.getKey());
+ if (targetKey != null) {
+ result.put(targetKey, en.getValue());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String get(String key) {
+ return getProperties().get(key);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/MetaEnrichedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MetaEnrichedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MetaEnrichedPropertySource.java
new file mode 100644
index 0000000..c2aeb8e
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/MetaEnrichedPropertySource.java
@@ -0,0 +1,81 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Configuration that filters part of the entries defined by a filter predicate.
+ */
+class MetaEnrichedPropertySource implements PropertySource {
+
+ private final PropertySource basePropertySource;
+ private final Map<String, String> metaInfo;
+
+ MetaEnrichedPropertySource(PropertySource basePropertySource, Map<String, String> metaInfo) {
+ this.basePropertySource = Objects.requireNonNull(basePropertySource);
+ this.metaInfo = Objects.requireNonNull(metaInfo);
+ }
+
+ // [meta:origin]a.b.c
+ @Override
+ public String get(String key) {
+ if(key.startsWith("[meta:")){
+ key = key.substring(6);
+ int index = key.indexOf(']');
+ String metaKey = key.substring(0,index);
+ String entryKey = key.substring(index+1);
+ String value = basePropertySource.get(entryKey);
+ if(value!=null) {
+ return metaInfo.get(metaKey);
+ }
+ }
+ return basePropertySource.get(key);
+ }
+
+ @Override
+ public String getName() {
+ return basePropertySource.getName();
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> baseProperties = basePropertySource.getProperties();
+ Map<String, String> allProperties = new HashMap<>(baseProperties);
+ for(Map.Entry<String,String> en: baseProperties.entrySet()) {
+ for (Map.Entry<String, String> miEn : metaInfo.entrySet()) {
+ allProperties.put("[meta:" + miEn.getKey() + ']' + en.getKey(), miEn.getValue());
+ }
+ }
+ return allProperties;
+ }
+
+ @Override
+ public String toString() {
+ return "MetaEnrichedPropertySource{" +
+ "basePropertySource=" + basePropertySource +
+ ", metaInfo=" + metaInfo +
+ '}';
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java b/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
new file mode 100644
index 0000000..3061746
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
@@ -0,0 +1,42 @@
+/*
+ * 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.functions;
+
+/**
+ * Represents a predicate (boolean-valued function) of one argument.
+ *
+ * <p>This is a <a href="package-summary.html">functional interface</a>
+ * whose functional method is {@link #test(Object)}.
+ *
+ * @param <T> the type of the input to the predicate
+ */
+//@FunctionalInterface
+public interface Predicate<T> {
+
+ /**
+ * Evaluates this predicate on the given argument.
+ *
+ * @param t the input argument
+ * @return {@code true} if the input argument matches the predicate,
+ * otherwise {@code false}
+ */
+ boolean test(T t);
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
new file mode 100644
index 0000000..bf76c7d
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
@@ -0,0 +1,240 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Accessor that provides useful functions along with configuration.
+ */
+public final class PropertySourceFunctions {
+ /**
+ * Private singleton constructor.
+ */
+ private PropertySourceFunctions() {
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ * <p>
+ * Metadata is added only for keys that are present on the original configuration.
+ * They are added in the following format:
+ * <pre>
+ * Given are
+ * 1) a configuration with two entries: entry1, entry 2
+ * 2) metadata as metaKey1=metaValue1, metaKey2=metaValue2
+ *
+ * The final configuration will look like:
+ *
+ * entry1=entry1Value;
+ * entry2=entry2Value;
+ * [meta:metaKey1]entry1=metaValue1
+ * [meta:metaKey2]entry1=metaValue2
+ * [meta:metaKey1]entry2=metaValue1
+ * [meta:metaKey2]entry2=metaValue2
+ * </pre>
+ *
+ * This mechanism allows to add meta information such as origin, sensitivity, to all keys of a current
+ * PropertySource or Configuration. If done on multiple PropertySources that are combined the corresponding
+ * values are visible in synch with the values visible.
+ *
+ * @param propertySource the base propertySource, not null.
+ * @param metaData the metaData to be added, not null
+ * @return the metadata enriched configuration, not null.
+ */
+ public static PropertySource addMetaData(PropertySource propertySource, Map<String,String> metaData) {
+ return new MetaEnrichedPropertySource(propertySource, metaData);
+ }
+
+ /**
+ * Calculates the current area key and compares it with the given key.
+ *
+ * @param key the fully qualified entry key, not null
+ * @param areaKey the area key, not null
+ * @return true, if the entry is exact in this area
+ */
+ public static boolean isKeyInArea(String key, String areaKey) {
+ int lastIndex = key.lastIndexOf('.');
+ String curAreaKey = lastIndex > 0 ? key.substring(0, lastIndex) : "";
+ return curAreaKey.equals(areaKey);
+ }
+
+ /**
+ * Calculates the current area key and compares it with the given area keys.
+ *
+ * @param key the fully qualified entry key, not null
+ * @param areaKeys the area keys, not null
+ * @return true, if the entry is exact in this area
+ */
+ public static boolean isKeyInAreas(String key, String... areaKeys) {
+ for(String areaKey:areaKeys){
+ if(isKeyInArea(key, areaKey)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualifies area names. This method should return the areas as accurate as possible,
+ * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
+ * does not support key iteration.
+ *
+ * @return s set with all areas, never {@code null}.
+ */
+ public static Set<String> areas(Map<String,String> map) {
+ final Set<String> areas = new HashSet<>();
+ for(String s: map.keySet()) {
+ int index = s.lastIndexOf('.');
+ if (index > 0) {
+ areas.add(s.substring(0, index));
+ } else {
+ areas.add("<root>");
+ }
+ }
+ return areas;
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
+ * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate
+ * as possible, but may not provide a complete set of areas that are finally accessible, especially when the
+ * underlying storage does not support key iteration.
+ *
+ * @return s set with all transitive areas, never {@code null}.
+ */
+ public static Set<String> transitiveAreas(Map<String,String> map) {
+ final Set<String> transitiveAreas = new HashSet<>();
+ for(String s:areas(map)) {
+ int index = s.lastIndexOf('.');
+ if (index < 0) {
+ transitiveAreas.add("<root>");
+ } else {
+ while (index > 0) {
+ s = s.substring(0, index);
+ transitiveAreas.add(s);
+ index = s.lastIndexOf('.');
+ }
+ }
+ }
+ return transitiveAreas;
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualified area names, containing only the
+ * areas that match the predicate and have properties attached. This method should return the areas as accurate as possible,
+ * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
+ * does not support key iteration.
+ *
+ * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
+ * @return s set with all areas, never {@code null}.
+ */
+ public static Set<String> areas(Map<String,String> map, final Predicate<String> predicate) {
+ Set<String> treeSet = new TreeSet<>();
+ for(String area: areas(map)){
+ if(predicate.test(area)){
+ treeSet.add(area);
+ }
+ }
+ return treeSet;
+ }
+
+ /**
+ * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
+ * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate as possible,
+ * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
+ * does not support key iteration.
+ *
+ * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
+ * @return s set with all transitive areas, never {@code null}.
+ */
+ public static Set<String> transitiveAreas(Map<String,String> map, Predicate<String> predicate) {
+ Set<String> treeSet = new TreeSet<>();
+ for(String area: transitiveAreas(map)){
+ if(predicate.test(area)){
+ treeSet.add(area);
+ }
+ }
+ return treeSet;
+ }
+
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ *
+ * @param areaKeys the area keys, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static Map<String,String> areasRecursive(Map<String,String> map, String... areaKeys) {
+ return areaRecursive(map, true, areaKeys);
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (recursive).
+ *
+ * @param areaKeys the area keys, not null
+ * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static Map<String,String> areaRecursive(Map<String,String> map, boolean stripKeys, String... areaKeys) {
+ Map<String,String> result = new HashMap<>(map.size());
+ if(stripKeys) {
+ for(Map.Entry<String,String> en: map.entrySet()){
+ if(isKeyInAreas(en.getKey(), areaKeys)){
+ result.put(en.getKey(), en.getValue());
+ }
+ }
+ } else {
+ for(Map.Entry<String,String> en: map.entrySet()){
+ if(isKeyInAreas(en.getKey(), areaKeys)){
+ result.put(stripAreaKeys(en.getKey(), areaKeys), en.getValue());
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Strips the area key of the given absolute key, if it is one of the areaKeys passed.
+ * @param key the current key, not null.
+ * @param areaKeys the areaKeys, not null.
+ * @return the stripped key, or the original key (if no area was matching).
+ */
+ static String stripAreaKeys(String key, String... areaKeys) {
+ for(String areaKey:areaKeys) {
+ if(key.startsWith(areaKey+'.')) {
+ return key.substring(areaKey.length() + 1);
+ }
+ }
+ return key;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/UnaryOperator.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/UnaryOperator.java b/modules/functions/src/main/java/org/apache/tamaya/functions/UnaryOperator.java
new file mode 100644
index 0000000..dc61b6d
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/UnaryOperator.java
@@ -0,0 +1,39 @@
+/*
+ * 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.functions;
+
+
+/**
+ * Represents an operation on a single operand that produces a result of the
+ * same type as its operand. This is a specialization of {@code Function} for
+ * the case where the operand and result are of the same type.
+ *
+ * <p>This is a <a href="package-summary.html">functional interface</a>
+ * whose functional method is {@link #apply(Object)}.
+ *
+ * @param <T> the type of the operand and result of the operator
+ *
+ * @see java.util.function.Function
+ * @since 1.8
+ */
+//@FunctionalInterface
+public interface UnaryOperator<T> extends Function<T, T> {
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/ValueFilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ValueFilteredPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ValueFilteredPropertySource.java
new file mode 100644
index 0000000..cdbc577
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ValueFilteredPropertySource.java
@@ -0,0 +1,78 @@
+/*
+ * 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.functions;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.BiFunction;
+
+/**
+ * Property source which filters any key/values dynamically.
+ */
+class ValueFilteredPropertySource implements PropertySource{
+
+ private String name;
+ private BiFunction<String, String, String> valueFilter;
+ private PropertySource source;
+
+ public ValueFilteredPropertySource(String name, BiFunction<String, String, String> valueFilter, PropertySource current) {
+ this.name = Optional.ofNullable(name).orElse("<valueFiltered> -> name="+current.getName()+", valueFilter="+valueFilter.toString());
+ this.valueFilter = valueFilter;
+ this.source = Objects.requireNonNull(current);
+ }
+
+ @Override
+ public int getOrdinal() {
+ return source.getOrdinal();
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String get(String key) {
+ String value = this.source.get(key);
+ if(value!=null) {
+ return valueFilter.apply(key, value);
+ }
+ return value;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> map = new HashMap<>(source.getProperties());
+ map.replaceAll(valueFilter);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "ValueFilteredPropertySource{" +
+ "source=" + source.getName() +
+ ", name='" + name + '\'' +
+ ", valueFilter=" + valueFilter +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java b/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java
new file mode 100644
index 0000000..fa908e9
--- /dev/null
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+/**
+ * Contains additional useful operators and queries.
+ */
+package org.apache.tamaya.resource.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/pom.xml
----------------------------------------------------------------------
diff --git a/modules/management/pom.xml b/modules/management/pom.xml
new file mode 100644
index 0000000..f519307
--- /dev/null
+++ b/modules/management/pom.xml
@@ -0,0 +1,57 @@
+<!--
+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-extensions</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>tamaya-management</artifactId>
+ <name>Apache Tamaya Modules - Java Management Extensions</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-java7-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-functions</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-java7-core</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java
----------------------------------------------------------------------
diff --git a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java b/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java
new file mode 100644
index 0000000..3b6e99f
--- /dev/null
+++ b/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java
@@ -0,0 +1,106 @@
+/*
+ * 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.management;
+
+
+import org.apache.tamaya.functions.ConfigurationFunctions;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Created by Anatole on 24.11.2014.
+ */
+public class ManagedConfig implements ManagedConfigMBean{
+
+ /** The logger used. */
+ private final static Logger LOG = Logger.getLogger(ManagedConfig.class.getName());
+
+ @Override
+ public String getConfigurationInfo() {
+ return ConfigurationProvider.getConfiguration().query(ConfigurationFunctions.info());
+ }
+
+ @Override
+ public Map<String, String> getConfiguration() {
+ return ConfigurationProvider.getConfiguration().getProperties();
+ }
+
+ @Override
+ public Map<String, String> getConfigurationArea(String area, boolean recursive) {
+ return ConfigurationProvider.getConfiguration().with(ConfigurationFunctions.area(area, recursive)).getProperties();
+ }
+
+ @Override
+ public Set<String> getAreas() {
+ return ConfigurationProvider.getConfiguration().query(ConfigurationFunctions.areas());
+ }
+
+ @Override
+ public Set<String> getTransitiveAreas() {
+ return ConfigurationProvider.getConfiguration().query(ConfigurationFunctions.transitiveAreas());
+ }
+
+ @Override
+ public boolean isAreaExisting(String area) {
+ return !ConfigurationProvider.getConfiguration().with(
+ ConfigurationFunctions.area(area)).getProperties().isEmpty();
+ }
+
+ /**
+ * Registers the {@link ManagedConfigMBean} mbean for accessing config documentation into the local platform
+ * mbean server.
+ */
+ public static void registerMBean() {
+ registerMBean(null);
+ }
+
+ /**
+ * Registers the {@link ManagedConfigMBean} mbean for accessing config documentation into the local platform
+ * mbean server.
+ */
+ public static void registerMBean(String context) {
+ try{
+ ManagedConfigMBean configMbean = ServiceContextManager.getServiceContext()
+ .getService(ManagedConfigMBean.class);
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ ObjectName on = context==null?new ObjectName("org.apache.tamaya.managemet:type=ManagedConfigMBean"):
+ new ObjectName("org.apache.tamaya.management:type=ManagedConfigMBean,context="+context);
+ try{
+ mbs.getMBeanInfo(on);
+ LOG.warning("Cannot register mbean " + on + ": already existing.");
+ } catch(InstanceNotFoundException e) {
+ LOG.info("Registering mbean " + on + "...");
+ mbs.registerMBean(configMbean, on);
+ }
+ } catch(Exception e){
+ Logger.getLogger(ManagedConfig.class.getName()).log(Level.WARNING,
+ "Failed to register ManagedConfigMBean.", e);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
----------------------------------------------------------------------
diff --git a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java b/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
new file mode 100644
index 0000000..94ec3ea
--- /dev/null
+++ b/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.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.management;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Managed bean interface for accessing environment data.
+ */
+public interface ManagedConfigMBean {
+
+ /**
+ * Get a general description of the configuration (context) in place, in JSON format:
+ * <pre>
+ * ConfigurationContext[gqContextClassName] {
+ * version = 2345-34334-2333-3434,
+ * config {
+ * key = "value",
+ * key2 = "value2"
+ * ...
+ * },
+ * filters = [...],
+ * converters{...},
+ * property-sources{...}
+ * }
+ * </pre>
+ *
+ * @return a JSON formatted meta-information.
+ */
+ String getConfigurationInfo();
+
+
+ /**
+ * Accesses a configuration current a given type as Map.
+ *
+ * @return the current configuration map.
+ * @throws org.apache.tamaya.ConfigException If the configuration is not available.
+ */
+ Map<String, String> getConfiguration();
+
+ /**
+ * Accesses a configuration values for current a given config area as Map.
+ * @param area the target area key, not null.
+ * @param recursive if set to false only direct child keys of the given area are returned.
+ * @return the key/values found, including the recursive child values.
+ * @throws org.apache.tamaya.ConfigException If the configuration is not yet loaded.
+ */
+ Map<String, String> getConfigurationArea(String area, boolean recursive);
+
+ /**
+ * Access the defined areas for a given configuration.
+ * @return the areas defined (only returning the areas that contain properties).
+ * @throws org.apache.tamaya.ConfigException If the configuration is not yet loaded
+ */
+ Set<String> getAreas();
+
+ /**
+ * Access the transitive areas for the current configuration.
+ * @return the transitive areas defined.
+ * @throws org.apache.tamaya.ConfigException If the configuration is not yet loaded
+ */
+ Set<String> getTransitiveAreas();
+
+ /**
+ * Allows to determine if an area is existing.
+ * @param area the target area key, not null.
+ * @return true, if such an area exists (the area may be empty).
+ */
+ boolean isAreaExisting(String area);
+
+ /**
+ * Allows to determine if an area is empty.
+ * @param area the target area key, not null.
+ * @return true, if such an area exists and is not empty.
+ */
+ default boolean isAreaEmpty(String area){
+ return getConfigurationArea(area, true).isEmpty();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/management/src/main/resources/META-INF/beans.xml b/modules/management/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..adee378
--- /dev/null
+++ b/modules/management/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+</beans>
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean
----------------------------------------------------------------------
diff --git a/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean b/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean
new file mode 100644
index 0000000..4ba72b6
--- /dev/null
+++ b/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean
@@ -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.management.ManagedConfig
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/src/test/java/org/apache/tamaya/management/ManagedConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/management/src/test/java/org/apache/tamaya/management/ManagedConfigTest.java b/modules/management/src/test/java/org/apache/tamaya/management/ManagedConfigTest.java
new file mode 100644
index 0000000..577425e
--- /dev/null
+++ b/modules/management/src/test/java/org/apache/tamaya/management/ManagedConfigTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.management;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by Anatole on 20.08.2015.
+ */
+public class ManagedConfigTest {
+
+ private ManagedConfig bean = new ManagedConfig();
+
+ @org.junit.Test
+ public void testGetConfigurationInfo() throws Exception {
+ System.out.println(bean.getConfigurationInfo());
+ }
+
+ @org.junit.Test
+ public void testGetConfiguration() throws Exception {
+ System.out.println(bean.getConfiguration());
+ }
+
+ @org.junit.Test
+ public void testGetConfigurationArea() throws Exception {
+ System.out.println(bean.getConfigurationArea("a", false));
+ }
+
+ @org.junit.Test
+ public void testGetAreas() throws Exception {
+ System.out.println(bean.getAreas());
+ }
+
+ @org.junit.Test
+ public void testGetTransitiveAreas() throws Exception {
+ System.out.println(bean.getTransitiveAreas());
+ }
+
+ @org.junit.Test
+ public void testIsAreaExisting() throws Exception {
+ assertTrue(bean.isAreaExisting("java"));
+ assertFalse(bean.isAreaExisting("sd.fldsfl.erlwsf"));
+ }
+
+ @org.junit.Test
+ public void testRegisterMBean() throws Exception {
+ ManagedConfig.registerMBean();
+ ManagedConfig.registerMBean();
+ // Lookup object name
+
+ }
+
+ @org.junit.Test
+ public void testRegisterMBean1() throws Exception {
+ ManagedConfig.registerMBean("SubContext1");
+ ManagedConfig.registerMBean("SubContext1");
+ ManagedConfig.registerMBean("SubContext2");
+ // Lookup object name
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/management/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/management/src/test/resources/META-INF/beans.xml b/modules/management/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..adee378
--- /dev/null
+++ b/modules/management/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+</beans>
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c5343410/modules/model/pom.xml
----------------------------------------------------------------------
diff --git a/modules/model/pom.xml b/modules/model/pom.xml
new file mode 100644
index 0000000..c30e97d
--- /dev/null
+++ b/modules/model/pom.xml
@@ -0,0 +1,85 @@
+<!--
+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-extensions</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <groupId>org.apache.tamaya.ext.model</groupId>
+ <artifactId>tamaya-model</artifactId>
+ <name>Apache Tamaya Extension Modules: Configuration Model Infrastructure</name>
+ <description>This extension module provides functionality to describe, document and
+ validate configuration during runtime.
+ </description>
+ <packaging>jar</packaging>
+
+ <properties>
+ <jdkVersion>1.7</jdkVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-java7-api</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-java7-core</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <scope>Test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-formats</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-json</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>0.9-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <version>1.0-alpha-1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>