You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/01/18 01:09:35 UTC

[1/5] incubator-tamaya git commit: TAMAYA-58: Added getTargetType to PropertyConverter. Added implementations of converters for base types.

Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 8f9c11ddc -> bfbaefa43


TAMAYA-58: Added getTargetType to PropertyConverter. Added implementations of converters for base types.


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

Branch: refs/heads/master
Commit: 578c873d8bce0f175575d55b5a775e60f63c741c
Parents: 8f9c11d
Author: anatole <an...@apache.org>
Authored: Sun Jan 18 01:01:43 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 18 01:09:24 2015 +0100

----------------------------------------------------------------------
 .../apache/tamaya/spi/PropertyConverter.java    |  13 +-
 .../core/internal/PropertyConverterManager.java |  89 ++++++-------
 .../converters/BigDecimalConverter.java         |  41 ++++++
 .../converters/BigIntegerConverter.java         |  42 ++++++
 .../internal/converters/BooleanConverter.java   |  56 ++++++++
 .../core/internal/converters/ByteConverter.java |  39 ++++++
 .../core/internal/converters/CharConverter.java |  42 ++++++
 .../internal/converters/CurrencyConverter.java  |  40 ++++++
 .../internal/converters/DoubleConverter.java    |  40 ++++++
 .../core/internal/converters/EnumConverter.java |  65 +++++++++
 .../internal/converters/FloatConverter.java     |  40 ++++++
 .../internal/converters/IntegerConverter.java   |  39 ++++++
 .../internal/converters/LocalDateConverter.java |  40 ++++++
 .../converters/LocalDateTimeConverter.java      |  40 ++++++
 .../internal/converters/LocalTimeConverter.java |  40 ++++++
 .../core/internal/converters/LongConverter.java |  39 ++++++
 .../internal/converters/NumberConverter.java    |  41 ++++++
 .../internal/converters/ShortConverter.java     |  39 ++++++
 .../internal/converters/ZoneIdConverter.java    |  40 ++++++
 .../converters/BooleanConverterTest.java        | 131 +++++++++++++++++++
 .../internal/converters/ByteConverterTest.java  |  56 ++++++++
 .../ConverterTestsPropertySource.java           | 112 ++++++++++++++++
 .../org.apache.tamaya.spi.PropertySource        |   3 +-
 23 files changed, 1069 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
