tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [01/10] incubator-tamaya git commit: TAMAYA-128: Added ConversionContext for supporting more complex conversion cases.
Date Thu, 29 Oct 2015 12:09:54 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 7b6a17839 -> 7fc04517a


TAMAYA-128: Added ConversionContext for supporting more complex conversion cases.


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

Branch: refs/heads/master
Commit: a037268ac018ac283340257edf927a8137c3f154
Parents: 7b6a178
Author: Anatole Tresch <anatole@apache.org>
Authored: Thu Oct 29 11:38:18 2015 +0100
Committer: Anatole Tresch <anatole@apache.org>
Committed: Thu Oct 29 11:38:18 2015 +0100

----------------------------------------------------------------------
 .../apache/tamaya/spi/ConversionContext.java    | 219 +++++++++++++++++++
 .../apache/tamaya/spi/PropertyConverter.java    |  13 +-
 .../core/internal/DefaultConfiguration.java     |  12 +-
 .../core/internal/PropertyConverterManager.java |   7 +-
 .../converters/BigDecimalConverter.java         |   7 +-
 .../converters/BigIntegerConverter.java         |   8 +-
 .../internal/converters/BooleanConverter.java   |   4 +-
 .../core/internal/converters/ByteConverter.java |   4 +-
 .../core/internal/converters/CharConverter.java |   4 +-
 .../internal/converters/ClassConverter.java     |   4 +-
 .../internal/converters/CurrencyConverter.java  |   4 +-
 .../internal/converters/DoubleConverter.java    |   6 +-
 .../core/internal/converters/EnumConverter.java |   4 +-
 .../internal/converters/FloatConverter.java     |   6 +-
 .../internal/converters/IntegerConverter.java   |   4 +-
 .../core/internal/converters/LongConverter.java |   6 +-
 .../internal/converters/NumberConverter.java    |   8 +-
 .../internal/converters/ShortConverter.java     |   4 +-
 .../core/internal/converters/URIConverter.java  |   4 +-
 .../core/internal/converters/URLConverter.java  |   4 +-
 .../tamaya/core/internal/CTestConverter.java    |   3 +-
 .../internal/PropertyConverterManagerTest.java  |  20 +-
 .../internal/converters/EnumConverterTest.java  |  13 +-
 .../tamaya/spisupport/DefaultConfiguration.java |   7 +-
 .../apache/tamaya/spisupport/EnumConverter.java |   3 +-
 .../spisupport/PropertyConverterManager.java    |   5 +-
 26 files changed, 327 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java b/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java
