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 2018/02/06 07:57:19 UTC
incubator-tamaya-sandbox git commit: Renamed Meta main singleton.
Repository: incubator-tamaya-sandbox
Updated Branches:
refs/heads/configjsr f030e1225 -> 36faebb63
Renamed Meta main singleton.
Signed-off-by: Anatole Tresch <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/36faebb6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/36faebb6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/36faebb6
Branch: refs/heads/configjsr
Commit: 36faebb6381e0f192cc76b40c615bfeef40accc6
Parents: f030e12
Author: Anatole Tresch <an...@apache.org>
Authored: Tue Feb 6 08:57:05 2018 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Tue Feb 6 08:57:05 2018 +0100
----------------------------------------------------------------------
.../collections/AdaptiveCombinationPolicy.java | 8 +-
.../tamaya/collections/CollectionConverter.java | 6 +-
.../tamaya/collections/ItemTokenizer.java | 8 +-
.../tamaya/collections/ListConverter.java | 6 +-
.../apache/tamaya/collections/MapConverter.java | 6 +-
.../apache/tamaya/collections/SetConverter.java | 6 +-
.../org/apache/tamaya/meta/MetaProperties.java | 179 -------------------
.../apache/tamaya/meta/MetaPropertyMapper.java | 179 +++++++++++++++++++
.../internal/DefaultMetaPropertyMapping.java | 2 +-
.../meta/internal/EtcdMetaPropertyMapping.java | 2 +-
10 files changed, 201 insertions(+), 201 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java b/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
index a88437e..fdad74a 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.collections;
-import org.apache.tamaya.meta.MetaProperties;
+import org.apache.tamaya.meta.MetaPropertyMapper;
import org.apache.tamaya.base.ConfigValueCombinationPolicy;
import javax.annotation.Priority;
@@ -50,7 +50,7 @@ public class AdaptiveCombinationPolicy implements ConfigValueCombinationPolicy {
if(currentValue==null){
return newValue;
}
- final String separator = MetaProperties.getOptionalMetaEntry(ConfigProvider.getConfig(),
+ final String separator = MetaPropertyMapper.getOptionalMetaEntry(ConfigProvider.getConfig(),
key, "item-separator").orElse(",");
return currentValue + separator + newValue;
}else{
@@ -66,14 +66,14 @@ public class AdaptiveCombinationPolicy implements ConfigValueCombinationPolicy {
@Override
public String collect(String currentValue, String key, ConfigSource propertySource){
- if(MetaProperties.isMetaEntry(key)){
+ if(MetaPropertyMapper.isMetaEntry(key)){
String newValue = propertySource.getValue(key);
if(newValue!=null){
return newValue;
}
return currentValue;
}
- String adaptiveCombinationPolicyClass = MetaProperties.getOptionalMetaEntry(
+ String adaptiveCombinationPolicyClass = MetaPropertyMapper.getOptionalMetaEntry(
ConfigProvider.getConfig(),
key, "combination-policy").orElse("override");
ConfigValueCombinationPolicy combinationPolicy = null;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/collections/src/main/java/org/apache/tamaya/collections/CollectionConverter.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/tamaya/collections/CollectionConverter.java b/collections/src/main/java/org/apache/tamaya/collections/CollectionConverter.java
index 4d410cc..54e4bfe 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/CollectionConverter.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/CollectionConverter.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.collections;
-import org.apache.tamaya.meta.MetaProperties;
+import org.apache.tamaya.meta.MetaPropertyMapper;
import javax.config.spi.Converter;
import java.util.Collection;
@@ -31,7 +31,7 @@ public class CollectionConverter implements Converter<Collection> {
@Override
public Collection convert(String value) {
- String collectionType = MetaProperties.getOptionalMetaEntry(
+ String collectionType = MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"collection-type").orElse("List");
@@ -57,7 +57,7 @@ public class CollectionConverter implements Converter<Collection> {
result = ArrayListConverter.getInstance().convert(value);
break;
}
- if(MetaProperties.getOptionalMetaEntry(
+ if(MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"read-only", boolean.class).orElse(true)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java b/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
index 93836d5..2d369eb 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.collections;
import org.apache.tamaya.base.TypeUtils;
import org.apache.tamaya.base.convert.ConversionContext;
import org.apache.tamaya.base.convert.ConverterManager;
-import org.apache.tamaya.meta.MetaProperties;
+import org.apache.tamaya.meta.MetaPropertyMapper;
import org.apache.tamaya.base.ConfigContextSupplier;
import javax.config.Config;
@@ -54,7 +54,7 @@ final class ItemTokenizer {
*/
public static List<String> split(String value){
return split(value,
- MetaProperties.getOptionalMetaEntry(
+ MetaPropertyMapper.getOptionalMetaEntry(
config(),
key(),"item-separator").orElse( ","));
}
@@ -95,7 +95,7 @@ final class ItemTokenizer {
* @return an array of length 2, with the trimmed and parsed key/value pair.
*/
public static String[] splitMapEntry(String mapEntry){
- return splitMapEntry(mapEntry, MetaProperties.getOptionalMetaEntry(
+ return splitMapEntry(mapEntry, MetaPropertyMapper.getOptionalMetaEntry(
config(),
key(),".map-entry-separator").orElse( "::"));
}
@@ -137,7 +137,7 @@ final class ItemTokenizer {
* @return the parsed value, or null.
*/
public static Object convertValue(String value) {
- String converterClass = MetaProperties.getOptionalMetaEntry(
+ String converterClass = MetaPropertyMapper.getOptionalMetaEntry(
config(),
key(),"item-converters").orElse(null);
List<Converter> valueConverters = new ArrayList<>(1);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/collections/src/main/java/org/apache/tamaya/collections/ListConverter.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/tamaya/collections/ListConverter.java b/collections/src/main/java/org/apache/tamaya/collections/ListConverter.java
index e0d055c..718afa3 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/ListConverter.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/ListConverter.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.collections;
-import org.apache.tamaya.meta.MetaProperties;
+import org.apache.tamaya.meta.MetaPropertyMapper;
import javax.config.spi.Converter;
import java.util.Collections;
@@ -31,7 +31,7 @@ public class ListConverter implements Converter<List> {
@Override
public List convert(String value) {
- String collectionType = MetaProperties.getOptionalMetaEntry(
+ String collectionType = MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"collection-type").orElse("List");
@@ -49,7 +49,7 @@ public class ListConverter implements Converter<List> {
result = ArrayListConverter.getInstance().convert(value);
break;
}
- if(MetaProperties.getOptionalMetaEntry(
+ if(MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"read-only", boolean.class).orElse(true)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/collections/src/main/java/org/apache/tamaya/collections/MapConverter.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/tamaya/collections/MapConverter.java b/collections/src/main/java/org/apache/tamaya/collections/MapConverter.java
index 1696519..b0eb422 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/MapConverter.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/MapConverter.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.collections;
-import org.apache.tamaya.meta.MetaProperties;
+import org.apache.tamaya.meta.MetaPropertyMapper;
import javax.config.spi.Converter;
import java.util.Collections;
@@ -31,7 +31,7 @@ public class MapConverter implements Converter<Map> {
@Override
public Map convert(String value) {
- String collectionType = MetaProperties.getOptionalMetaEntry(
+ String collectionType = MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"collection-type").orElse("Map");
@@ -52,7 +52,7 @@ public class MapConverter implements Converter<Map> {
result = HashMapConverter.getInstance().convert(value);
break;
}
- if(MetaProperties.getOptionalMetaEntry(
+ if(MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"read-only", boolean.class).orElse(true)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/collections/src/main/java/org/apache/tamaya/collections/SetConverter.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/tamaya/collections/SetConverter.java b/collections/src/main/java/org/apache/tamaya/collections/SetConverter.java
index 2107c58..8c8141f 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/SetConverter.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/SetConverter.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.collections;
-import org.apache.tamaya.meta.MetaProperties;
+import org.apache.tamaya.meta.MetaPropertyMapper;
import javax.config.spi.Converter;
import java.util.Collections;
@@ -31,7 +31,7 @@ public class SetConverter implements Converter<Set> {
@Override
public Set convert(String value) {
- String collectionType = MetaProperties.getOptionalMetaEntry(ItemTokenizer.config(),
+ String collectionType = MetaPropertyMapper.getOptionalMetaEntry(ItemTokenizer.config(),
ItemTokenizer.key(),"collection-type").orElse("Set");
if(collectionType.startsWith("java.util.")){
collectionType = collectionType.substring("java.util.".length());
@@ -47,7 +47,7 @@ public class SetConverter implements Converter<Set> {
result = HashSetConverter.getInstance().convert(value);
break;
}
- if(MetaProperties.getOptionalMetaEntry(
+ if(MetaPropertyMapper.getOptionalMetaEntry(
ItemTokenizer.config(),
ItemTokenizer.key(),
"read-only", boolean.class).orElse(true)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/meta/src/main/java/org/apache/tamaya/meta/MetaProperties.java
----------------------------------------------------------------------
diff --git a/meta/src/main/java/org/apache/tamaya/meta/MetaProperties.java b/meta/src/main/java/org/apache/tamaya/meta/MetaProperties.java
deleted file mode 100644
index 8fa181f..0000000
--- a/meta/src/main/java/org/apache/tamaya/meta/MetaProperties.java
+++ /dev/null
@@ -1,179 +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.meta;
-
-
-import org.apache.tamaya.meta.spi.MetaPropertyMapping;
-import org.apache.tamaya.base.ServiceContextManager;
-
-import javax.config.Config;
-import javax.config.spi.ConfigSource;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Predicate;
-import java.util.logging.Logger;
-
-
-/**
- * Accessor singleton for Meta-entries.
- */
-public final class MetaProperties {
-
- /** The logger used. */
- private final static Logger LOG = Logger.getLogger(MetaProperties.class.getName());
-
-
- /**
- * Private singleton constructor.
- */
- private MetaProperties(){}
-
- /**
- * Checks if the given key is a meta-entry.
- * @param key the config key, not null.
- * @return true, if the entry is a meta-entry.
- */
- public static boolean isMetaEntry(String key){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- return mapping.getMetaEntryFilter(null).test(key);
- }
-
- /**
- * Get all meta-entries of the given config instance.
- * @param config the config, not null.
- * @return the meta entries found.
- */
- public static Map<String,String> getMetaEntries(Config config){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- Map<String,String> result = new HashMap<>();
- Predicate<String> filter = mapping.getMetaEntryFilter(null);
- config.getPropertyNames().forEach(k -> {
- if(filter.test(k)){
- result.put(k, config.getValue(k, String.class));
- }
- });
- return result;
- }
-
- /**
- * Get all meta-entries of the given config source and entry of the given configuration.
- * @param config the config, not null
- * @param configSource the configSource name, not null.
- * @return the meta entries found.
- */
- public static Map<String,String> getMetaEntriesForConfigSource(Config config, String configSource){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- Map<String,String> result = new HashMap<>();
- Predicate<String> filter = mapping.getMetaEntryFilter(null);
- for(ConfigSource cs:config.getConfigSources()){
- if(cs.getName().equals(configSource)){
- cs.getProperties().forEach((key, value) -> {
- if (filter.test(key)) {
- result.put(key, value);
- }
- });
- }
- }
- return result;
- }
-
- /**
- * Get all meta-entries of the given config instance and entry.
- * @param config the config, not null
- * @param key the target key, not null.
- * @return the meta entries found.
- */
- public static Map<String,String> getMetaEntries(Config config, String key){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- Map<String,String> result = new HashMap<>();
- Predicate<String> filter = mapping.getMetaEntryFilter(key);
- config.getPropertyNames().forEach(k -> {
- if(filter.test(k)){
- result.put(k, config.getValue(k, String.class));
- }
- });
- return result;
- }
-
- /**
- * Get the given metaentry.
- * @param config the config, not null
- * @param key the target key, not null.
- * @param metaEntry the meta entry key, not null.
- * @return the meta entry value.
- */
- public static String getMetaEntry(Config config, String key, String metaEntry){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- return config.getValue(mapping.getKey(key, metaEntry), String.class);
- }
-
- /**
- * Get the given metaentry.
- * @param config the config, not null
- * @param key the target key, not null.
- * @param metaEntry the meta entry key, not null.
- * @param targetType the target type, not null.
- * @return the meta entry value.
- */
- public static <T> T getMetaEntry(Config config, String key, String metaEntry, Class<T> targetType){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- return config.getValue(mapping.getKey(key, metaEntry), targetType);
- }
-
- /**
- * Get the given (optional) metaentry.
- * @param config the config, not null
- * @param key the target key, not null.
- * @param metaEntry the meta entry key, not null.
- * @return the meta entry value.
- */
- public static Optional<String> getOptionalMetaEntry(Config config, String key, String metaEntry){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- return config.getOptionalValue(mapping.getKey(key, metaEntry), String.class);
- }
-
- /**
- * Get the given (optional) metaentry.
- * @param config the config, not null
- * @param key the target key, not null.
- * @param metaEntry the meta entry key, not null.
- * @param targetType the target type, not null.
- * @return the meta entry value.
- */
- public static <T> Optional<T> getOptionalMetaEntry(Config config, String key, String metaEntry, Class<T> targetType) {
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- return config.getOptionalValue(mapping.getKey(key, metaEntry), targetType);
- }
-
- /**
- * Get the corresponding meta key for a given key. This method can be used by property sources to add
- * the correct meta keys, hereby using the correct metadata representation key layout.
- * @param entryKey the key of the config entry, not null.
- * @param metaKey the metadata key, not null.
- * @return the key to be used to store/reference the given metadata.
- */
- public static String getMetaKey(String entryKey, String metaKey){
- MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
- return mapping.getKey(entryKey, metaKey);
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/meta/src/main/java/org/apache/tamaya/meta/MetaPropertyMapper.java
----------------------------------------------------------------------
diff --git a/meta/src/main/java/org/apache/tamaya/meta/MetaPropertyMapper.java b/meta/src/main/java/org/apache/tamaya/meta/MetaPropertyMapper.java
new file mode 100644
index 0000000..b959a75
--- /dev/null
+++ b/meta/src/main/java/org/apache/tamaya/meta/MetaPropertyMapper.java
@@ -0,0 +1,179 @@
+/*
+ * 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.meta;
+
+
+import org.apache.tamaya.meta.spi.MetaPropertyMapping;
+import org.apache.tamaya.base.ServiceContextManager;
+
+import javax.config.Config;
+import javax.config.spi.ConfigSource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.logging.Logger;
+
+
+/**
+ * Accessor singleton for Meta-entries.
+ */
+public final class MetaPropertyMapper {
+
+ /** The logger used. */
+ private final static Logger LOG = Logger.getLogger(MetaPropertyMapper.class.getName());
+
+
+ /**
+ * Private singleton constructor.
+ */
+ private MetaPropertyMapper(){}
+
+ /**
+ * Checks if the given key is a meta-entry.
+ * @param key the config key, not null.
+ * @return true, if the entry is a meta-entry.
+ */
+ public static boolean isMetaEntry(String key){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ return mapping.getMetaEntryFilter(null).test(key);
+ }
+
+ /**
+ * Get all meta-entries of the given config instance.
+ * @param config the config, not null.
+ * @return the meta entries found.
+ */
+ public static Map<String,String> getMetaEntries(Config config){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ Map<String,String> result = new HashMap<>();
+ Predicate<String> filter = mapping.getMetaEntryFilter(null);
+ config.getPropertyNames().forEach(k -> {
+ if(filter.test(k)){
+ result.put(k, config.getValue(k, String.class));
+ }
+ });
+ return result;
+ }
+
+ /**
+ * Get all meta-entries of the given config source and entry of the given configuration.
+ * @param config the config, not null
+ * @param configSource the configSource name, not null.
+ * @return the meta entries found.
+ */
+ public static Map<String,String> getMetaEntriesForConfigSource(Config config, String configSource){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ Map<String,String> result = new HashMap<>();
+ Predicate<String> filter = mapping.getMetaEntryFilter(null);
+ for(ConfigSource cs:config.getConfigSources()){
+ if(cs.getName().equals(configSource)){
+ cs.getProperties().forEach((key, value) -> {
+ if (filter.test(key)) {
+ result.put(key, value);
+ }
+ });
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get all meta-entries of the given config instance and entry.
+ * @param config the config, not null
+ * @param key the target key, not null.
+ * @return the meta entries found.
+ */
+ public static Map<String,String> getMetaEntries(Config config, String key){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ Map<String,String> result = new HashMap<>();
+ Predicate<String> filter = mapping.getMetaEntryFilter(key);
+ config.getPropertyNames().forEach(k -> {
+ if(filter.test(k)){
+ result.put(k, config.getValue(k, String.class));
+ }
+ });
+ return result;
+ }
+
+ /**
+ * Get the given metaentry.
+ * @param config the config, not null
+ * @param key the target key, not null.
+ * @param metaEntry the meta entry key, not null.
+ * @return the meta entry value.
+ */
+ public static String getMetaEntry(Config config, String key, String metaEntry){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ return config.getValue(mapping.getKey(key, metaEntry), String.class);
+ }
+
+ /**
+ * Get the given metaentry.
+ * @param config the config, not null
+ * @param key the target key, not null.
+ * @param metaEntry the meta entry key, not null.
+ * @param targetType the target type, not null.
+ * @return the meta entry value.
+ */
+ public static <T> T getMetaEntry(Config config, String key, String metaEntry, Class<T> targetType){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ return config.getValue(mapping.getKey(key, metaEntry), targetType);
+ }
+
+ /**
+ * Get the given (optional) metaentry.
+ * @param config the config, not null
+ * @param key the target key, not null.
+ * @param metaEntry the meta entry key, not null.
+ * @return the meta entry value.
+ */
+ public static Optional<String> getOptionalMetaEntry(Config config, String key, String metaEntry){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ return config.getOptionalValue(mapping.getKey(key, metaEntry), String.class);
+ }
+
+ /**
+ * Get the given (optional) metaentry.
+ * @param config the config, not null
+ * @param key the target key, not null.
+ * @param metaEntry the meta entry key, not null.
+ * @param targetType the target type, not null.
+ * @return the meta entry value.
+ */
+ public static <T> Optional<T> getOptionalMetaEntry(Config config, String key, String metaEntry, Class<T> targetType) {
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ return config.getOptionalValue(mapping.getKey(key, metaEntry), targetType);
+ }
+
+ /**
+ * Get the corresponding meta key for a given key. This method can be used by property sources to add
+ * the correct meta keys, hereby using the correct metadata representation key layout.
+ * @param entryKey the key of the config entry, not null.
+ * @param metaKey the metadata key, not null.
+ * @return the key to be used to store/reference the given metadata.
+ */
+ public static String getMetaKey(String entryKey, String metaKey){
+ MetaPropertyMapping mapping = ServiceContextManager.getServiceContext().getService(MetaPropertyMapping.class);
+ return mapping.getKey(entryKey, metaKey);
+ }
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/meta/src/main/java/org/apache/tamaya/meta/internal/DefaultMetaPropertyMapping.java
----------------------------------------------------------------------
diff --git a/meta/src/main/java/org/apache/tamaya/meta/internal/DefaultMetaPropertyMapping.java b/meta/src/main/java/org/apache/tamaya/meta/internal/DefaultMetaPropertyMapping.java
index 495af8a..3ff4749 100644
--- a/meta/src/main/java/org/apache/tamaya/meta/internal/DefaultMetaPropertyMapping.java
+++ b/meta/src/main/java/org/apache/tamaya/meta/internal/DefaultMetaPropertyMapping.java
@@ -46,7 +46,7 @@ import java.util.function.Predicate;
* </pre>
*/
@Priority(1)
-public final class DefaultMetaPropertyMapping implements MetaPropertyMapping{
+public final class DefaultMetaPropertyMapping implements MetaPropertyMapping {
@Override
public String getKey(String entryKey, String metaKey) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/36faebb6/meta/src/main/java/org/apache/tamaya/meta/internal/EtcdMetaPropertyMapping.java
----------------------------------------------------------------------
diff --git a/meta/src/main/java/org/apache/tamaya/meta/internal/EtcdMetaPropertyMapping.java b/meta/src/main/java/org/apache/tamaya/meta/internal/EtcdMetaPropertyMapping.java
index 14e9009..aea4bb8 100644
--- a/meta/src/main/java/org/apache/tamaya/meta/internal/EtcdMetaPropertyMapping.java
+++ b/meta/src/main/java/org/apache/tamaya/meta/internal/EtcdMetaPropertyMapping.java
@@ -41,7 +41,7 @@ import java.util.function.Predicate;
* _foo.bar.Property.propertySource=MyPropertySource
* </pre>
*/
-public final class EtcdMetaPropertyMapping implements MetaPropertyMapping{
+public final class EtcdMetaPropertyMapping implements MetaPropertyMapping {
@Override
public String getKey(String entryKey, String metaKey) {