index bb3757d..7c3ee83 100644
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
+++ b/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
@@ -26,12 +26,12 @@ package org.apache.tamaya.spi;
  */
 public interface PropertyConverter<T>{
 
-//    /**
-//     * Access the target type, this converter is producing. This is necessary to determine which converters are
-//     * to be used for converting a possible value.
-//     * @return the target type returned by a converter instance, never null.
-//     */
-//    Class<T> getTargetType();
+    /**
+     * Access the target type, this converter is producing. This is necessary to determine which converters are
+     * to be used for converting a possible value.
+     * @return the target type returned by a converter instance, never null.
+     */
+    Class<T> getTargetType();
 
     /**
      * Convert the given configuration keys from it's String representation into the required target type.
@@ -45,4 +45,5 @@ public interface PropertyConverter<T>{
     //X This could be useful if e.g. no converter in the chain felt responsible
     //X because a wrongly formatted configuration string had been used.
     //X This could probably also be handled via an additional Annotation on the converter.
+    //X Collection<String> getSupportedFormats();
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
index f755d0a..58aad71 100644
--- a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
@@ -20,15 +20,8 @@ package org.apache.tamaya.core.internal;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Currency;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -39,7 +32,9 @@ import java.util.concurrent.locks.StampedLock;
 import java.util.logging.Logger;
 
 import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.core.internal.converters.EnumConverter;
 import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.spi.ServiceContext;
 
 /**
  * Manager that deals with {@link org.apache.tamaya.spi.PropertyConverter} instances.
@@ -57,43 +52,16 @@ public class PropertyConverterManager {
      * Constructor.
      */
     public PropertyConverterManager() {
-        initDefaultConverters();
+        initConverters();
     }
 
-    private static final PropertyConverter<Character> CHAR_CONVERTER =
-            (s) -> Objects.requireNonNull(s,CHAR_NULL_ERROR).charAt(0);
-
     /**
      * Registers the default converters provided out of the box.
      */
-    protected void initDefaultConverters() {
-        // Add default converters
-        register(char.class, CHAR_CONVERTER);
-        register(byte.class, Byte::parseByte);
-        register(short.class, Short::parseShort);
-        register(int.class, Integer::parseInt);
-        register(long.class, Long::parseLong);
-        register(boolean.class, Boolean::parseBoolean);
-        register(float.class, Float::parseFloat); //X TODO not good enough as this is Locale dependent!
-        register(double.class, Double::parseDouble); //X TODO not good enough as this is Locale dependent!
-
-        register(Character.class, CHAR_CONVERTER);
-        register(Byte.class, Byte::valueOf);
-        register(Short.class, Short::valueOf);
-        register(Integer.class, Integer::valueOf);
-        register(Long.class, Long::valueOf);
-        register(Boolean.class, Boolean::valueOf);
-        register(Float.class, Float::valueOf); //X TODO not good enough as this is Locale dependent!
-        register(Double.class, Double::valueOf); //X TODO not good enough as this is Locale dependent!
-        register(BigDecimal.class, BigDecimal::new); //X TODO not good enough as this is Locale dependent!
-        register(BigInteger.class, BigInteger::new); //X TODO not good enough as this is Locale dependent!
-
-        register(Currency.class, Currency::getInstance);
-
-        register(LocalDate.class, LocalDate::parse);
-        register(LocalTime.class, LocalTime::parse);
-        register(LocalDateTime.class, LocalDateTime::parse);
-        register(ZoneId.class, ZoneId::of);
+    protected void initConverters() {
+        for(PropertyConverter conv: ServiceContext.getInstance().getServices(PropertyConverter.class)){
+            register(conv.getTargetType(), conv);
+        }
     }
 
     /**
@@ -194,27 +162,46 @@ public class PropertyConverterManager {
      * @return a new converter, or null.
      */
     protected <T> PropertyConverter<T> createDefaultPropertyConverter(Class<T> targetType) {
+        if(Enum.class.isAssignableFrom(targetType)){
+            return new EnumConverter<T>(targetType);
+        }
         PropertyConverter<T> converter = null;
         Method factoryMethod = getFactoryMethod(targetType, "of", "valueOf", "instanceOf", "getInstance", "from", "fromString", "parse");
         if (factoryMethod != null) {
-            converter = (s) -> {
-                try {
-                    factoryMethod.setAccessible(true);
-                    return targetType.cast(factoryMethod.invoke(s));
-                } catch (Exception e) {
-                    throw new ConfigException("Failed to decode '" + s + "'", e);
+            converter = new PropertyConverter<T>() {
+                @Override
+                public Class<T> getTargetType() {
+                    return targetType;
+                }
+
+                @Override
+                public T convert(String value) {
+                    try {
+                        factoryMethod.setAccessible(true);
+                        return targetType.cast(factoryMethod.invoke(value));
+                    } catch (Exception e) {
+                        throw new ConfigException("Failed to decode '" + value + "'", e);
+                    }
                 }
             };
         }
         if (converter == null) {
             try {
                 Constructor<T> constr = targetType.getDeclaredConstructor(String.class);
-                converter = (s) -> {
-                    try {
-                        constr.setAccessible(true);
-                        return constr.newInstance(s);
-                    } catch (Exception e) {
-                        throw new ConfigException("Failed to decode '" + s + "'", e);
+                converter = new PropertyConverter<T>() {
+                    @Override
+                    public Class<T> getTargetType() {
+                        return targetType;
+                    }
+
+                    @Override
+                    public T convert(String value) {
+                        try {
+                            constr.setAccessible(true);
+                            return constr.newInstance(value);
+                        } catch (Exception e) {
+                            throw new ConfigException("Failed to decode '" + value + "'", e);
+                        }
                     }
                 };
             } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
new file mode 100644
index 0000000..ab4387b
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to BigDecimal.
+ * //X TODO not good enough as this is Locale dependent!
+ */
+public class BigDecimalConverter implements PropertyConverter<BigDecimal>{
+    @Override
+    public Class<BigDecimal> getTargetType() {
+        return BigDecimal.class;
+    }
+
+    @Override
+    public BigDecimal convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return new BigDecimal(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
new file mode 100644
index 0000000..4fc9c01
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.math.BigInteger;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to BigInteger.
+ * //X TODO not good enough as this is Locale dependent!
+ */
+public class BigIntegerConverter implements PropertyConverter<BigInteger>{
+    @Override
+    public Class<BigInteger> getTargetType() {
+        return BigInteger.class;
+    }
+
+    @Override
+    public BigInteger convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return new BigInteger(trimmed);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
new file mode 100644
index 0000000..47e53ea
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.logging.Logger;
+
+/**
+ * Converter, converting from String to Short.
+ */
+public class BooleanConverter implements PropertyConverter<Boolean> {
+
+    private Logger LOG = Logger.getLogger(getClass().getName());
+
+    @Override
+    public Class<Boolean> getTargetType() {
+        return Boolean.class;
+    }
+
+    @Override
+    public Boolean convert(String value) {
+        String ignoreCaseValue = value.toLowerCase();
+        switch(ignoreCaseValue) {
+            case "yes":
+            case "y":
+            case "true":
+            case "t":
+                return Boolean.TRUE;
+            case "no":
+            case "n":
+            case "false":
+            case "f":
+                return Boolean.FALSE;
+            default:
+                LOG.warning("Unknown boolean value encountered: " + value);
+                return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
new file mode 100644
index 0000000..64de0f5
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Byte.
+ */
+public class ByteConverter implements PropertyConverter<Byte>{
+    @Override
+    public Class<Byte> getTargetType() {
+        return Byte.class;
+    }
+
+    @Override
+    public Byte convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return Byte.decode(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
new file mode 100644
index 0000000..667ede3
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Character.
+ */
+public class CharConverter implements PropertyConverter<Character>{
+    @Override
+    public Class<Character> getTargetType() {
+        return Character.class;
+    }
+
+    @Override
+    public Character convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        if(trimmed.length()!=1){
+            return null;
+        }
+        return Character.valueOf(value.charAt(0));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
new file mode 100644
index 0000000..6cd5c67
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Currency;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Currency.
+ */
+public class CurrencyConverter implements PropertyConverter<Currency>{
+    @Override
+    public Class<Currency> getTargetType() {
+        return Currency.class;
+    }
+
+    @Override
+    public Currency convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return Currency.getInstance(trimmed.toUpperCase());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
new file mode 100644
index 0000000..91c6ac8
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Double.
+ */
+public class DoubleConverter implements PropertyConverter<Double>{
+    @Override
+    public Class<Double> getTargetType() {
+        return Double.class;
+    }
+
+    @Override
+    public Double convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        //X TODO not good enough as this is Locale dependent!
+        return Double.valueOf(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
new file mode 100644
index 0000000..0440ef2
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.lang.reflect.Method;
+import java.util.Objects;
+import java.util.logging.Logger;
+
+/**
+ * Converter, converting from String to tge given enum type.
+ */
+public class EnumConverter<T> implements PropertyConverter<T> {
+    private Logger LOG = Logger.getLogger(EnumConverter.class.getName());
+    private Class<T> enumType;
+    private Method factory;
+
+    public EnumConverter(Class<T> enumType) {
+        if (!Enum.class.isAssignableFrom(enumType)) {
+            throw new IllegalArgumentException("Not an Enum: " + enumType.getName());
+        }
+        this.enumType = Objects.requireNonNull(enumType);
+        try {
+            this.factory = enumType.getMethod("valueOf", String.class);
+        } catch (NoSuchMethodException e) {
+            throw new ConfigException("Uncovertible enum type without valueOf method found, please provide a custom " +
+                    "PropertyConverter for: " + enumType.getName());
+        }
+    }
+
+    @Override
+    public Class<T> getTargetType() {
+        return enumType;
+    }
+
+    @Override
+    public T convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        try {
+            Method m = enumType.getMethod("valueOf", String.class);
+            return (T) factory.invoke(null, value);
+        } catch (Exception e) {
+            throw new ConfigException("Invalid enum value '" + value + "' for " + enumType.getName());
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
new file mode 100644
index 0000000..e5341b8
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Float.
+ */
+public class FloatConverter implements PropertyConverter<Float>{
+    @Override
+    public Class<Float> getTargetType() {
+        return Float.class;
+    }
+
+    @Override
+    public Float convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        //X TODO not good enough as this is Locale dependent!
+        return Float.valueOf(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
new file mode 100644
index 0000000..772baad
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Integer.
+ */
+public class IntegerConverter implements PropertyConverter<Integer>{
+    @Override
+    public Class<Integer> getTargetType() {
+        return Integer.class;
+    }
+
+    @Override
+    public Integer convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return Integer.decode(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java
new file mode 100644
index 0000000..3b57768
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.time.LocalDate;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to LocalDate.
+ */
+public class LocalDateConverter implements PropertyConverter<LocalDate>{
+    @Override
+    public Class<LocalDate> getTargetType() {
+        return LocalDate.class;
+    }
+
+    @Override
+    public LocalDate convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return LocalDate.parse(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java
new file mode 100644
index 0000000..e05cbb8
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.time.LocalDateTime;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to LocalDateTime.
+ */
+public class LocalDateTimeConverter implements PropertyConverter<LocalDateTime>{
+    @Override
+    public Class<LocalDateTime> getTargetType() {
+        return LocalDateTime.class;
+    }
+
+    @Override
+    public LocalDateTime convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return LocalDateTime.parse(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java
new file mode 100644
index 0000000..b2080ce
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.time.LocalTime;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to LocalTime.
+ */
+public class LocalTimeConverter implements PropertyConverter<LocalTime>{
+    @Override
+    public Class<LocalTime> getTargetType() {
+        return LocalTime.class;
+    }
+
+    @Override
+    public LocalTime convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return LocalTime.parse(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
new file mode 100644
index 0000000..dbfe332
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Long.
+ */
+public class LongConverter implements PropertyConverter<Long>{
+    @Override
+    public Class<Long> getTargetType() {
+        return Long.class;
+    }
+
+    @Override
+    public Long convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return Long.decode(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
new file mode 100644
index 0000000..543988b
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to BigDecimal.
+ * //X TODO not good enough as this is Locale dependent!
+ */
+public class NumberConverter implements PropertyConverter<Number>{
+    @Override
+    public Class<Number> getTargetType() {
+        return Number.class;
+    }
+
+    @Override
+    public Number convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return new BigDecimal(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
new file mode 100644
index 0000000..5e12702
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to Short.
+ */
+public class ShortConverter implements PropertyConverter<Short>{
+    @Override
+    public Class<Short> getTargetType() {
+        return Short.class;
+    }
+
+    @Override
+    public Short convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return Short.decode(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ZoneIdConverter.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ZoneIdConverter.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ZoneIdConverter.java
new file mode 100644
index 0000000..eeeb84d
--- /dev/null
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/converters/ZoneIdConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.time.ZoneId;
+import java.util.Objects;
+
+/**
+ * Converter, converting from String to LocalDate.
+ */
+public class ZoneIdConverter implements PropertyConverter<ZoneId>{
+    @Override
+    public Class<ZoneId> getTargetType() {
+        return ZoneId.class;
+    }
+
+    @Override
+    public ZoneId convert(String value) {
+        String trimmed = Objects.requireNonNull(value).trim();
+        return ZoneId.of(trimmed);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java
new file mode 100644
index 0000000..ba4279f
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.Configuration;
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests the default converter for bytes.
+ */
+public class BooleanConverterTest {
+
+    /**
+     * Test conversion. The value are provided by
+     * {@link ConverterTestsPropertySource}.
+     * @throws Exception
+     */
+    @Test
+    public void testConvert_Byte() throws Exception {
+        Configuration config = Configuration.current();
+        // trues
+        Optional<Boolean> valueRead = config.getOptional("tests.converter.boolean.y1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.y2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.yes1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.yes2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.yes3", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.true1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.true2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.true3", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.t1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.t2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertTrue(valueRead.get().booleanValue());
+        // falses
+        valueRead = config.getOptional("tests.converter.boolean.n1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.n2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.no1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.no2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.no3", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.false1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.false2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.false3", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.f1", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.f2", Boolean.class);
+        assertTrue(valueRead.isPresent());
+        assertFalse(valueRead.get().booleanValue());
+        valueRead = config.getOptional("tests.converter.boolean.foo", Boolean.class);
+        assertFalse(valueRead.isPresent());
+    }
+    /*
+
+            case "tests.converter.boolean.n1":
+                return "n";
+            case "tests.converter.boolean.n2":
+                return "N";
+            case "tests.converter.boolean.no1":
+                return "no";
+            case "tests.converter.boolean.no2":
+                return "No";
+            case "tests.converter.boolean.no3":
+                return "nO";
+            case "tests.converter.boolean.false1":
+                return "false";
+            case "tests.converter.boolean.false2":
+                return "False";
+            case "tests.converter.boolean.false3":
+                return "falSe";
+            case "tests.converter.boolean.f1":
+                return "f";
+            case "tests.converter.boolean.f2":
+                return "F";
+     */
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java
new file mode 100644
index 0000000..5bdee37
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.Configuration;
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the default converter for bytes.
+ */
+public class ByteConverterTest {
+
+    /**
+     * Test conversion. The value are provided by
+     * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}.
+     * @throws Exception
+     */
+    @Test
+    public void testConvert_Byte() throws Exception {
+        Configuration config = Configuration.current();
+        Optional<Byte> valueRead = config.getOptional("tests.converter.byte.decimal", Byte.class);
+        assertTrue(valueRead.isPresent());
+        assertEquals(valueRead.get().byteValue(), 101);
+        valueRead = config.getOptional("tests.converter.byte.octal", Byte.class);
+        assertTrue(valueRead.isPresent());
+        assertEquals(valueRead.get().byteValue(), Byte.decode("02").byteValue());
+        valueRead = config.getOptional("tests.converter.byte.hex.lowerX", Byte.class);
+        assertTrue(valueRead.isPresent());
+        assertEquals(valueRead.get().byteValue(), Byte.decode("0x2F").byteValue());
+        valueRead = config.getOptional("tests.converter.byte.hex.upperX", Byte.class);
+        assertTrue(valueRead.isPresent());
+        assertEquals(valueRead.get().byteValue(), Byte.decode("0X3F").byteValue());
+        valueRead = config.getOptional("tests.converter.byte.foo", Byte.class);
+        assertFalse(valueRead.isPresent());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
new file mode 100644
index 0000000..618a8d6
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Test Property Source used by converter tests.
+ */
+public class ConverterTestsPropertySource implements PropertySource{
+    @Override
+    public int getOrdinal() {
+        return 0;
+    }
+
+    @Override
+    public String get(String key) {
+        switch(key){
+            // Bytes
+            case "tests.converter.byte.decimal":
+                return "101";
+            case "tests.converter.byte.octal":
+                return "02";
+            case "tests.converter.byte.hex.lowerX":
+                return "0x2F";
+            case "tests.converter.byte.hex.upperX":
+                return "0X3F";
+            // Boolean
+            case "tests.converter.boolean.y1":
+                return "y";
+            case "tests.converter.boolean.y2":
+                return "Y";
+            case "tests.converter.boolean.yes1":
+                return "yes";
+            case "tests.converter.boolean.yes2":
+                return "Yes";
+            case "tests.converter.boolean.yes3":
+                return "yeS";
+            case "tests.converter.boolean.true1":
+                return "true";
+            case "tests.converter.boolean.true2":
+                return "True";
+            case "tests.converter.boolean.true3":
+                return "trUe";
+            case "tests.converter.boolean.t1":
+                return "t";
+            case "tests.converter.boolean.t2":
+                return "T";
+            case "tests.converter.boolean.n1":
+                return "n";
+            case "tests.converter.boolean.n2":
+                return "N";
+            case "tests.converter.boolean.no1":
+                return "no";
+            case "tests.converter.boolean.no2":
+                return "No";
+            case "tests.converter.boolean.no3":
+                return "nO";
+            case "tests.converter.boolean.false1":
+                return "false";
+            case "tests.converter.boolean.false2":
+                return "False";
+            case "tests.converter.boolean.false3":
+                return "falSe";
+            case "tests.converter.boolean.f1":
+                return "f";
+            case "tests.converter.boolean.f2":
+                return "F";
+        }
+        return null;
+    }
+
+    /*
+    case "yes":
+            case "y":
+            case "true":
+            case "t":
+                return Boolean.TRUE;
+            case "no":
+            case "n":
+            case "false":
+            case "f":
+     */
+    @Override
+    public Map<String, String> getProperties() {
+        return Collections.emptyMap();
+    }
+
+    @Override
+    public boolean isScannable() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/578c873d/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
index 1effc9e..72dd3c3 100644
--- a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -18,4 +18,5 @@
 #
 org.apache.tamaya.core.testdata.TestPropertyDefaultSource
 org.apache.tamaya.core.propertysource.SystemPropertySource
-org.apache.tamaya.core.propertysource.EnvironmentPropertySource
\ No newline at end of file
+org.apache.tamaya.core.propertysource.EnvironmentPropertySource
+org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource
\ No newline at end of file


[3/5] incubator-tamaya git commit: TAMAYA-45: Moved event annotations out of package (functionality must be discussed with question of update handling in general).

Posted by an...@apache.org.
TAMAYA-45: Moved event annotations out of package (functionality must be discussed with question of update handling in general).


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

Branch: refs/heads/master
Commit: 2acf67b770c4e3c61293aad87599346ccb827799
Parents: 4f5269e
Author: anatole <an...@apache.org>
Authored: Sun Jan 18 01:04:56 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 18 01:09:26 2015 +0100

----------------------------------------------------------------------
 .../tamaya/event/ObservesConfigChange.java      |  38 +++++
 .../apache/tamaya/event/PropertyChangeSet.java  | 125 +++++++++++++++
 .../tamaya/event/PropertyChangeSetBuilder.java  | 154 +++++++++++++++++++
 .../org/apache/tamaya/inject/ConfigRoot.java    |  43 ++++++
 .../tamaya/inject/ConfigurationInjector.java    |  25 +--
 .../org/apache/tamaya/inject/DefaultAreas.java  |  43 ------
 .../tamaya/inject/ObservesConfigChange.java     |  38 -----
 .../apache/tamaya/inject/PropertyChangeSet.java | 125 ---------------
 .../tamaya/inject/PropertyChangeSetBuilder.java | 154 -------------------
 .../internal/ConfigChangeCallbackMethod.java    |   2 +-
 .../tamaya/inject/internal/ConfiguredField.java |   4 +-
 .../inject/internal/ConfiguredSetterMethod.java |   6 +-
 .../tamaya/inject/internal/ConfiguredType.java  |   8 +-
 .../internal/DefaultConfigurationInjector.java  |  11 +-
 .../tamaya/inject/internal/InjectionUtils.java  |  12 +-
 .../internal/WeakConfigListenerManager.java     |   2 +-
 16 files changed, 401 insertions(+), 389 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java b/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
new file mode 100644
index 0000000..9fc6d9b
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
@@ -0,0 +1,38 @@
+/*
+ * 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.event;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to annotate a method on a class to be informed on config changes.
+ * The exact behaviour, when configuration change events are sent can be configured
+ * on each configured property/method by adding the {@link org.apache.tamaya.inject.WithLoadPolicy}
+ * annotation. By default listeners are informed on all changes of configurations that were used as
+ * input configurations for configuring a class/instance. Additionally {@link org.apache.tamaya.inject.ConfiguredProperty}
+ * annotations can be added that allows to constrain changes to some limited properties.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.METHOD })
+public @interface ObservesConfigChange {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java b/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java
new file mode 100644
index 0000000..079f333
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java
@@ -0,0 +1,125 @@
+/*
+ * 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.event;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * Event that contains a set of changed keys of a {@link org.apache.tamaya.spi.PropertySource}. Any values must
+ * be obtained by calling the {@link org.apache.tamaya.Configuration} due to security reasons. This event can be used
+ * by the {@link org.apache.tamaya.spi.PropertySource} implementation to cleanup caches as needed.
+ * This class is immutable and thread-safe. To create instances use
+ * {@link PropertyChangeSetBuilder}.
+ */
+public final class PropertyChangeSet implements Serializable{
+    /** The serialVersionUID. */
+    private static final long serialVersionUID = 1L;
+    /** The base property source name. */
+    private String propertySourceName;
+    /** The timestamp of the change. */
+    private long timestamp = System.currentTimeMillis();
+    /**
+     * The recorded keys added.
+     */
+    final SortedSet<String> addedKeys = new TreeSet<>();
+
+    /**
+     * The recorded keys updated.
+     */
+    final SortedSet<String> updatedKeys = new TreeSet<>();
+
+    /**
+     * The recorded keys removed.
+     */
+    final SortedSet<String> removedKeys = new TreeSet<>();
+
+
+    /**
+     * Constructor used by {@link PropertyChangeSetBuilder}.
+     * @param builder The builder instance, not null.
+     */
+    PropertyChangeSet(PropertyChangeSetBuilder builder) {
+        this.propertySourceName = Objects.requireNonNull(builder.propertySourceName);
+        this.addedKeys.addAll(builder.addedKeys);
+        this.removedKeys.addAll(builder.removedKeys);
+        this.updatedKeys.addAll(builder.updatedKeys);
+    }
+
+    /**
+     * Get the underlying property provider/configuration.
+     * @return the underlying property provider/configuration, never null.
+     */
+    public String getPropertySourceName(){
+        return this.propertySourceName;
+    }
+
+    /**
+     * Get the timestamp of this changeset. This allows to track, if a ChangeSet was already applied.
+     * @return the timestamp
+     */
+    public long getTimestamp(){
+        return timestamp;
+    }
+
+    /**
+     * Get the keys added.
+     * @return the added keys, never null.
+     */
+    public Collection<String> getKeysAdded(){
+        return Collections.unmodifiableCollection(this.addedKeys);
+    }
+
+    /**
+     * Get the keys removed.
+     * @return the removed keys, never null.
+     */
+    public Collection<String> getKeysRemoved(){
+        return Collections.unmodifiableCollection(this.removedKeys);
+    }
+
+    /**
+     * Get the updated keys.
+     * @return the updated keys, never null.
+     */
+    public Collection<String> getKeysUpdated(){
+        return Collections.unmodifiableCollection(this.addedKeys);
+    }
+
+
+    /**
+     * CHecks if the current change set does not contain any changes.
+     * @return tru, if the change set is empty.
+     */
+    public boolean isEmpty(){
+        return this.addedKeys.isEmpty() && this.updatedKeys.isEmpty() && this.removedKeys.isEmpty();
+    }
+
+
+    @Override
+    public String toString() {
+        return "ConfigChangeSet{" +
+                "propertySourceName=" + propertySourceName +
+                ", timestamp=" + timestamp +
+                ", addedKeys=" + addedKeys +
+                ", updatedKeys=" + updatedKeys +
+                ", removedKeys=" + removedKeys +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java b/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java
new file mode 100644
index 0000000..57a6264
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java
@@ -0,0 +1,154 @@
+/*
+ * 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.event;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.beans.PropertyChangeEvent;
+import java.util.*;
+
+/**
+ * Models a set current changes to be applied to a configuration/property provider.  Such a set can be applied
+ * to any {@link PropertySource} instance. If the provider is mutable it may check the
+ * version given and applyChanges the changes to the provider/configuration, including triggering current regarding
+ * change events.
+ * <p>
+ * For appropriate conversion a {@code Function<String, Codec>} can be applied, which performs correct conversion,
+ * when changed values are set. This function enables connecting e.g. setters on a configuration template with
+ * the corresponding conversion logic, so the template calls are correctly converted back.
+ */
+public final class PropertyChangeSetBuilder {
+    /**
+     * The recorded changes.
+     */
+    final SortedSet<String> addedKeys = new TreeSet<>();
+
+    /**
+     * The recorded changes.
+     */
+    final SortedSet<String> updatedKeys = new TreeSet<>();
+
+    /**
+     * The recorded changes.
+     */
+    final SortedSet<String> removedKeys = new TreeSet<>();
+
+    /**
+     * The underlying configuration/provider.
+     */
+    String propertySourceName;
+
+    /**
+     * Constructor.
+     *
+     * @param source      the underlying configuration/provider, not null.
+     */
+    private PropertyChangeSetBuilder(PropertySource source) {
+        this.propertySourceName = Objects.requireNonNull(source).getName();
+    }
+
+    /**
+     * Creates a new instance current this builder.
+     *
+     * @param source the underlying property provider/configuration, not null.
+     * @return the builder for chaining.
+     */
+    public static PropertyChangeSetBuilder of(PropertySource source) {
+        return new PropertyChangeSetBuilder(source);
+    }
+
+
+    /**
+     * Marks the given key(s) as removed.
+     *
+     * @param keys       the keys removed
+     * @return the builder for chaining.
+     */
+    public PropertyChangeSetBuilder remove(String... keys) {
+        for (String removeKey : keys) {
+            this.removedKeys.add(removeKey);
+        }
+        return this;
+    }
+
+    /**
+     * Marks the given key(s) as added.
+     *
+     * @param keys       the keys added
+     * @return the builder for chaining.
+     */
+    public PropertyChangeSetBuilder add(String... keys) {
+        for (String addKey : keys) {
+            this.addedKeys.add(addKey);
+        }
+        return this;
+    }
+
+    /**
+     * Marks the given key(s) as updaed.
+     *
+     * @param keys       the keys updated
+     * @return the builder for chaining.
+     */
+    public PropertyChangeSetBuilder update(String... keys) {
+        for (String uptKey : keys) {
+            this.updatedKeys.add(uptKey);
+        }
+        return this;
+    }
+
+
+    /**
+     * Compares the two property maps and adds the corresponding updated/aded/removed keys to the builder.
+     *
+     * @param map1 the source map, not null.
+     * @param map2 the target map, not null.
+     * @return the builder for chaining.
+     */
+    public PropertyChangeSetBuilder addChanges(Map<String,String> map1, Map<String,String> map2) {
+        List<PropertyChangeEvent> changes = new ArrayList<>();
+        for (Map.Entry<String, String> en : map1.entrySet()) {
+            String val = map2.get(en.getKey());
+            if (val==null) {
+                remove(en.getKey());
+            } else if (!val.equals(en.getValue())) {
+                update(en.getKey());
+            }
+        }
+        for (Map.Entry<String, String> en : map2.entrySet()) {
+            String val = map1.get(en.getKey());
+            if (val==null) {
+                add(en.getKey());
+            }
+            // update case already handled before!
+        }
+        return this;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "PropertyChangeEventBuilder [propertySourceName=" + propertySourceName + ", " +
+                ", added=" + addedKeys + ", updated=" + updatedKeys +  ", removed=" + removedKeys +"]";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigRoot.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigRoot.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigRoot.java
new file mode 100644
index 0000000..86de2fb
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigRoot.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.inject;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to control injection and resolution current a configured bean. The configuration keys
+ * to be resolved are basically determined by the {@link ConfiguredProperty}
+ * annotation(s). Nevertheless these annotations can also have relative key names. This annotation allows
+ * to define a configuration area that is prefixed to all relative configuration keys within the
+ * corresponding class/template interface.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE })
+public @interface ConfigRoot {
+
+    /**
+     * Allows to declare an operator that should be applied before injecting values into the bean.
+     * @return the operator class to be used.
+     */
+    String[] value();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
index f7f7ee7..de1c29e 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
@@ -20,6 +20,8 @@ package org.apache.tamaya.inject;
 
 import org.apache.tamaya.spi.ServiceContext;
 
+import java.util.function.Supplier;
+
 
 /**
  * Accessor interface for injection of configuration and configuration templates.
@@ -27,24 +29,29 @@ import org.apache.tamaya.spi.ServiceContext;
 public interface ConfigurationInjector {
 
     /**
-     * Extract the configuration annotation config and registers it per class, for later reuse.
-     * @param type the type to be configured.
-     * @return the configured type registered.
-     */
-    void registerType(Class<?> type);
-
-    /**
      * Configured the current instance and reigsterd necessary listener to forward config change events as
      * defined by the current annotations in place.
+     *
      * @param instance the instance to be configured
+     * @return the configured instance (allows chaining of operations).
+     */
+    <T> T configure(T instance);
+
+
+    /**
+     * Creates a supplier for configured instances of the given type {@code T}.
+     * @param supplier the supplier to create new instances.
+     * @param <T> the target type.
+     * @return a supplier creating configured instances of {@code T}.
      */
-    void configure(Object instance);
+    <T> Supplier<T> getConfiguredSupplier(Supplier<T> supplier);
 
     /**
      * Get the current injector instance.
+     *
      * @return the current injector, not null.
      */
-    public static ConfigurationInjector getInstance(){
+    public static ConfigurationInjector getInstance() {
         return ServiceContext.getInstance().getService(ConfigurationInjector.class).get();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultAreas.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultAreas.java b/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultAreas.java
deleted file mode 100644
index a327f4e..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultAreas.java
+++ /dev/null
@@ -1,43 +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.inject;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to control injection and resolution current a configured bean. The configuration keys
- * to be resolved are basically determined by the {@link ConfiguredProperty}
- * annotation(s). Nevertheless these annotations can also have relative key names. This annotation allows
- * to define a configuration area that is prefixed to all relative configuration keys within the
- * corresponding class/template interface.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE })
-public @interface DefaultAreas {
-
-    /**
-     * Allows to declare an operator that should be applied before injecting values into the bean.
-     * @return the operator class to be used.
-     */
-    String[] value();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/ObservesConfigChange.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ObservesConfigChange.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ObservesConfigChange.java
deleted file mode 100644
index 95ea972..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ObservesConfigChange.java
+++ /dev/null
@@ -1,38 +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.inject;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to annotate a method on a class to be informed on config changes.
- * The exact behaviour, when configuration change events are sent can be configured
- * on each configured property/method by adding the {@link WithLoadPolicy}
- * annotation. By default listeners are informed on all changes of configurations that were used as
- * input configurations for configuring a class/instance. Additionally {@link ConfiguredProperty}
- * annotations can be added that allows to constrain changes to some limited properties.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.METHOD })
-public @interface ObservesConfigChange {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSet.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSet.java b/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSet.java
deleted file mode 100644
index bccb161..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSet.java
+++ /dev/null
@@ -1,125 +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.inject;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * Event that contains a set of changed keys of a {@link org.apache.tamaya.spi.PropertySource}. Any values must
- * be obtained by calling the {@link org.apache.tamaya.Configuration} due to security reasons. This event can be used
- * by the {@link org.apache.tamaya.spi.PropertySource} implementation to cleanup caches as needed.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertyChangeSetBuilder}.
- */
-public final class PropertyChangeSet implements Serializable{
-    /** The serialVersionUID. */
-    private static final long serialVersionUID = 1L;
-    /** The base property source name. */
-    private String propertySourceName;
-    /** The timestamp of the change. */
-    private long timestamp = System.currentTimeMillis();
-    /**
-     * The recorded keys added.
-     */
-    final SortedSet<String> addedKeys = new TreeSet<>();
-
-    /**
-     * The recorded keys updated.
-     */
-    final SortedSet<String> updatedKeys = new TreeSet<>();
-
-    /**
-     * The recorded keys removed.
-     */
-    final SortedSet<String> removedKeys = new TreeSet<>();
-
-
-    /**
-     * Constructor used by {@link PropertyChangeSetBuilder}.
-     * @param builder The builder instance, not null.
-     */
-    PropertyChangeSet(PropertyChangeSetBuilder builder) {
-        this.propertySourceName = Objects.requireNonNull(builder.propertySourceName);
-        this.addedKeys.addAll(builder.addedKeys);
-        this.removedKeys.addAll(builder.removedKeys);
-        this.updatedKeys.addAll(builder.updatedKeys);
-    }
-
-    /**
-     * Get the underlying property provider/configuration.
-     * @return the underlying property provider/configuration, never null.
-     */
-    public String getPropertySourceName(){
-        return this.propertySourceName;
-    }
-
-    /**
-     * Get the timestamp of this changeset. This allows to track, if a ChangeSet was already applied.
-     * @return the timestamp
-     */
-    public long getTimestamp(){
-        return timestamp;
-    }
-
-    /**
-     * Get the keys added.
-     * @return the added keys, never null.
-     */
-    public Collection<String> getKeysAdded(){
-        return Collections.unmodifiableCollection(this.addedKeys);
-    }
-
-    /**
-     * Get the keys removed.
-     * @return the removed keys, never null.
-     */
-    public Collection<String> getKeysRemoved(){
-        return Collections.unmodifiableCollection(this.removedKeys);
-    }
-
-    /**
-     * Get the updated keys.
-     * @return the updated keys, never null.
-     */
-    public Collection<String> getKeysUpdated(){
-        return Collections.unmodifiableCollection(this.addedKeys);
-    }
-
-
-    /**
-     * CHecks if the current change set does not contain any changes.
-     * @return tru, if the change set is empty.
-     */
-    public boolean isEmpty(){
-        return this.addedKeys.isEmpty() && this.updatedKeys.isEmpty() && this.removedKeys.isEmpty();
-    }
-
-
-    @Override
-    public String toString() {
-        return "ConfigChangeSet{" +
-                "propertySourceName=" + propertySourceName +
-                ", timestamp=" + timestamp +
-                ", addedKeys=" + addedKeys +
-                ", updatedKeys=" + updatedKeys +
-                ", removedKeys=" + removedKeys +
-                '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSetBuilder.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSetBuilder.java b/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSetBuilder.java
deleted file mode 100644
index be37f7d..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/PropertyChangeSetBuilder.java
+++ /dev/null
@@ -1,154 +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.inject;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.beans.PropertyChangeEvent;
-import java.util.*;
-
-/**
- * Models a set current changes to be applied to a configuration/property provider.  Such a set can be applied
- * to any {@link PropertySource} instance. If the provider is mutable it may check the
- * version given and applyChanges the changes to the provider/configuration, including triggering current regarding
- * change events.
- * <p>
- * For appropriate conversion a {@code Function<String, Codec>} can be applied, which performs correct conversion,
- * when changed values are set. This function enables connecting e.g. setters on a configuration template with
- * the corresponding conversion logic, so the template calls are correctly converted back.
- */
-public final class PropertyChangeSetBuilder {
-    /**
-     * The recorded changes.
-     */
-    final SortedSet<String> addedKeys = new TreeSet<>();
-
-    /**
-     * The recorded changes.
-     */
-    final SortedSet<String> updatedKeys = new TreeSet<>();
-
-    /**
-     * The recorded changes.
-     */
-    final SortedSet<String> removedKeys = new TreeSet<>();
-
-    /**
-     * The underlying configuration/provider.
-     */
-    String propertySourceName;
-
-    /**
-     * Constructor.
-     *
-     * @param source      the underlying configuration/provider, not null.
-     */
-    private PropertyChangeSetBuilder(PropertySource source) {
-        this.propertySourceName = Objects.requireNonNull(source).getName();
-    }
-
-    /**
-     * Creates a new instance current this builder.
-     *
-     * @param source the underlying property provider/configuration, not null.
-     * @return the builder for chaining.
-     */
-    public static PropertyChangeSetBuilder of(PropertySource source) {
-        return new PropertyChangeSetBuilder(source);
-    }
-
-
-    /**
-     * Marks the given key(s) as removed.
-     *
-     * @param keys       the keys removed
-     * @return the builder for chaining.
-     */
-    public PropertyChangeSetBuilder remove(String... keys) {
-        for (String removeKey : keys) {
-            this.removedKeys.add(removeKey);
-        }
-        return this;
-    }
-
-    /**
-     * Marks the given key(s) as added.
-     *
-     * @param keys       the keys added
-     * @return the builder for chaining.
-     */
-    public PropertyChangeSetBuilder add(String... keys) {
-        for (String addKey : keys) {
-            this.addedKeys.add(addKey);
-        }
-        return this;
-    }
-
-    /**
-     * Marks the given key(s) as updaed.
-     *
-     * @param keys       the keys updated
-     * @return the builder for chaining.
-     */
-    public PropertyChangeSetBuilder update(String... keys) {
-        for (String uptKey : keys) {
-            this.updatedKeys.add(uptKey);
-        }
-        return this;
-    }
-
-
-    /**
-     * Compares the two property maps and adds the corresponding updated/aded/removed keys to the builder.
-     *
-     * @param map1 the source map, not null.
-     * @param map2 the target map, not null.
-     * @return the builder for chaining.
-     */
-    public PropertyChangeSetBuilder addChanges(Map<String,String> map1, Map<String,String> map2) {
-        List<PropertyChangeEvent> changes = new ArrayList<>();
-        for (Map.Entry<String, String> en : map1.entrySet()) {
-            String val = map2.get(en.getKey());
-            if (val==null) {
-                remove(en.getKey());
-            } else if (!val.equals(en.getValue())) {
-                update(en.getKey());
-            }
-        }
-        for (Map.Entry<String, String> en : map2.entrySet()) {
-            String val = map1.get(en.getKey());
-            if (val==null) {
-                add(en.getKey());
-            }
-            // update case already handled before!
-        }
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
-    @Override
-    public String toString() {
-        return "PropertyChangeEventBuilder [propertySourceName=" + propertySourceName + ", " +
-                ", added=" + addedKeys + ", updated=" + updatedKeys +  ", removed=" + removedKeys +"]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigChangeCallbackMethod.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigChangeCallbackMethod.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigChangeCallbackMethod.java
index 74ae68f..5f51741 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigChangeCallbackMethod.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigChangeCallbackMethod.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.inject.internal;
 
-import org.apache.tamaya.inject.PropertyChangeSet;
+import org.apache.tamaya.event.PropertyChangeSet;
 
 import java.lang.reflect.Method;
 import java.util.Optional;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredField.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredField.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredField.java
index 96b5f38..5e4db2a 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredField.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredField.java
@@ -23,8 +23,8 @@ import java.util.List;
 import java.util.Objects;
 
 import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.inject.ConfigRoot;
 import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultAreas;
 
 /**
  * Small class that contains and manages all information anc access to a configured field and a concrete instance current
@@ -97,7 +97,7 @@ public class ConfiguredField {
      */
     public boolean matchesKey(String key) {
         ConfiguredProperty prop = this.annotatedField.getAnnotation(ConfiguredProperty.class);
-        DefaultAreas areasAnnot = this.annotatedField.getDeclaringClass().getAnnotation(DefaultAreas.class);
+        ConfigRoot areasAnnot = this.annotatedField.getDeclaringClass().getAnnotation(ConfigRoot.class);
         List<String> keys = InjectionUtils.evaluateKeys(this.annotatedField, areasAnnot, prop);
         return keys.contains(key);
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
index cc3ed05..7a41ac9 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
@@ -24,9 +24,9 @@ import java.util.Optional;
 import java.util.function.Consumer;
 
 import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.inject.ConfigRoot;
 import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultAreas;
-import org.apache.tamaya.inject.PropertyChangeSet;
+import org.apache.tamaya.event.PropertyChangeSet;
 
 /**
  * Small class that contains and manages all information and access to a configured field and a concrete instance current
@@ -107,7 +107,7 @@ public class ConfiguredSetterMethod {
      * @return true, if the key is referenced.
      */
     public boolean matchesKey(String key) {
-        DefaultAreas areasAnnot = this.setterMethod.getDeclaringClass().getAnnotation(DefaultAreas.class);
+        ConfigRoot areasAnnot = this.setterMethod.getDeclaringClass().getAnnotation(ConfigRoot.class);
         ConfiguredProperty prop = this.setterMethod.getAnnotation(ConfiguredProperty.class);
         if (InjectionUtils.evaluateKeys(this.setterMethod, areasAnnot, prop).contains(key)) {
             return true;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
index ff155c4..08ee8c9 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
@@ -24,11 +24,11 @@ import java.util.*;
 
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.Configuration;
+import org.apache.tamaya.inject.ConfigRoot;
 import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultAreas;
 import org.apache.tamaya.inject.NoConfig;
-import org.apache.tamaya.inject.ObservesConfigChange;
-import org.apache.tamaya.inject.PropertyChangeSet;
+import org.apache.tamaya.event.ObservesConfigChange;
+import org.apache.tamaya.event.PropertyChangeSet;
 import org.apache.tamaya.spi.PropertySource;
 
 /**
@@ -187,7 +187,7 @@ public class ConfiguredType {
     }
 
     public static boolean isConfigured(Class type) {
-        if (type.getAnnotation(DefaultAreas.class) != null) {
+        if (type.getAnnotation(ConfigRoot.class) != null) {
             return true;
         }
         // if no class level annotation is there we might have field level annotations only

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
index f62838c..6f6794b 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
@@ -24,6 +24,7 @@ import javax.annotation.Priority;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Supplier;
 
 /**
  * Simple injector singleton that also registers instances configured using weak references.
@@ -43,8 +44,7 @@ public final class DefaultConfigurationInjector implements ConfigurationInjector
         return configuredTypes.computeIfAbsent(type, ConfiguredType::new);
     }
 
-    @Override
-    public void registerType(Class<?> type) {
+    void registerType(Class<?> type) {
         registerTypeInternal(type);
     }
 
@@ -54,11 +54,16 @@ public final class DefaultConfigurationInjector implements ConfigurationInjector
      *
      * @param instance the instance to be configured
      */
-    public void configure(Object instance) {
+    public <T> T configure(T instance) {
         Class type = Objects.requireNonNull(instance).getClass();
         ConfiguredType configuredType = registerTypeInternal(type);
         Objects.requireNonNull(configuredType).configure(instance);
+        return instance;
     }
 
 
+    @Override
+    public <T> Supplier<T> getConfiguredSupplier(Supplier<T> supplier) {
+        return () -> configure(supplier.get());
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
index 3944cd6..bf4f77d 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
@@ -31,8 +31,8 @@ import java.util.logging.Logger;
 
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.Configuration;
+import org.apache.tamaya.inject.ConfigRoot;
 import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultAreas;
 import org.apache.tamaya.inject.DefaultValue;
 import org.apache.tamaya.inject.WithLoadPolicy;
 import org.apache.tamaya.inject.WithPropertyConverter;
@@ -72,7 +72,7 @@ final class InjectionUtils {
      *                           several keys to be looked up (in absolute or relative form).
      * @return the list current keys in order how they should be processed/looked up.
      */
-    public static List<String> evaluateKeys(Member member, DefaultAreas areasAnnot, ConfiguredProperty propertyAnnotation) {
+    public static List<String> evaluateKeys(Member member, ConfigRoot areasAnnot, ConfiguredProperty propertyAnnotation) {
         List<String> keys = new ArrayList<>(Arrays.asList(propertyAnnotation.keys()));
         if (keys.isEmpty()) {
             keys.add(member.getName());
@@ -103,7 +103,7 @@ final class InjectionUtils {
      * @param areasAnnot the (optional) annotation definining areas to be looked up.
      * @return the list current keys in order how they should be processed/looked up.
      */
-    public static List<String> evaluateKeys(Member member, DefaultAreas areasAnnot) {
+    public static List<String> evaluateKeys(Member member, ConfigRoot areasAnnot) {
         List<String> keys = new ArrayList<>();
         String name = member.getName();
         String mainKey;
@@ -132,7 +132,7 @@ final class InjectionUtils {
      * @return the keys to be returned, or null.
      */
     public static String getConfigValue(Method method) {
-        DefaultAreas areasAnnot = method.getDeclaringClass().getAnnotation(DefaultAreas.class);
+        ConfigRoot areasAnnot = method.getDeclaringClass().getAnnotation(ConfigRoot.class);
         WithLoadPolicy loadPolicy = Utils.getAnnotation(WithLoadPolicy.class, method, method.getDeclaringClass());
         return getConfigValueInternal(method, areasAnnot, loadPolicy);
     }
@@ -144,7 +144,7 @@ final class InjectionUtils {
      * @return the keys to be returned, or null.
      */
     public static String getConfigValue(Field field) {
-        DefaultAreas areasAnnot = field.getDeclaringClass().getAnnotation(DefaultAreas.class);
+        ConfigRoot areasAnnot = field.getDeclaringClass().getAnnotation(ConfigRoot.class);
         WithLoadPolicy loadPolicy = Utils.getAnnotation(WithLoadPolicy.class, field, field.getDeclaringClass());
         return getConfigValueInternal(field, areasAnnot, loadPolicy);
     }
@@ -154,7 +154,7 @@ final class InjectionUtils {
      *
      * @return the keys to be returned, or null.
      */
-    private static String getConfigValueInternal(AnnotatedElement element, DefaultAreas areasAnnot, WithLoadPolicy loadPolicy) {
+    private static String getConfigValueInternal(AnnotatedElement element, ConfigRoot areasAnnot, WithLoadPolicy loadPolicy) {
         ConfiguredProperty prop = element.getAnnotation(ConfiguredProperty.class);
         DefaultValue defaultAnnot = element.getAnnotation(DefaultValue.class);
         String configValue = null;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2acf67b7/modules/injection/src/main/java/org/apache/tamaya/inject/internal/WeakConfigListenerManager.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/WeakConfigListenerManager.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/WeakConfigListenerManager.java
index dd8bf31..3ea8ed7 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/WeakConfigListenerManager.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/WeakConfigListenerManager.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tamaya.inject.internal;
 
-import org.apache.tamaya.inject.PropertyChangeSet;
+import org.apache.tamaya.event.PropertyChangeSet;
 
 import java.util.Map;
 import java.util.WeakHashMap;


[4/5] incubator-tamaya git commit: Removed unused imports.

Posted by an...@apache.org.
Removed unused imports.


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

Branch: refs/heads/master
Commit: dc022afdd41c8e647ffe0dd1cbcc5eefb61f392a
Parents: 2acf67b
Author: anatole <an...@apache.org>
Authored: Sun Jan 18 01:05:50 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 18 01:09:27 2015 +0100

----------------------------------------------------------------------
 .../internal/DefaultServiceContextTest.java     | 131 ++++++++++++++++++
 .../core/internal/PropetiesFileLoaderTest.java  |  75 +++++++++++
 .../internal/DefaultServiceContextTest.java     | 133 -------------------
 .../test/internal/PropetiesFileLoaderTest.java  |  76 -----------
 4 files changed, 206 insertions(+), 209 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
new file mode 100644
index 0000000..69f02c0
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.annotation.Priority;
+import java.util.List;
+import java.util.Optional;
+
+public class DefaultServiceContextTest {
+
+    /**
+     * context to test
+     */
+    private DefaultServiceContext context = new DefaultServiceContext();
+
+
+    @Test
+    public void testGetService() {
+        Optional<ConfigurationContext> configurationContext = context.getService(ConfigurationContext.class);
+
+        Assert.assertNotNull(configurationContext);
+        Assert.assertTrue(configurationContext.isPresent());
+        Assert.assertTrue(configurationContext.get() instanceof DefaultConfigurationContext);
+    }
+
+    @Test(expected = ConfigException.class)
+    public void testGetService_multipleServicesWithoutPriority_shouldThrowConfigException() {
+        context.getService(InvalidPriorityInterface.class);
+    }
+
+    @Test
+    public void testGetService_multipleService_shouldReturnServiceWithHighestPriority() {
+        Optional<MultiImplsInterface> service = context.getService(MultiImplsInterface.class);
+
+        Assert.assertTrue(service.isPresent());
+        Assert.assertTrue(service.get() instanceof MultiImpl2);
+    }
+
+    @Test
+    public void testGetService_noImpl_shouldReturnEmptyOpional() {
+        Optional<NoImplInterface> service = context.getService(NoImplInterface.class);
+        Assert.assertFalse(service.isPresent());
+    }
+
+
+    @Test
+    public void testGetServices_shouldReturnServices() {
+        {
+            List<InvalidPriorityInterface> services = context.getServices(InvalidPriorityInterface.class);
+            Assert.assertNotNull(services);
+            Assert.assertEquals(2, services.size());
+
+            for (InvalidPriorityInterface service : services) {
+                Assert.assertTrue(service instanceof InvalidPriorityImpl1 || service instanceof InvalidPriorityImpl2);
+            }
+        }
+
+        {
+            List<MultiImplsInterface> services = context.getServices(MultiImplsInterface.class);
+            Assert.assertNotNull(services);
+            Assert.assertEquals(3, services.size());
+
+            for (MultiImplsInterface service : services) {
+                Assert.assertTrue(service instanceof MultiImpl1 ||
+                                          service instanceof MultiImpl2 ||
+                                          service instanceof MultiImpl3);
+            }
+        }
+    }
+
+    @Test
+    public void testGetServices_noImpl_shouldReturnEmptyList() {
+        List<NoImplInterface> services = context.getServices(NoImplInterface.class);
+        Assert.assertNotNull(services);
+        Assert.assertTrue(services.isEmpty());
+    }
+
+
+    // some test interfaces and classes
+
+    public static interface InvalidPriorityInterface {
+    }
+
+    @Priority(value = 50)
+    public static class InvalidPriorityImpl1 implements InvalidPriorityInterface {
+    }
+
+    @Priority(value = 50)
+    public static class InvalidPriorityImpl2 implements InvalidPriorityInterface {
+    }
+
+
+    public static interface MultiImplsInterface {
+    }
+
+    public static class MultiImpl1 implements MultiImplsInterface {
+    }
+
+    @Priority(value = 500)
+    public static class MultiImpl2 implements MultiImplsInterface {
+    }
+
+    @Priority(value = -10)
+    public static class MultiImpl3 implements MultiImplsInterface {
+    }
+
+
+    private static interface NoImplInterface {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
new file mode 100644
index 0000000..c125641
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.net.URL;
+import java.util.Properties;
+import java.util.Set;
+
+public class PropetiesFileLoaderTest {
+
+
+    @Test
+    public void testResolvePropertiesFiles() throws Exception {
+        Properties expectedProperties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
+
+        {
+            // with .properties
+            Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile.properties");
+            Assert.assertNotNull(urls);
+            Assert.assertFalse(urls.isEmpty());
+
+            Properties properties = PropertiesFileLoader.load(urls.iterator().next());
+            Assert.assertEquals(expectedProperties.size(), properties.size());
+        }
+
+        {
+            // without .properties
+            Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile");
+            Assert.assertNotNull(urls);
+            Assert.assertFalse(urls.isEmpty());
+
+            Properties properties = PropertiesFileLoader.load(urls.iterator().next());
+            Assert.assertEquals(expectedProperties.size(), properties.size());
+        }
+
+        {
+            // with a while which doesn't exist
+            Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("nonexistingfile.properties");
+            Assert.assertNotNull(urls);
+            Assert.assertTrue(urls.isEmpty());
+        }
+
+    }
+
+    @Test
+    public void testLoad() {
+        Properties properties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
+
+        Assert.assertNotNull(properties);
+        Assert.assertEquals(5, properties.size());
+
+        for (int i = 1; i < 6; i++) {
+            Assert.assertEquals(properties.getProperty("key" + i), "val" + i);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java
deleted file mode 100644
index 0aaf63f..0000000
--- a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.test.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.internal.DefaultConfigurationContext;
-import org.apache.tamaya.core.internal.DefaultServiceContext;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.junit.Assert;
-import org.junit.Test;
-
-import javax.annotation.Priority;
-import java.util.List;
-import java.util.Optional;
-
-public class DefaultServiceContextTest {
-
-    /**
-     * context to test
-     */
-    private DefaultServiceContext context = new DefaultServiceContext();
-
-
-    @Test
-    public void testGetService() {
-        Optional<ConfigurationContext> configurationContext = context.getService(ConfigurationContext.class);
-
-        Assert.assertNotNull(configurationContext);
-        Assert.assertTrue(configurationContext.isPresent());
-        Assert.assertTrue(configurationContext.get() instanceof DefaultConfigurationContext);
-    }
-
-    @Test(expected = ConfigException.class)
-    public void testGetService_multipleServicesWithoutPriority_shouldThrowConfigException() {
-        context.getService(InvalidPriorityInterface.class);
-    }
-
-    @Test
-    public void testGetService_multipleService_shouldReturnServiceWithHighestPriority() {
-        Optional<MultiImplsInterface> service = context.getService(MultiImplsInterface.class);
-
-        Assert.assertTrue(service.isPresent());
-        Assert.assertTrue(service.get() instanceof MultiImpl2);
-    }
-
-    @Test
-    public void testGetService_noImpl_shouldReturnEmptyOpional() {
-        Optional<NoImplInterface> service = context.getService(NoImplInterface.class);
-        Assert.assertFalse(service.isPresent());
-    }
-
-
-    @Test
-    public void testGetServices_shouldReturnServices() {
-        {
-            List<InvalidPriorityInterface> services = context.getServices(InvalidPriorityInterface.class);
-            Assert.assertNotNull(services);
-            Assert.assertEquals(2, services.size());
-
-            for (InvalidPriorityInterface service : services) {
-                Assert.assertTrue(service instanceof InvalidPriorityImpl1 || service instanceof InvalidPriorityImpl2);
-            }
-        }
-
-        {
-            List<MultiImplsInterface> services = context.getServices(MultiImplsInterface.class);
-            Assert.assertNotNull(services);
-            Assert.assertEquals(3, services.size());
-
-            for (MultiImplsInterface service : services) {
-                Assert.assertTrue(service instanceof MultiImpl1 ||
-                                          service instanceof MultiImpl2 ||
-                                          service instanceof MultiImpl3);
-            }
-        }
-    }
-
-    @Test
-    public void testGetServices_noImpl_shouldReturnEmptyList() {
-        List<NoImplInterface> services = context.getServices(NoImplInterface.class);
-        Assert.assertNotNull(services);
-        Assert.assertTrue(services.isEmpty());
-    }
-
-
-    // some test interfaces and classes
-
-    public static interface InvalidPriorityInterface {
-    }
-
-    @Priority(value = 50)
-    public static class InvalidPriorityImpl1 implements InvalidPriorityInterface {
-    }
-
-    @Priority(value = 50)
-    public static class InvalidPriorityImpl2 implements InvalidPriorityInterface {
-    }
-
-
-    public static interface MultiImplsInterface {
-    }
-
-    public static class MultiImpl1 implements MultiImplsInterface {
-    }
-
-    @Priority(value = 500)
-    public static class MultiImpl2 implements MultiImplsInterface {
-    }
-
-    @Priority(value = -10)
-    public static class MultiImpl3 implements MultiImplsInterface {
-    }
-
-
-    private static interface NoImplInterface {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java
deleted file mode 100644
index 985b5d5..0000000
--- a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.test.internal;
-
-import org.apache.tamaya.core.internal.PropertiesFileLoader;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.net.URL;
-import java.util.Properties;
-import java.util.Set;
-
-public class PropetiesFileLoaderTest {
-
-
-    @Test
-    public void testResolvePropertiesFiles() throws Exception {
-        Properties expectedProperties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
-
-        {
-            // with .properties
-            Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile.properties");
-            Assert.assertNotNull(urls);
-            Assert.assertFalse(urls.isEmpty());
-
-            Properties properties = PropertiesFileLoader.load(urls.iterator().next());
-            Assert.assertEquals(expectedProperties.size(), properties.size());
-        }
-
-        {
-            // without .properties
-            Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile");
-            Assert.assertNotNull(urls);
-            Assert.assertFalse(urls.isEmpty());
-
-            Properties properties = PropertiesFileLoader.load(urls.iterator().next());
-            Assert.assertEquals(expectedProperties.size(), properties.size());
-        }
-
-        {
-            // with a while which doesn't exist
-            Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("nonexistingfile.properties");
-            Assert.assertNotNull(urls);
-            Assert.assertTrue(urls.isEmpty());
-        }
-
-    }
-
-    @Test
-    public void testLoad() {
-        Properties properties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
-
-        Assert.assertNotNull(properties);
-        Assert.assertEquals(5, properties.size());
-
-        for (int i = 1; i < 6; i++) {
-            Assert.assertEquals(properties.getProperty("key" + i), "val" + i);
-        }
-    }
-}


[2/5] incubator-tamaya git commit: TAMAYA-58: Added getTargetType to PropertyConverter. Added implementations of converters for base types.

Posted by an...@apache.org.
TAMAYA-58: Added getTargetType to PropertyConverter. Added implementations of converters for base types.


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

Branch: refs/heads/master
Commit: 4f5269ec6e1cba7ea59ddf81f5cd94467353ebf4
Parents: 578c873
Author: anatole <an...@apache.org>
Authored: Sun Jan 18 01:03:32 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 18 01:09:25 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/spi/PropertySource.java   | 11 ++++---
 .../org.apache.tamaya.spi.PropertyConverter     | 34 ++++++++++++++++++++
 ...tServiceContextTest$InvalidPriorityInterface | 19 +++++++++++
 ...efaultServiceContextTest$MultiImplsInterface | 20 ++++++++++++
 ...tServiceContextTest$InvalidPriorityInterface | 19 -----------
 ...efaultServiceContextTest$MultiImplsInterface | 20 ------------
 6 files changed, 80 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4f5269ec/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
index 350759e..e91906a 100644
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
+++ b/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
@@ -84,11 +84,14 @@ public interface PropertySource {
 
 
     /**
-     * Get the name of the property source. The name should be unique for the type of source, whereas the id is used
-     * to ensure unique identity, either locally or remotely.
-     * @return the configuration's name, never null.
+     * Get the name of the property source. The name should be unique for the type of source, whereas multiple instances
+     * of the same type (and thus name) may exist in a system. Give a {@link org.apache.tamaya.spi.ConfigurationContext}
+     * the name of a PropertySource is unique.
+     * @return the property source's name, never null.
      */
-    String getName();
+    default String getName(){
+        return getClass().getName();
+    }
 
     /**
      * Access a property.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4f5269ec/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
new file mode 100644
index 0000000..964843c
--- /dev/null
+++ b/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy current the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.core.internal.converters.BooleanConverter
+org.apache.tamaya.core.internal.converters.ByteConverter
+org.apache.tamaya.core.internal.converters.CharConverter
+org.apache.tamaya.core.internal.converters.DoubleConverter
+org.apache.tamaya.core.internal.converters.FloatConverter
+org.apache.tamaya.core.internal.converters.IntegerConverter
+org.apache.tamaya.core.internal.converters.LongConverter
+org.apache.tamaya.core.internal.converters.ShortConverter
+org.apache.tamaya.core.internal.converters.BigDecimalConverter
+org.apache.tamaya.core.internal.converters.BigIntegerConverter
+org.apache.tamaya.core.internal.converters.CurrencyConverter
+org.apache.tamaya.core.internal.converters.LocalDateConverter
+org.apache.tamaya.core.internal.converters.LocalDateTimeConverter
+org.apache.tamaya.core.internal.converters.LocalTimeConverter
+org.apache.tamaya.core.internal.converters.ZoneIdConverter
+org.apache.tamaya.core.internal.converters.NumberConverter

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4f5269ec/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
----------------------------------------------------------------------
diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
new file mode 100644
index 0000000..62b9bd5
--- /dev/null
+++ b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy 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.
+
+org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityImpl1
+org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityImpl2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4f5269ec/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
----------------------------------------------------------------------
diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
new file mode 100644
index 0000000..b144790
--- /dev/null
+++ b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy 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.
+
+org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImpl1
+org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImpl2
+org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImpl3
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4f5269ec/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$InvalidPriorityInterface
----------------------------------------------------------------------
diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$InvalidPriorityInterface b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$InvalidPriorityInterface
deleted file mode 100644
index 6f0ccc7..0000000
--- a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$InvalidPriorityInterface
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy 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.
-
-org.apache.tamaya.core.test.internal.DefaultServiceContextTest$InvalidPriorityImpl1
-org.apache.tamaya.core.test.internal.DefaultServiceContextTest$InvalidPriorityImpl2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4f5269ec/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImplsInterface
----------------------------------------------------------------------
diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImplsInterface b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImplsInterface
deleted file mode 100644
index 1168b01..0000000
--- a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImplsInterface
+++ /dev/null
@@ -1,20 +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.
-
-org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImpl1
-org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImpl2
-org.apache.tamaya.core.test.internal.DefaultServiceContextTest$MultiImpl3
\ No newline at end of file


[5/5] incubator-tamaya git commit: TAMAYA-59: Fixed existing simple model to work with current API and other deps.

Posted by an...@apache.org.
TAMAYA-59: Fixed existing simple model to work with current API and other deps.


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

Branch: refs/heads/master
Commit: bfbaefa4314ab36ae9fc1e25880268dc106ba44d
Parents: dc022af
Author: anatole <an...@apache.org>
Authored: Sun Jan 18 01:08:58 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 18 01:09:28 2015 +0100

----------------------------------------------------------------------
 modules/metamodels/pom.xml                      |  2 +-
 modules/metamodels/simple/pom.xml               | 24 ++++++++++-
 .../metamodel/simple/MapPropertySource.java     | 44 ++++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bfbaefa4/modules/metamodels/pom.xml
----------------------------------------------------------------------
diff --git a/modules/metamodels/pom.xml b/modules/metamodels/pom.xml
index 4eecdc4..a42c287 100644
--- a/modules/metamodels/pom.xml
+++ b/modules/metamodels/pom.xml
@@ -23,7 +23,7 @@ under the License.
     <parent>
         <groupId>org.apache.tamaya.ext</groupId>
         <artifactId>tamaya-extensions</artifactId>
-        <version>0.2-incubating-SNAPSHOT</version>
+        <version>0.1-incubating-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <groupId>org.apache.tamaya.ext.metamodels</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bfbaefa4/modules/metamodels/simple/pom.xml
----------------------------------------------------------------------
diff --git a/modules/metamodels/simple/pom.xml b/modules/metamodels/simple/pom.xml
index 898ab2f..6665762 100644
--- a/modules/metamodels/simple/pom.xml
+++ b/modules/metamodels/simple/pom.xml
@@ -23,7 +23,7 @@ under the License.
     <parent>
         <groupId>org.apache.tamaya.ext.metamodels</groupId>
         <artifactId>tamaya-metamodels</artifactId>
-        <version>0.1-SNAPSHOT</version>
+        <version>0.1-incubating-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>tamaya-metamodel-simple</artifactId>
@@ -31,4 +31,26 @@ under the License.
     <description>Simple Tamaya Metamodel, e.g. feasible for SE commandline tools and simple use cases.</description>
     <packaging>jar</packaging>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-resources</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-formats</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bfbaefa4/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java b/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java
new file mode 100644
index 0000000..f2d237b
--- /dev/null
+++ b/modules/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/MapPropertySource.java
@@ -0,0 +1,44 @@
+package org.apache.tamaya.metamodel.simple;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Created by Anatole on 17.01.2015.
+ */
+public class MapPropertySource implements PropertySource {
+    private int ordinal;
+    private String name;
+    private Map<String, String> properties = new HashMap<>();
+
+    public MapPropertySource(int ordinal, String name, Map<String, String> properties) {
+        this.ordinal = ordinal;
+        this.name = Objects.requireNonNull(name);
+        this.properties.putAll(properties);
+        this.properties = Collections.unmodifiableMap(this.properties);
+    }
+
+    @Override
+    public int getOrdinal() {
+        return ordinal;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String get(String key) {
+        return properties.get(key);
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+}