http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java b/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java index 52247c9..3293153 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java @@ -50,7 +50,7 @@ import static org.apache.tamaya.core.internal.BannerManager.BANNER_RESOURCE_PATH * <dd>The banner will be logged</dd> * </dl> * - * In case of any other value the banner will not be shown. + * In case of any other createValue the banner will not be shown. * </p> * *
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java index 59a0512..7a5c7ff 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java @@ -93,7 +93,9 @@ public final class CoreConfigurationBuilder extends DefaultConfigurationBuilder this.combinationPolicy, this.propertyFilters, this.propertySources, - this.propertyConverters)); + this.propertyConverters, + this.metaDataProvider + )); built = true; return cfg; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceComparator.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceComparator.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceComparator.java index c9815cf..f039d27 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceComparator.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceComparator.java @@ -42,7 +42,7 @@ class OSGIServiceComparator implements Comparator<ServiceReference> { } /** - * Checks the given instance for a @Priority annotation. If present the annotation's value is evaluated. If no such + * Checks the given instance for a @Priority annotation. If present the annotation's createValue is evaluated. If no such * annotation is present, a default priority {@code 1} is returned. * * @param o the instance, not {@code null}. @@ -53,7 +53,7 @@ class OSGIServiceComparator implements Comparator<ServiceReference> { } /** - * Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated. + * Checks the given type optionally annotated with a @Priority. If present the annotation's createValue is evaluated. * If no such annotation is present, a default priority {@code 1} is returned. * * @param type the type, not {@code null}. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java index 57a4418..c0645b1 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java @@ -18,6 +18,7 @@ */ package org.apache.tamaya.core.internal; +import org.apache.tamaya.spi.ClassloaderAware; import org.apache.tamaya.spi.ConfigurationProviderSpi; import org.apache.tamaya.spi.ServiceContext; import org.osgi.framework.Bundle; @@ -27,6 +28,8 @@ import org.osgi.framework.ServiceReference; import java.io.IOException; import java.net.URL; import java.util.*; +import java.util.function.Supplier; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -65,7 +68,7 @@ public class OSGIServiceContext implements ServiceContext{ } @Override - public <T> T getService(Class<T> serviceType) { + public <T> T getService(Class<T> serviceType, Supplier<T> supplier) { LOG.finest("TAMAYA Loading service: " + serviceType.getName()); ServiceReference<T> ref = this.osgiServiceLoader.getBundleContext().getServiceReference(serviceType); if(ref!=null){ @@ -73,33 +76,66 @@ public class OSGIServiceContext implements ServiceContext{ } if(ConfigurationProviderSpi.class==serviceType){ @SuppressWarnings("unchecked") - T service = (T)new CoreConfigurationProvider(); + T service = (T)new CoreConfigurationProvider(); this.osgiServiceLoader.getBundleContext().registerService( serviceType.getName(), service, new Hashtable<String, Object>()); return service; } + if(supplier!=null){ + T t = supplier.get(); + if(t instanceof ClassloaderAware){ + ((ClassloaderAware)t).init(getClassLoader()); + } + this.osgiServiceLoader.getBundleContext().registerService( + serviceType.getName(), + t, + new Hashtable<String, Object>()); + return t; + } return null; } - @SuppressWarnings("unchecked") - @Override - public <T> T create(Class<T> serviceType) { + + @Override + public <T> T create(Class<T> serviceType, Supplier<T> supplier) { LOG.finest("TAMAYA Creating service: " + serviceType.getName()); ServiceReference<T> ref = this.osgiServiceLoader.getBundleContext().getServiceReference(serviceType); if(ref!=null){ try { return (T)this.osgiServiceLoader.getBundleContext().getService(ref).getClass().newInstance(); } catch (Exception e) { + if(supplier!=null){ + return supplier.get(); + } return null; } } + if(supplier!=null){ + return supplier.get(); + } return null; } @Override - public <T> List<T> getServices(Class<T> serviceType) { + public <T> List<T> getServices(Class<T> serviceType, Supplier<List<T>> supplier) { + LOG.finest("TAMAYA Loading services: " + serviceType.getName()); + List<T> services = loadServices(serviceType, null); + if(services.isEmpty() && supplier!=null) { + services = supplier.get(); + try { + for (T t : services) { + this.osgiServiceLoader.getBundleContext().registerService(serviceType, t, new Hashtable<>()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return services; + } + + private <T> List<T> loadServices(Class<T> serviceType, Supplier<List<T>> supplier) { LOG.finest("TAMAYA Loading services: " + serviceType.getName()); List<ServiceReference<T>> refs = new ArrayList<>(); List<T> services = new ArrayList<>(refs.size()); @@ -113,7 +149,7 @@ public class OSGIServiceContext implements ServiceContext{ } } } catch (InvalidSyntaxException e) { - e.printStackTrace(); + LOG.log(Level.INFO,"No services found in OSGI: " + serviceType, e); } try{ for(T service:ServiceLoader.load(serviceType)){ @@ -121,7 +157,10 @@ public class OSGIServiceContext implements ServiceContext{ } return services; } catch (Exception e) { - e.printStackTrace(); + LOG.log(Level.INFO, "No services found in ServiceLoader: " + serviceType, e); + } + if(services.isEmpty() && supplier!=null){ + return supplier.get(); } return services; } @@ -180,4 +219,61 @@ public class OSGIServiceContext implements ServiceContext{ } return null; } + + @Override + public <T> T register(Class<T> serviceType, T instance, boolean force) { + Collection<ServiceReference<T>> refs; + try { + refs = this.osgiServiceLoader.getBundleContext().getServiceReferences(serviceType, null); + if(refs!=null && force){ + for(ServiceReference ref:refs) { + osgiServiceLoader.getBundleContext().ungetService(ref); + } + refs = null; + } + } catch (InvalidSyntaxException e) { + throw new IllegalStateException("Failed to access OSGI services", e); + } + if(refs!=null && !refs.isEmpty()){ + return (T)this.osgiServiceLoader.getBundleContext().getService(refs.iterator().next()); + } + this.osgiServiceLoader.getBundleContext().registerService( + serviceType, instance, new Hashtable<>() + ); + return instance; + } + + @Override + public <T> List<T> register(Class<T> serviceType, List<T> instances, boolean force) { + Collection<ServiceReference<T>> refs; + try { + refs = this.osgiServiceLoader.getBundleContext().getServiceReferences(serviceType, null); + if(refs!=null && force){ + for(ServiceReference ref:refs) { + osgiServiceLoader.getBundleContext().ungetService(ref); + } + refs = null; + } + } catch (InvalidSyntaxException e) { + throw new IllegalStateException("Failed to access OSGI services", e); + } + if(refs!=null && !refs.isEmpty()){ + List<T> result = new ArrayList<>(); + for(ServiceReference ref:refs) { + T item = (T) this.osgiServiceLoader.getBundleContext().getService(ref); + if (item != null) { + result.add(item); + } + } + return result; + }else{ + for(T instance:instances) { + this.osgiServiceLoader.getBundleContext().registerService( + serviceType, instance, new Hashtable<>() + ); + } + return instances; + } + } + } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java index b973d5f..dc7c0d4 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java @@ -68,7 +68,7 @@ public class OSGIServiceLoader implements BundleListener { @Override public void bundleChanged(BundleEvent bundleEvent) { - // Parse and create metadata when installed + // Parse and createObject metadata when installed if (bundleEvent.getType() == BundleEvent.STARTED) { Bundle bundle = bundleEvent.getBundle(); checkAndLoadBundle(bundle); @@ -243,7 +243,7 @@ public class OSGIServiceLoader implements BundleListener { return serviceClass.newInstance(); } catch (Exception ex) { ex.printStackTrace(); - throw new IllegalStateException("Failed to create service: " + serviceClass.getName(), ex); + throw new IllegalStateException("Failed to createObject service: " + serviceClass.getName(), ex); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java index 4ca5c2d..6717c9d 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java @@ -50,10 +50,10 @@ public class BigIntegerConverter implements PropertyConverter<BigInteger> { ctx.addSupportedFormats(getClass(), "[-]0X.. (hex)", "[-]0x... (hex)", "<bigint> -> new BigInteger(bigint)")); String trimmed = Objects.requireNonNull(value).trim(); if(trimmed.startsWith("0x") || trimmed.startsWith("0X")){ - LOG.finest("Parsing Hex value to BigInteger: " + value); + LOG.finest("Parsing Hex createValue to BigInteger: " + value); return new BigInteger(value.substring(2), 16); } else if(trimmed.startsWith("-0x") || trimmed.startsWith("-0X")){ - LOG.finest("Parsing Hex value to BigInteger: " + value); + LOG.finest("Parsing Hex createValue to BigInteger: " + value); return new BigInteger('-' + value.substring(3), 16); } try{ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java index ce1fed4..f692718 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java @@ -57,7 +57,7 @@ public class BooleanConverter implements PropertyConverter<Boolean> { case "off": return Boolean.FALSE; default: - LOG.finest("Unknown boolean value encountered: " + value); + LOG.finest("Unknown boolean createValue encountered: " + value); } return null; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java index 0e0e73c..c6aa6be 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java @@ -30,14 +30,14 @@ import java.util.logging.Logger; /** * Converter, converting from String to Byte, the supported format is one of the following: * <ul> - * <li>123 (byte value)</li> - * <li>0xFF (byte value)</li> - * <li>0XDF (byte value)</li> - * <li>0D1 (byte value)</li> - * <li>-123 (byte value)</li> - * <li>-0xFF (byte value)</li> - * <li>-0XDF (byte value)</li> - * <li>-0D1 (byte value)</li> + * <li>123 (byte createValue)</li> + * <li>0xFF (byte createValue)</li> + * <li>0XDF (byte createValue)</li> + * <li>0D1 (byte createValue)</li> + * <li>-123 (byte createValue)</li> + * <li>-0xFF (byte createValue)</li> + * <li>-0XDF (byte createValue)</li> + * <li>-0D1 (byte createValue)</li> * <li>MIN_VALUE (ignoring case)</li> * <li>MIN (ignoring case)</li> * <li>MAX_VALUE (ignoring case)</li> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java index 2011fab..65ad2ae 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java @@ -29,10 +29,10 @@ import java.util.logging.Logger; * Converter, converting from String to Character, the supported format is one of the following: * <ul> * <li>'a'</li> - * <li>123 (byte value)</li> - * <li>0xFF (byte value)</li> - * <li>0XDF (byte value)</li> - * <li>0D1 (byte value)</li> + * <li>123 (byte createValue)</li> + * <li>0xFF (byte createValue)</li> + * <li>0XDF (byte createValue)</li> + * <li>0D1 (byte createValue)</li> * </ul> */ @Component(service = PropertyConverter.class) http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java index 6da3e6b..a570685 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ConvertQuery.java @@ -30,7 +30,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Query to convert a String value. + * Query to convert a String createValue. * @param <T> the target type. */ final class ConvertQuery<T> implements ConfigQuery<T> { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java index 0294d3d..a85f9fd 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java @@ -32,7 +32,7 @@ import java.util.logging.Logger; * Converter, converting from String to Currency, the supported format is one of the following: * <ul> * <li>CHF (currency code)</li> - * <li>123 (numeric currency value > + * <li>123 (numeric currency createValue > * = 0)</li> * <li>DE (ISO 2-digit country)</li> * <li>de_DE, de_DE_123 (Locale)</li> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java index edf46a1..9b19078 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java @@ -28,7 +28,7 @@ import java.util.logging.Logger; /** * Converter, converting from String to Double, using the Java number syntax: - * (-)?[0-9]*\.[0-9]*. In case of error the value given also is tried being parsed as integral number using + * (-)?[0-9]*\.[0-9]*. In case of error the createValue given also is tried being parsed as integral number using * {@link LongConverter}. Additionally the following values are supported: * <ul> * <li>NaN (ignoring case)</li> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java index e64b9d6..ba2392a 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java @@ -28,7 +28,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Converter, converting from String to File, using new File(value). + * Converter, converting from String to File, using new File(createValue). */ @Component(service = PropertyConverter.class) public class FileConverter implements PropertyConverter<File> { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java index b38d64c..e47b497 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java @@ -28,7 +28,7 @@ import java.util.logging.Logger; /** * Converter, converting from String to Float, using the Java number syntax: - * (-)?[0-9]*\.[0-9]*. In case of error the value given also is tried being parsed as integral number using + * (-)?[0-9]*\.[0-9]*. In case of error the createValue given also is tried being parsed as integral number using * {@link LongConverter}. Additionally the following values are supported: * <ul> * <li>NaN (ignoring case)</li> @@ -82,7 +82,7 @@ public class FloatConverter implements PropertyConverter<Float> { if(val!=null) { return val.floatValue(); } - LOG.finest("Unparseable float value: " + trimmed); + LOG.finest("Unparseable float createValue: " + trimmed); return null; } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java index 93f5c0b..a128c97 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java @@ -29,14 +29,14 @@ import java.util.logging.Logger; /** * Converter, converting from String to Integer, the supported format is one of the following: * <ul> - * <li>123 (byte value)</li> - * <li>0xFF (byte value)</li> - * <li>0XDF (byte value)</li> - * <li>0D1 (byte value)</li> - * <li>-123 (byte value)</li> - * <li>-0xFF (byte value)</li> - * <li>-0XDF (byte value)</li> - * <li>-0D1 (byte value)</li> + * <li>123 (byte createValue)</li> + * <li>0xFF (byte createValue)</li> + * <li>0XDF (byte createValue)</li> + * <li>0D1 (byte createValue)</li> + * <li>-123 (byte createValue)</li> + * <li>-0xFF (byte createValue)</li> + * <li>-0XDF (byte createValue)</li> + * <li>-0D1 (byte createValue)</li> * <li>MIN_VALUE (ignoring case)</li> * <li>MIN (ignoring case)</li> * <li>MAX_VALUE (ignoring case)</li> @@ -68,7 +68,7 @@ public class IntegerConverter implements PropertyConverter<Integer>{ return Integer.decode(trimmed); } catch(Exception e){ - LOG.finest("Unparseable Integer value: " + trimmed); + LOG.finest("Unparseable Integer createValue: " + trimmed); return null; } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java index 3d42bfc..1bdad71 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java @@ -29,14 +29,14 @@ import java.util.logging.Logger; /** * Converter, converting from String to Long, the supported format is one of the following: * <ul> - * <li>123 (byte value)</li> - * <li>0xFF (byte value)</li> - * <li>0XDF (byte value)</li> - * <li>0D1 (byte value)</li> - * <li>-123 (byte value)</li> - * <li>-0xFF (byte value)</li> - * <li>-0XDF (byte value)</li> - * <li>-0D1 (byte value)</li> + * <li>123 (byte createValue)</li> + * <li>0xFF (byte createValue)</li> + * <li>0XDF (byte createValue)</li> + * <li>0D1 (byte createValue)</li> + * <li>-123 (byte createValue)</li> + * <li>-0xFF (byte createValue)</li> + * <li>-0XDF (byte createValue)</li> + * <li>-0D1 (byte createValue)</li> * <li>MIN_VALUE (ignoring case)</li> * <li>MIN (ignoring case)</li> * <li>MAX_VALUE (ignoring case)</li> @@ -66,7 +66,7 @@ public class LongConverter implements PropertyConverter<Long>{ return Long.decode(trimmed); } catch(Exception e){ - LOGGER.finest("Unable to parse Long value: " + value); + LOGGER.finest("Unable to parse Long createValue: " + value); return null; } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java index c6c8de1..82e4486 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java @@ -41,7 +41,7 @@ import java.util.logging.Logger; public class NumberConverter implements PropertyConverter<Number>{ /** the logger. */ private static final Logger LOGGER = Logger.getLogger(NumberConverter.class.getName()); - /** Converter used for trying to parse as an integral value. */ + /** Converter used for trying to parse as an integral createValue. */ private final LongConverter longConverter = new LongConverter(); @Override http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java index 422d9d5..0be4bef 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OptionalConverter.java @@ -53,7 +53,7 @@ public class OptionalConverter implements PropertyConverter<Optional> { ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(pt.getActualTypeArguments()[0])); return Optional.ofNullable(context.getConfiguration().query(converter)); }catch(Exception e){ - throw new ConfigException("Error evaluating config value.", e); + throw new ConfigException("Error evaluating config createValue.", e); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java index 0ee36c6..f05fe0d 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java @@ -29,7 +29,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Converter, converting from String to Path, using FileSystem.getPath(value). + * Converter, converting from String to Path, using FileSystem.getPath(createValue). */ @Component(service = PropertyConverter.class) public class PathConverter implements PropertyConverter<Path> { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java index 03296b3..d111c31 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java @@ -29,14 +29,14 @@ import java.util.logging.Logger; /** * Converter, converting from String to Short, the supported format is one of the following: * <ul> - * <li>123 (byte value)</li> - * <li>0xFF (byte value)</li> - * <li>0XDF (byte value)</li> - * <li>0D1 (byte value)</li> - * <li>-123 (byte value)</li> - * <li>-0xFF (byte value)</li> - * <li>-0XDF (byte value)</li> - * <li>-0D1 (byte value)</li> + * <li>123 (byte createValue)</li> + * <li>0xFF (byte createValue)</li> + * <li>0XDF (byte createValue)</li> + * <li>0D1 (byte createValue)</li> + * <li>-123 (byte createValue)</li> + * <li>-0xFF (byte createValue)</li> + * <li>-0XDF (byte createValue)</li> + * <li>-0D1 (byte createValue)</li> * <li>MIN_VALUE (ignoring case)</li> * <li>MIN (ignoring case)</li> * <li>MAX_VALUE (ignoring case)</li> http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java index 873499d..268eb63 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/SupplierConverter.java @@ -54,11 +54,11 @@ public class SupplierConverter implements PropertyConverter<Supplier> { ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(pt.getActualTypeArguments()[0])); Object o = context.getConfiguration().query(converter); if(o==null){ - throw new ConfigException("No such value: " + context.getKey()); + throw new ConfigException("No such createValue: " + context.getKey()); } return o; }catch(Exception e){ - throw new ConfigException("Error evaluating config value.", e); + throw new ConfigException("Error evaluating config createValue.", e); } }; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java index d3a77fa..b3ce5b4 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java @@ -28,7 +28,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Converter, converting from String to URI, using new URI(value). + * Converter, converting from String to URI, using new URI(createValue). */ @Component(service = PropertyConverter.class) public class URIConverter implements PropertyConverter<URI> { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java index 680188b..1396b39 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java @@ -28,7 +28,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Converter, converting from String to URL, using new URL(value). + * Converter, converting from String to URL, using new URL(createValue). */ @Component(service = PropertyConverter.class) public class URLConverter implements PropertyConverter<URL> { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java b/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java index be1b45a..da5a557 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java +++ b/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java @@ -54,7 +54,7 @@ public class TestPropertySource implements PropertySource { @Override public PropertyValue get(String key) { - return PropertyValue.create(key, key + "Value") + return PropertyValue.createValue(key, key + "Value") .setMeta("source", getName()) .setMeta("ordinal", String.valueOf(getOrdinal())) .setMeta("createdAt", String.valueOf(new Date())); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/C.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/C.java b/code/core/src/test/java/org/apache/tamaya/core/internal/C.java index 4b4609b..f11c447 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/C.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/C.java @@ -38,8 +38,8 @@ public class C extends B implements Readable{ } /** - * Returns the input value, setCurrent on creation. Used for test assertion. - * @return the in value. + * Returns the input createValue, setCurrent on creation. Used for test assertion. + * @return the in createValue. */ public String getInValue() { return inValue; http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/OSGIServiceContextTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/OSGIServiceContextTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/OSGIServiceContextTest.java index 3ffbff8..77d009b 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/OSGIServiceContextTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/OSGIServiceContextTest.java @@ -57,7 +57,7 @@ public class OSGIServiceContextTest { } /** - * Test of create method, of class OSGIServiceContext. + * Test of createObject method, of class OSGIServiceContext. */ @Test public void testCreateThenGet() { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java index 31e0bc5..3269c1c 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify; public class BigDecimalConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -48,7 +48,7 @@ public class BigDecimalConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -71,7 +71,7 @@ public class BigDecimalConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -84,7 +84,7 @@ public class BigDecimalConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws Exception @@ -99,7 +99,7 @@ public class BigDecimalConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws Exception http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigIntegerConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigIntegerConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigIntegerConverterTest.java index 845a735..bf7a2d9 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigIntegerConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BigIntegerConverterTest.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.mock; public class BigIntegerConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -48,7 +48,7 @@ public class BigIntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -72,7 +72,7 @@ public class BigIntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -101,7 +101,7 @@ public class BigIntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * * @throws Exception @@ -114,7 +114,7 @@ public class BigIntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws Exception http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java index 2b33063..dc5b40a 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java @@ -32,7 +32,7 @@ import org.junit.Test; public class BooleanConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws Exception @@ -73,7 +73,7 @@ public class BooleanConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws Exception @@ -118,7 +118,7 @@ public class BooleanConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws ConfigException http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java index 610d7d2..a730e07 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.*; public class ByteConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -56,7 +56,7 @@ public class ByteConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -69,7 +69,7 @@ public class ByteConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -81,7 +81,7 @@ public class ByteConverterTest { assertThat(valueRead.byteValue()).isEqualTo(Byte.MAX_VALUE); } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws ConfigException http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java index ecca42a..ef3f020 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java @@ -110,7 +110,7 @@ public class CharConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * * @throws ConfigException http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java index 9b7cbd8..0160360 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java @@ -32,7 +32,7 @@ import org.junit.Test; public class DoubleConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -45,7 +45,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -58,7 +58,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -71,7 +71,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -84,7 +84,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -97,7 +97,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -109,7 +109,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -122,7 +122,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -135,7 +135,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -148,7 +148,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -161,7 +161,7 @@ public class DoubleConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java index 11fd864..f504088 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java @@ -32,7 +32,7 @@ import org.junit.Test; public class FloatConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -45,7 +45,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -58,7 +58,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -71,7 +71,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -84,7 +84,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -97,7 +97,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -110,7 +110,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -123,7 +123,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -136,7 +136,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -149,7 +149,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -162,7 +162,7 @@ public class FloatConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java index d6b5081..8060185 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.*; public class IntegerConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -45,7 +45,7 @@ public class IntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -58,7 +58,7 @@ public class IntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -74,7 +74,7 @@ public class IntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -86,7 +86,7 @@ public class IntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -99,7 +99,7 @@ public class IntegerConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java index bfab1c9..6f7b88c 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.*; public class LongConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -45,7 +45,7 @@ public class LongConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -58,7 +58,7 @@ public class LongConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -74,7 +74,7 @@ public class LongConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -86,7 +86,7 @@ public class LongConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -99,7 +99,7 @@ public class LongConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java index 41427ab..f57fd81 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.*; public class NumberConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -48,7 +48,7 @@ public class NumberConverterTest { /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -64,7 +64,7 @@ public class NumberConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ @@ -76,7 +76,7 @@ public class NumberConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -90,7 +90,7 @@ public class NumberConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -105,7 +105,7 @@ public class NumberConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -118,7 +118,7 @@ public class NumberConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ @@ -131,7 +131,7 @@ public class NumberConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. * @throws Exception */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java index fc54aa8..5dec2cf 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java @@ -74,7 +74,7 @@ public class ShortConverterTest { } /** - * Test conversion. The value are provided by + * Test conversion. The createValue are provided by * {@link ConverterTestsPropertySource}. * @throws Exception */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java index aea67f6..b948601 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java +++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java @@ -25,7 +25,7 @@ import javax.annotation.Priority; import java.util.concurrent.atomic.AtomicInteger; /** - * Simple PropertyFilter that filters exact one value, registered using ServiceLoader. + * Simple PropertyFilter that filters exact one createValue, registered using ServiceLoader. */ @Priority(100) public class TestPropertyFilter implements PropertyFilter{ @@ -35,7 +35,8 @@ public class TestPropertyFilter implements PropertyFilter{ @Override public PropertyValue filterProperty(PropertyValue valueToBeFiltered) { if("name4".equals(valueToBeFiltered.getKey())){ - return valueToBeFiltered.mutable().setValue(valueToBeFiltered.getValue() + "(filtered"+counter.incrementAndGet()+")"); + return valueToBeFiltered.mutable() + .setValue(valueToBeFiltered.getValue() + "(filtered"+counter.incrementAndGet()+")"); } return valueToBeFiltered; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java index 223e197..1c5365c 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java +++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java @@ -25,7 +25,7 @@ import org.apache.tamaya.spi.PropertyValue; import javax.annotation.Priority; /** - * Simple PropertyFilter that filters exact one value, registered using ServiceLoader. + * Simple PropertyFilter that filters exact one createValue, registered using ServiceLoader. */ @Priority(200) public class TestRemovingPropertyFilter implements PropertyFilter{ @@ -35,8 +35,8 @@ public class TestRemovingPropertyFilter implements PropertyFilter{ return null; } else if("name3".equals(valueToBeFiltered.getKey())){ - return valueToBeFiltered.setValue( - "Mapped to name: " + Configuration.current().get("name")); + return valueToBeFiltered + .setValue("Mapped to name: " + Configuration.current().get("name")); } return valueToBeFiltered; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java index 72c8972..f63f110 100644 --- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java +++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java @@ -28,16 +28,16 @@ import java.util.logging.Logger; /** - * Component SPI which encapsulates the evaluation of a single or full <b>raw</b> value + * Component SPI which encapsulates the evaluation of a single or full <b>raw</b> createValue * for a {@link ConfigurationContext}. */ public interface ConfigValueEvaluator { /** - * Evaluates single value using a {@link ConfigurationContext}. + * Evaluates single createValue using a {@link ConfigurationContext}. * @param key the config key, not null. * @param context the context, not null. - * @return the value, or null. + * @return the createValue, or null. */ default PropertyValue evaluteRawValue(String key, ConfigurationContext context){ List<PropertyValue> values = evaluteAllValues(key, context); @@ -51,7 +51,7 @@ public interface ConfigValueEvaluator { * Evaluates all values using a {@link ConfigurationContext}. * @param key the config key, not null. * @param context the context, not null. - * @return the value, or null. + * @return the createValue, or null. */ default List<PropertyValue> evaluteAllValues(String key, ConfigurationContext context){ List<PropertyValue> result = new ArrayList<>(); @@ -74,7 +74,7 @@ public interface ConfigValueEvaluator { /** * Evaluates all property values from a {@link ConfigurationContext}. * @param context the context, not null. - * @return the value, or null. + * @return the createValue, or null. */ default Map<String, PropertyValue> evaluateRawValues(ConfigurationContext context){ Map<String, PropertyValue> result = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java index 3767efd..9eb1847 100644 --- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java +++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java @@ -75,9 +75,9 @@ public class DefaultConfiguration implements Configuration { } /** - * Get a given value, filtered with the context's filters as needed. + * Get a given createValue, filtered with the context's filters as needed. * @param key the property's key, not null. - * @return the filtered value, or null. + * @return the filtered createValue, or null. */ @Override public String get(String key) { @@ -95,9 +95,9 @@ public class DefaultConfiguration implements Configuration { } /** - * Get a given value, filtered with the context's filters as needed. + * Get a given createValue, filtered with the context's filters as needed. * @param key the property's key, not null. - * @return the filtered value, or null. + * @return the filtered createValue, or null. */ public List<PropertyValue> getValues(String key) { Objects.requireNonNull(key, "Key must not be null."); @@ -115,9 +115,9 @@ public class DefaultConfiguration implements Configuration { /** - * Evaluates the raw value using the context's {@link PropertyValueCombinationPolicy}. + * Evaluates the raw createValue using the context's {@link PropertyValueCombinationPolicy}. * @param key the key, not null. - * @return the value, before filtering is applied. + * @return the createValue, before filtering is applied. */ protected PropertyValue evaluteRawValue(String key) { List<PropertySource> propertySources = configurationContext.getPropertySources(); @@ -177,15 +177,15 @@ public class DefaultConfiguration implements Configuration { /** - * Accesses the current String value for the given key and tries to convert it + * Accesses the current String createValue for the given key and tries to convert it * using the {@link PropertyConverter} instances provided by the current * {@link ConfigurationContext}. * * @param key the property's absolute, or relative path, e.g. {@code * a/b/c/d.myProperty}, never {@code null}. * @param type The target type required, not {@code null}. - * @param <T> the value type - * @return the converted value, never {@code null}. + * @param <T> the createValue type + * @return the converted createValue, never {@code null}. */ @Override public <T> T get(String key, Class<T> type) { @@ -193,15 +193,15 @@ public class DefaultConfiguration implements Configuration { } /** - * Accesses the current String value for the given key and tries to convert it + * Accesses the current String createValue for the given key and tries to convert it * using the {@link PropertyConverter} instances provided by the current * {@link ConfigurationContext}. * * @param key the property's absolute, or relative path, e.g. {@code * a/b/c/d.myProperty}. * @param type The target type required, not {@code null}. - * @param <T> the value type - * @return the converted value, never {@code null}. + * @param <T> the createValue type + * @return the converted createValue, never {@code null}. */ @Override public <T> T get(String key, TypeLiteral<T> type) { @@ -228,10 +228,10 @@ public class DefaultConfiguration implements Configuration { return t; } } catch (Exception e) { - LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value, e); + LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " + value, e); } } - // if the target type is a String, we can return the value, no conversion required. + // if the target type is a String, we can return the createValue, no conversion required. if (type.equals(TypeLiteral.of(String.class))) { return (T) value; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java index 48a958d..6a7439c 100644 --- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java +++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilder.java @@ -44,6 +44,7 @@ public class DefaultConfigurationBuilder implements ConfigurationBuilder { protected List<PropertySource> propertySources = new ArrayList<>(); protected PropertyValueCombinationPolicy combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY; protected Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> propertyConverters = new HashMap<>(); + protected MetadataProvider metaDataProvider = serviceContext.create(MetadataProvider.class, DefaultMetaDataProvider::new); /** * Flag if the config has already been built. @@ -86,6 +87,11 @@ public class DefaultConfigurationBuilder implements ConfigurationBuilder { } @Override + public ClassLoader getClassLoader() { + return serviceContext.getClassLoader(); + } + + @Override public ConfigurationBuilder setServiceContext(ServiceContext serviceContext) { checkBuilderState(); this.serviceContext = Objects.requireNonNull(serviceContext); @@ -118,6 +124,18 @@ public class DefaultConfigurationBuilder implements ConfigurationBuilder { return this; } + @Override + public ConfigurationBuilder setMeta(String key, String value){ + this.metaDataProvider.setMeta(key, value); + return this; + } + + @Override + public ConfigurationBuilder setMeta(Map<String, String> metaData){ + this.metaDataProvider.setMeta(metaData); + return this; + } + /** * Adds the given sources as property sources. * @@ -314,7 +332,8 @@ public class DefaultConfigurationBuilder implements ConfigurationBuilder { this.combinationPolicy, this.propertyFilters, this.propertySources, - this.propertyConverters)); + this.propertyConverters, + this.metaDataProvider)); this.built = true; return cfg; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java index 878d64e..8a5362d 100644 --- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java +++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java @@ -33,6 +33,7 @@ public class DefaultConfigurationContext implements ConfigurationContext { /** The logger used. */ private final static Logger LOG = Logger.getLogger(DefaultConfigurationContext.class.getName()); + private final MetadataProvider metaDataProvider; /** * Subcomponent handling {@link PropertyConverter} instances. @@ -40,12 +41,12 @@ public class DefaultConfigurationContext implements ConfigurationContext { private PropertyConverterManager propertyConverterManager; /** - * The current unmodifiable list of loaded {@link PropertySource} instances. + * The current unmodifiable createList of loaded {@link PropertySource} instances. */ private List<PropertySource> immutablePropertySources; /** - * The current unmodifiable list of loaded {@link PropertyFilter} instances. + * The current unmodifiable createList of loaded {@link PropertyFilter} instances. */ private List<PropertyFilter> immutablePropertyFilters; @@ -58,6 +59,7 @@ public class DefaultConfigurationContext implements ConfigurationContext { /** The corresponding classLoader for this instance. */ private ServiceContext serviceContext; + /** * Lock for internal synchronization. */ @@ -66,6 +68,8 @@ public class DefaultConfigurationContext implements ConfigurationContext { @SuppressWarnings("unchecked") protected DefaultConfigurationContext(DefaultConfigurationContextBuilder builder) { this.serviceContext = builder.getServiceContext(); + this.metaDataProvider = Objects.requireNonNull(builder.getMetaDataProvider()); + this.metaDataProvider.init(this); propertyConverterManager = new PropertyConverterManager(serviceContext); List<PropertySource> propertySources = new ArrayList<>(); // first we load all PropertySources which got registered via java.util.ServiceLoader @@ -98,11 +102,14 @@ public class DefaultConfigurationContext implements ConfigurationContext { public DefaultConfigurationContext(ServiceContext serviceContext, PropertyValueCombinationPolicy combinationPolicy, List<PropertyFilter> propertyFilters, List<PropertySource> propertySources, - Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> propertyConverters) { + Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> propertyConverters, + MetadataProvider metaDataProvider) { this.propertyValueCombinationPolicy = Objects.requireNonNull(combinationPolicy); this.serviceContext = Objects.requireNonNull(serviceContext); this.immutablePropertyFilters = Collections.unmodifiableList(new ArrayList<>(propertyFilters)); this.immutablePropertySources = Collections.unmodifiableList(new ArrayList<>(propertySources)); + this.metaDataProvider = Objects.requireNonNull(metaDataProvider); + this.metaDataProvider.init(this); propertyConverterManager = new PropertyConverterManager(serviceContext); for(Map.Entry<TypeLiteral<?>, Collection<PropertyConverter<?>>> en:propertyConverters.entrySet()) { for (@SuppressWarnings("rawtypes") PropertyConverter converter : en.getValue()) { @@ -113,6 +120,11 @@ public class DefaultConfigurationContext implements ConfigurationContext { @Override + public Map<String,String> getMetadata() { + return metaDataProvider.getMetaData(); + } + + @Override public ServiceContext getServiceContext() { return serviceContext; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java index d9fb558..f7b4fb1 100644 --- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java +++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilder.java @@ -47,6 +47,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB protected ServiceContext serviceContext = ServiceContextManager.getServiceContext(); protected List<PropertyFilter> propertyFilters = new ArrayList<>(); protected List<PropertySource> propertySources = new ArrayList<>(); + protected MetadataProvider metaDataProvider = serviceContext.create(MetadataProvider.class, () -> new DefaultMetaDataProvider()); protected PropertyValueCombinationPolicy combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY; protected Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> propertyConverters = new HashMap<>(); @@ -124,6 +125,18 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB } @Override + public ConfigurationContextBuilder addMetaData(Map<String, String> metaData) { + this.metaDataProvider.setMeta(metaData); + return this; + } + + @Override + public ConfigurationContextBuilder addMetaData(String key, String value) { + this.metaDataProvider.setMeta(key, value); + return this; + } + + @Override public final ConfigurationContextBuilder addPropertySources(PropertySource... sources){ return addPropertySources(Arrays.asList(sources)); } @@ -458,4 +471,8 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB public Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter() { return Collections.unmodifiableMap(this.propertyConverters); } + + public MetadataProvider getMetaDataProvider() { + return metaDataProvider; + } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java ---------------------------------------------------------------------- diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java new file mode 100644 index 0000000..cc43360 --- /dev/null +++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.spisupport; + +import org.apache.tamaya.spi.ConfigurationContext; +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertyValue; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Default metadata provider implementation, which searches for all kind of entries + * starting with {@code [META]}. All matching key/values are added to the + * meta data map, hereby reoving the key prefix. + */ +public class DefaultMetaDataProvider implements MetadataProvider { + + private static final String META_PREFIX = "[META]"; + private ConfigurationContext context; + private Map<String, String> additionalProperties = new ConcurrentHashMap<>(); + private AtomicLong lastHash = new AtomicLong(); + private Map<String, String> propertyCache = new HashMap<>(); + + @Override + public MetadataProvider init(ConfigurationContext context) { + this.context = Objects.requireNonNull(context); + return this; + } + + @Override + public Map<String, String> getMetaData() { + long configHash = Objects.hash(context.getPropertySources().toArray()); + if(configHash!=lastHash.get()){ + lastHash.set(configHash); + propertyCache = loadMetaProperties(); + } + return propertyCache; + } + + private Map<String, String> loadMetaProperties() { + Map<String, String> result = new HashMap<>(); + for(PropertySource ps:context.getPropertySources()){ + ps.getProperties().values().forEach(v -> { + loadMetaData(v, result); + }); + } + result.putAll(additionalProperties); + return Collections.unmodifiableMap(result); + } + + /** + * Iterates all values and it's children and adds all meta-entries found. + * @param value the starting value. + * @param result the result map to add/override values found. + */ + private void loadMetaData(PropertyValue value, Map<String, String> result) { + String key = value.getQualifiedKey(); + if(key.toUpperCase(Locale.ENGLISH).startsWith(META_PREFIX)){ + if(value.getValue()!=null){ + result.put(key.substring(META_PREFIX.length()), value.getValue()); + } + value.iterator().forEachRemaining(v -> loadMetaData(v, result)); + } + } + + @Override + public MetadataProvider setMeta(String key, String value) { + additionalProperties.put(key, value); + return this; + } + + @Override + public MetadataProvider setMeta(Map<String, String> metaData) { + additionalProperties.putAll(metaData); + return this; + } + + @Override + public MetadataProvider reset() { + additionalProperties.clear(); + return this; + } + + @Override + public String toString() { + return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]") + .add("additionalProperties = " + additionalProperties) + .add("context = " + context) + .toString(); + } +}