new file mode 100644
index 0000000..c993003
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java
@@ -0,0 +1,219 @@
+/*
+ * 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.spi;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.TypeLiteral;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * A conversion context containing all the required values for implementing conversion. Use the included #Builder
+ * for creating new instances of. This class is thread-safe to use. Adding supported formats is synchronized.
+ * @see PropertyConverter
+ */
+public class ConversionContext {
+
+    private Configuration configuration;
+    private String key;
+    private TypeLiteral<?> targetType;
+    private Member injectionTarget;
+    private List<String> supportedFormats = new ArrayList<>();
+
+    /**
+     * Private constructor used from builder.
+     * @param builder the builder, not null.
+     */
+    protected ConversionContext(Builder builder){
+        this.key = builder.key;
+        this.injectionTarget = builder.injectionTarget;
+        this.targetType = builder.targetType;
+        this.supportedFormats.addAll(builder.supportedFormats);
+        this.configuration = builder.configuration;
+    }
+
+    /**
+     * Get the key accessed. This information is very useful to evaluate additional metadata needed to determine/
+     * control further aspects of the conversion.
+     * @return the key. This may be null in case where a default value has to be converted and no unique underlying
+     * key/value configuration is present..
+     */
+    public String getKey(){
+        return key;
+    }
+
+    /**
+     * Get the target type required.
+     * @return the target type required.
+     */
+    public TypeLiteral<?> getTargetType(){
+        return targetType;
+    }
+
+    /**
+     * Get the injection target, if conversion is performed using injection mechanisms.
+     * @return the injection target, either a {@link Field} or {@link Method}, or null.
+     */
+    public Member getInjectionTarget(){
+        return injectionTarget;
+    }
+
+    /**
+     * Get the configuration, which is targeted.
+     * @return the configuration instance.
+     */
+    public Configuration getConfiguration(){
+        return configuration;
+    }
+
+    /**
+     * Allows to add information on the supported/tried formats, which can be shown to the user, especially when
+     * conversion failed. Adding of formats is synchronized, all formats are added in order to the overall list.
+     * This means formats should be passed in order of precedence.
+     * @param converterType the converter, which implements the formats provided.
+     * @param formatDescriptors the format descriptions in a human readable form, e.g. as regular expressions.
+     */
+    public void addSupportedFormats(Class<? extends PropertyConverter> converterType, String... formatDescriptors){
+        synchronized (supportedFormats){
+            for(String format: formatDescriptors) {
+                supportedFormats.add(format + " (" + converterType.getSimpleName() + ")");
+            }
+        }
+    }
+
+    /**
+     * Get the supported/tried formats in precedence order. The contents of this method depends on the
+     * {@link PropertyConverter} instances involved in a conversion.
+     * @return the supported/tried formats, never null.
+     */
+    public List<String> getSupportedFormats(){
+        synchronized (supportedFormats){
+            return new ArrayList<>(supportedFormats);
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "ConversionContext{" +
+                "configuration=" + configuration +
+                ", key='" + key + '\'' +
+                ", targetType=" + targetType +
+                ", injectionTarget=" + injectionTarget +
+                ", supportedFormats=" + supportedFormats +
+                '}';
+    }
+
+    /**
+     * Builder to create new instances of {@link ConversionContext}.
+     */
+    public static final class Builder{
+        /** The backing configuration. */
+        private Configuration configuration;
+        /** The accessed key, or null. */
+        private String key;
+        /** The target type. */
+        private TypeLiteral<?> targetType;
+        /** The injection target (only set with injection used). */
+        private Member injectionTarget;
+        /** The ordered list of formats tried. */
+        private Set<String> supportedFormats = new HashSet<>();
+
+        /**
+         * Creates a new Builder instance.
+         * @param configuration the configuration, not null.
+         * @param key the requested key, may be null.
+         */
+        public Builder(Configuration configuration, String key){
+            this.key = key;
+            this.configuration = Objects.requireNonNull(configuration);
+        }
+
+        /**
+         * Sets the injected field, when configuration is injected.
+         * @param field the field, not null
+         * @return the builder instance, for chaining
+         */
+        public Builder setInjectedField(Field field){
+            this.injectionTarget = Objects.requireNonNull(field);
+            this.targetType = TypeLiteral.of(field.getType());
+            return this;
+        }
+
+        /**
+         * Sets the injected setter method, when configuration is injected.
+         * @param method the method, not null
+         * @return the builder instance, for chaining
+         */
+        public Builder setInjectedMethod(Method method){
+            this.injectionTarget = Objects.requireNonNull(method);
+            this.targetType = TypeLiteral.of(method.getParameterTypes()[0]);
+            return this;
+        }
+
+        /**
+         * Sets the required target type resulting from the conversion.
+         * @param typeLiteral the target type, not null.
+         * @return the builder instance, for chaining
+         */
+        public Builder setTargetType(TypeLiteral typeLiteral){
+            this.targetType = Objects.requireNonNull(typeLiteral);
+            return this;
+        }
+
+        /**
+         * Add the formats provided by a {@link PropertyConverter}. This method should be called by each converter
+         * performing/trying conversion, so the user can be given feedback on the supported formats on failure.
+         * @param converterType the converter type, not null.
+         * @param formatDescriptors the formats supported in a human readable form, e.g. as regular expressions.
+         * @return the builder instance, for chaining
+         */
+        public Builder addSupportedFormats(Class<? extends PropertyConverter> converterType, String... formatDescriptors){
+            for(String format: formatDescriptors) {
+                supportedFormats.add(format + " (" + converterType.getSimpleName() + ")");
+            }
+            return this;
+        }
+
+        /**
+         * Builds a new context instance.
+         * @return a new context, never null.
+         */
+        public ConversionContext build(){
+            return new ConversionContext(this);
+        }
+
+        @Override
+        public String toString() {
+            return "Builder{" +
+                    "configuration=" + configuration +
+                    ", key='" + key + '\'' +
+                    ", targetType=" + targetType +
+                    ", injectionTarget=" + injectionTarget +
+                    ", supportedFormats=" + supportedFormats +
+                    '}';
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java b/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
index 167e0a8..02ca904 100644
--- a/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
+++ b/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
@@ -28,14 +28,13 @@ public interface PropertyConverter<T>{
 
     /**
      * Convert the given configuration keys from it' String representation into the required target type.
-     * @param value the configuration keys
+     * The context instance passed also allows to add a list of supported formats, which is very handy in case a
+     * value could not be converted. This list of supported formats can then shown to the user to give some hints
+     * how a value could be configured.
+     * @param context the  {@link ConversionContext}, containing the String value and the requested configuration key.
      * @return converted keys
+     * @see ConversionContext#addSupportedFormats(Class, String...)
      */
-    T convert(String value);
+    T convert(String value, ConversionContext context);
 
-    //X TODO probably add some diagnostic info which explains what kind of
-    //X format(s) is supported.
-    //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.
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
index 76d9ac1..948c38e 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
@@ -23,11 +23,7 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+import org.apache.tamaya.spi.*;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -163,9 +159,10 @@ public class DefaultConfiguration implements Configuration {
     protected <T> T convertValue(String key, String value, TypeLiteral<T> type) {
         if (value != null) {
             List<PropertyConverter<T>> converters = configurationContext.getPropertyConverters(type);
+            ConversionContext context = new ConversionContext.Builder(this, key).setTargetType(type).build();
             for (PropertyConverter<T> converter : converters) {
                 try {
-                    T t = converter.convert(value);
+                    T t = converter.convert(value, context);
                     if (t != null) {
                         return t;
                     }
@@ -173,7 +170,8 @@ public class DefaultConfiguration implements Configuration {
                     LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value, e);
                 }
             }
-            throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key);
+            throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
+                    ", supported formats: " + context.getSupportedFormats());
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java b/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
index cbfad97..2a15e1d 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java
@@ -21,6 +21,7 @@ package org.apache.tamaya.core.internal;
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.TypeLiteral;
 import org.apache.tamaya.core.internal.converters.EnumConverter;
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.spi.ServiceContextManager;
 
@@ -364,7 +365,7 @@ public class PropertyConverterManager {
             }
             converter = new PropertyConverter<T>() {
                     @Override
-                    public T convert(String value) {
+                    public T convert(String value, ConversionContext context) {
                         AccessController.doPrivileged(new PrivilegedAction<Object>() {
                             @Override
                             public Object run() {
@@ -421,7 +422,9 @@ public class PropertyConverterManager {
         }
 
         @Override
-        public T convert(String value) {
+        public T convert(String value, ConversionContext context) {
+            context.addSupportedFormats(getClass(), "<String -> "+factoryMethod.toGenericString());
+
             if (!Modifier.isStatic(factoryMethod.getModifiers())) {
                 throw new ConfigException(factoryMethod.toGenericString() +
                         " is not a static method. Only static " +

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
index 53122f5..7057e73 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/BigDecimalConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.math.BigDecimal;
@@ -43,13 +44,15 @@ public class BigDecimalConverter implements PropertyConverter<BigDecimal>{
     private BigIntegerConverter integerConverter = new BigIntegerConverter();
 
     @Override
-    public BigDecimal convert(String value) {
+    public BigDecimal convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<bigDecimal> -> new BigDecimal(String)");
+
         String trimmed = Objects.requireNonNull(value).trim();
         try{
             return new BigDecimal(trimmed);
         } catch(Exception e){
             LOG.finest("Parsing BigDecimal failed, trying BigInteger for: " + value);
-            BigInteger bigInt = integerConverter.convert(trimmed);
+            BigInteger bigInt = integerConverter.convert(value, context);
             if(bigInt!=null){
                 return new BigDecimal(bigInt);
             }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
index 4692606..57ff2fb 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/BigIntegerConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.math.BigInteger;
@@ -44,7 +45,8 @@ public class BigIntegerConverter implements PropertyConverter<BigInteger>{
     private ByteConverter byteConverter = new ByteConverter();
 
     @Override
-    public BigInteger convert(String value) {
+    public BigInteger convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "[-]0X.. (hex)", "[-]0x... (hex)", "<bigint> -> new BigInteger(bigint)");
         String trimmed = Objects.requireNonNull(value).trim();
         if(trimmed.startsWith("0x") || trimmed.startsWith("0X")){
             LOG.finest("Parsing Hex value to BigInteger: " + value);
@@ -55,7 +57,7 @@ public class BigIntegerConverter implements PropertyConverter<BigInteger>{
                     LOG.finest("Invalid Hex-Byte-String: " + value);
                     return null;
                 }
-                byte val = byteConverter.convert("0x" + trimmed.substring(offset, offset + 2));
+                byte val = byteConverter.convert("0x" + trimmed.substring(offset, offset + 2), context);
                 if(val<10){
                     decimal.append('0').append(val);
                 } else{
@@ -72,7 +74,7 @@ public class BigIntegerConverter implements PropertyConverter<BigInteger>{
                     LOG.finest("Invalid Hex-Byte-String: " + trimmed);
                     return null;
                 }
-                byte val = byteConverter.convert("0x" + trimmed.substring(offset, offset + 2));
+                byte val = byteConverter.convert("0x" + trimmed.substring(offset, offset + 2), context);
                 if(val<10){
                     decimal.append('0').append(val);
                 } else{

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
index cf62256..d0f596d 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -32,7 +33,8 @@ public class BooleanConverter implements PropertyConverter<Boolean> {
     private Logger LOG = Logger.getLogger(getClass().getName());
 
     @Override
-    public Boolean convert(String value) {
+    public Boolean convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "yes (ignore case)", "y (ignore case)", "true (ignore case)", "t (ignore case)", "no (ignore case)", "n (ignore case)", "false (ignore case)", "f (ignore case)");
         String ignoreCaseValue = Objects.requireNonNull(value)
                                         .trim()
                                         .toLowerCase(Locale.ENGLISH);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
index 0d4652d..ed193d8 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -47,7 +48,8 @@ public class ByteConverter implements PropertyConverter<Byte>{
     private Logger LOG = Logger.getLogger(getClass().getName());
 
     @Override
-    public Byte convert(String value) {
+    public Byte convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(),"<byte>", "MIN_VALUE", "MIN", "MAX_VALUE", "MAX");
         String trimmed = Objects.requireNonNull(value).trim();
         switch(trimmed.toUpperCase(Locale.ENGLISH)){
             case "MIN_VALUE":

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
index d905c39..dd6f557 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/CharConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Objects;
@@ -38,7 +39,8 @@ public class CharConverter implements PropertyConverter<Character>{
     private static final Logger LOG = Logger.getLogger(CharConverter.class.getName());
 
     @Override
-    public Character convert(String value) {
+    public Character convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(),"\\'<char>\\'", "<char>", "<charNum>");
         String trimmed = Objects.requireNonNull(value).trim();
         if(trimmed.isEmpty()){
             return null;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
index 25bf479..8fd3cb8 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Objects;
@@ -36,7 +37,8 @@ public class ClassConverter implements PropertyConverter<Class<?>>{
     private Logger LOG = Logger.getLogger(getClass().getName());
 
     @Override
-    public Class<?> convert(String value) {
+    public Class<?> convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(),"<fullyQualifiedClassName>");
         String trimmed = Objects.requireNonNull(value).trim();
         try{
             return Class.forName(trimmed, false, Thread.currentThread().getContextClassLoader());

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
index fbf7f25..50fded7 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/CurrencyConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Currency;
@@ -40,7 +41,8 @@ public class CurrencyConverter implements PropertyConverter<Currency> {
     private static final Logger LOG = Logger.getLogger(CurrencyConverter.class.getName());
 
     @Override
-    public Currency convert(String value) {
+    public Currency convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<currencyCode>, using Locale.ENGLISH", "<numericValue>", "<locale>");
         String trimmed = Objects.requireNonNull(value).trim();
         try {
             return Currency.getInstance(trimmed.toUpperCase(Locale.ENGLISH));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
index 82d673e..b843d91 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/DoubleConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -45,7 +46,8 @@ public class DoubleConverter implements PropertyConverter<Double> {
     private LongConverter integerConverter = new LongConverter();
 
     @Override
-    public Double convert(String value) {
+    public Double convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<double>", "MIN", "MIN_VALUE", "MAX", "MAX_VALUE", "POSITIVE_INFINITY", "NEGATIVE_INFINITY", "NAN");
         String trimmed = Objects.requireNonNull(value).trim();
         switch (trimmed.toUpperCase(Locale.ENGLISH)) {
             case "POSITIVE_INFINITY":
@@ -68,7 +70,7 @@ public class DoubleConverter implements PropertyConverter<Double> {
                     LOG.finest("Parsing of double as floating number failed, trying parsing integral" +
                             " number/hex instead...");
                 }
-                Long val = integerConverter.convert(trimmed);
+                Long val = integerConverter.convert(trimmed, context);
                 if(val!=null){
                     return val.doubleValue();
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
index 1a05a7a..1cf68fe 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/EnumConverter.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.core.internal.converters;
 
 import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.lang.reflect.InvocationTargetException;
@@ -50,7 +51,8 @@ public class EnumConverter<T> implements PropertyConverter<T> {
     }
 
     @Override
-    public T convert(String value) {
+    public T convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(),"<enumValue>");
         try {
             return (T) factory.invoke(null, value);
         } catch (InvocationTargetException | IllegalAccessException e) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
index 0485e68..1cbb273 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/FloatConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -45,7 +46,8 @@ public class FloatConverter implements PropertyConverter<Float> {
     private IntegerConverter integerConverter = new IntegerConverter();
 
     @Override
-    public Float convert(String value) {
+    public Float convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<float>", "MIN", "MIN_VALUE", "MAX", "MAX_VALUE", "POSITIVE_INFINITY", "NEGATIVE_INFINITY", "NAN");
         String trimmed = Objects.requireNonNull(value).trim();
         switch(trimmed.toUpperCase(Locale.ENGLISH)){
             case "POSITIVE_INFINITY":
@@ -68,7 +70,7 @@ public class FloatConverter implements PropertyConverter<Float> {
                     LOG.finest("Parsing of float as floating number failed, trying parsing integral" +
                             " number/hex instead...");
                 }
-                Integer val = integerConverter.convert(trimmed);
+                Integer val = integerConverter.convert(trimmed, context);
                 if(val!=null) {
                     return val.floatValue();
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
index 64eba48..313cb63 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/IntegerConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -49,7 +50,8 @@ public class IntegerConverter implements PropertyConverter<Integer>{
     private static final Logger LOG = Logger.getLogger(IntegerConverter.class.getName());
 
     @Override
-    public Integer convert(String value) {
+    public Integer convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<int>", "MIN_VALUE", "MIN", "MAX_VALUE", "MAX");
         String trimmed = Objects.requireNonNull(value).trim();
         switch(trimmed.toUpperCase(Locale.ENGLISH)){
             case "MIN_VALUE":

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
index c81219f..11cda90 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/LongConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -46,9 +47,10 @@ public class LongConverter implements PropertyConverter<Long>{
     private static final Logger LOGGER = Logger.getLogger(LongConverter.class.getName());
 
     @Override
-    public Long convert(String value) {
+    public Long convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<long>", "MIN", "MIN_VALUE", "MAX", "MAX_VALUE");
 
-            String trimmed = Objects.requireNonNull(value).trim();
+        String trimmed = Objects.requireNonNull(value).trim();
             switch (trimmed.toUpperCase(Locale.ENGLISH)) {
                 case "MIN_VALUE":
                 case "MIN":

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
index acfaae1..83fd3c0 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/NumberConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.math.BigDecimal;
@@ -42,7 +43,10 @@ public class NumberConverter implements PropertyConverter<Number>{
     private LongConverter longConverter = new LongConverter();
 
     @Override
-    public Number convert(String value) {
+    public Number convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<double>, <long>", "0x (hex)", "0X... (hex)", "POSITIVE_INFINITY",
+                "NEGATIVE_INFINITY", "NAN");
+
         String trimmed = Objects.requireNonNull(value).trim();
         switch(trimmed.toUpperCase(Locale.ENGLISH)) {
             case "POSITIVE_INFINITY":
@@ -52,7 +56,7 @@ public class NumberConverter implements PropertyConverter<Number>{
             case "NAN":
                 return Double.NaN;
             default:
-                Long lVal = longConverter.convert(trimmed);
+                Long lVal = longConverter.convert(trimmed, context);
                 if (lVal != null) {
                     return lVal;
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
index e9ab6da..dd9ebdd 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/ShortConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.util.Locale;
@@ -47,7 +48,8 @@ public class ShortConverter implements PropertyConverter<Short>{
     private static final Logger LOG = Logger.getLogger(ShortConverter.class.getName());
 
     @Override
-    public Short convert(String value) {
+    public Short convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "short", "MIN", "MIN_VALUE", "MAX", "MAX_VALUE");
         String trimmed = Objects.requireNonNull(value).trim();
         switch(trimmed.toUpperCase(Locale.ENGLISH)){
             case "MIN_VALUE":

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
index 749c80c..74b1337 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.net.URI;
@@ -33,7 +34,8 @@ public class URIConverter implements PropertyConverter<URI> {
     private Logger LOG = Logger.getLogger(getClass().getName());
 
     @Override
-    public URI convert(String value) {
+    public URI convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(), "<uri> -> new URI(uri)");
         String trimmed = Objects.requireNonNull(value).trim();
         try {
             return new URI(trimmed);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java b/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
index 34788c0..4125c8a 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.net.URL;
@@ -33,7 +34,8 @@ public class URLConverter implements PropertyConverter<URL> {
     private Logger LOG = Logger.getLogger(getClass().getName());
 
     @Override
-    public URL convert(String value) {
+    public URL convert(String value, ConversionContext context) {
+        context.addSupportedFormats(getClass(),"<URL>");
         String trimmed = Objects.requireNonNull(value).trim();
         try {
             return new URL(trimmed);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/test/java/org/apache/tamaya/core/internal/CTestConverter.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/internal/CTestConverter.java b/core/src/test/java/org/apache/tamaya/core/internal/CTestConverter.java
index 62b8c9d..7ee2a35 100644
--- a/core/src/test/java/org/apache/tamaya/core/internal/CTestConverter.java
+++ b/core/src/test/java/org/apache/tamaya/core/internal/CTestConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.internal;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 /**
@@ -25,7 +26,7 @@ import org.apache.tamaya.spi.PropertyConverter;
  */
 public class CTestConverter implements PropertyConverter<C>{
     @Override
-    public C convert(String value) {
+    public C convert(String value, ConversionContext context) {
         return new C(value);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java b/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
index d8ca277..cda216f 100644
--- a/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
+++ b/core/src/test/java/org/apache/tamaya/core/internal/PropertyConverterManagerTest.java
@@ -19,6 +19,8 @@
 package org.apache.tamaya.core.internal;
 
 
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.TypeLiteral;
 import org.junit.Test;
@@ -31,6 +33,10 @@ import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
 
 public class PropertyConverterManagerTest {
+
+    private ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder(ConfigurationProvider.getConfiguration(),
+            "someKey").build();
+
     @Test
     public void customTypeWithFactoryMethodOfIsRecognizedAsSupported() {
         PropertyConverterManager manager = new PropertyConverterManager();
@@ -50,7 +56,7 @@ public class PropertyConverterManagerTest {
 
         PropertyConverter<MyType> converter = converters.get(0);
 
-        Object result = converter.convert("IN");
+        Object result = converter.convert("IN", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(MyType.class));
@@ -64,7 +70,7 @@ public class PropertyConverterManagerTest {
         assertThat(converters, hasSize(1));
 
         PropertyConverter<C> converter = converters.get(0);
-        C result = converter.convert("testDirectConverterMapping");
+        C result = converter.convert("testDirectConverterMapping", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(C.class));
@@ -80,7 +86,7 @@ public class PropertyConverterManagerTest {
         assertThat(converters, hasSize(1));
 
         PropertyConverter<B> converter = converters.get(0);
-        B result = converter.convert("testDirectSuperclassConverterMapping");
+        B result = converter.convert("testDirectSuperclassConverterMapping", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(C.class));
@@ -104,7 +110,7 @@ public class PropertyConverterManagerTest {
         assertThat(converters, hasSize(1));
 
         PropertyConverter<A> converter = converters.get(0);
-        A result = converter.convert("testTransitiveSuperclassConverterMapping");
+        A result = converter.convert("testTransitiveSuperclassConverterMapping", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(C.class));
@@ -118,7 +124,7 @@ public class PropertyConverterManagerTest {
         assertThat(converters, hasSize(1));
 
         PropertyConverter<Readable> converter = converters.get(0);
-        Readable result = converter.convert("testDirectInterfaceMapping");
+        Readable result = converter.convert("testDirectInterfaceMapping", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(C.class));
@@ -132,7 +138,7 @@ public class PropertyConverterManagerTest {
         assertThat(converters, hasSize(1));
 
         PropertyConverter<Runnable> converter = converters.get(0);
-        Runnable result = converter.convert("testTransitiveInterfaceMapping1");
+        Runnable result = converter.convert("testTransitiveInterfaceMapping1", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(C.class));
@@ -146,7 +152,7 @@ public class PropertyConverterManagerTest {
         assertThat(converters, hasSize(1));
 
         PropertyConverter<AutoCloseable> converter = converters.get(0);
-        AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2");
+        AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2", DUMMY_CONTEXT);
 
         assertThat(result, notNullValue());
         assertThat(result, instanceOf(C.class));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java b/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
index be9e61a..f3d66d1 100644
--- a/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
+++ b/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tamaya.core.internal.converters;
 
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.ConversionContext;
 import org.junit.Test;
 
 import java.math.RoundingMode;
@@ -32,23 +34,26 @@ public class EnumConverterTest {
 
     private EnumConverter testConverter = new EnumConverter(RoundingMode.class);
 
+    private ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder(ConfigurationProvider.getConfiguration(), "someKey").build();
+
     @Test
     public void testConvert() {
-        assertEquals(testConverter.convert(RoundingMode.CEILING.toString()), RoundingMode.CEILING);
+        assertEquals(testConverter.convert(RoundingMode.CEILING.toString(),
+                DUMMY_CONTEXT), RoundingMode.CEILING);
     }
 
     @Test
     public void testConvert_LowerCase() {
-        assertEquals(testConverter.convert("ceiling"), RoundingMode.CEILING);
+        assertEquals(testConverter.convert("ceiling", DUMMY_CONTEXT), RoundingMode.CEILING);
     }
 
     @Test
     public void testConvert_MixedCase()  {
-        assertEquals(testConverter.convert("CeiLinG"), RoundingMode.CEILING);
+        assertEquals(testConverter.convert("CeiLinG", DUMMY_CONTEXT), RoundingMode.CEILING);
     }
 
     @Test
     public void testConvert_OtherValue() {
-        assertNull(testConverter.convert("fooBars"));
+        assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
index 0f938d0..5a8abcd 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
@@ -24,6 +24,7 @@ import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
 import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
@@ -176,9 +177,10 @@ public class DefaultConfiguration implements Configuration {
     protected <T> T convertValue(String key, String value, TypeLiteral<T> type) {
         if (value != null) {
             List<PropertyConverter<T>> converters = configurationContext.getPropertyConverters(type);
+            ConversionContext context = new ConversionContext.Builder(this, key).setTargetType(type).build();
             for (PropertyConverter<T> converter : converters) {
                 try {
-                    T t = converter.convert(value);
+                    T t = converter.convert(value, context);
                     if (t != null) {
                         return t;
                     }
@@ -186,7 +188,8 @@ public class DefaultConfiguration implements Configuration {
                     LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value, e);
                 }
             }
-            throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key);
+            throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
+            ", supported formats: "+context.getSupportedFormats());
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
index ffab266..3392818 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.spisupport;
 
 import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 
 import java.lang.reflect.InvocationTargetException;
@@ -51,7 +52,7 @@ public class EnumConverter<T> implements PropertyConverter<T> {
     }
 
     @Override
-    public T convert(String value) {
+    public T convert(String value, ConversionContext context) {
         try {
             return (T) factory.invoke(null, value);
         } catch (InvocationTargetException | IllegalAccessException e) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a037268a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
index 28ea65f..a349547 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.spisupport;
 
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.spi.ServiceContextManager;
 
@@ -369,7 +370,7 @@ public class PropertyConverterManager {
         if (factoryMethod != null) {
             converter = new PropertyConverter<T>() {
                 @Override
-                public T convert(String value) {
+                public T convert(String value, ConversionContext context) {
                     try {
                         if (!Modifier.isStatic(factoryMethod.getModifiers())) {
                             throw new ConfigException(factoryMethod.toGenericString() +
@@ -395,7 +396,7 @@ public class PropertyConverterManager {
                 final Constructor<T> constr = targetType.getRawType().getDeclaredConstructor(String.class);
                 converter = new PropertyConverter<T>() {
                     @Override
-                    public T convert(String value) {
+                    public T convert(String value, ConversionContext context) {
                         try {
                             constr.setAccessible(true);
                             return constr.newInstance(value);


Mime
View raw message