tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [1/2] incubator-tamaya git commit: add a way to register and lookup Converters
Date Tue, 30 Dec 2014 10:52:19 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 4c95c9b9c -> 2d508f3db


add a way to register and lookup Converters


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

Branch: refs/heads/master
Commit: 251432b469d6b6d44749c161ba050e1f4e20fc59
Parents: 4c95c9b
Author: Mark Struberg <struberg@apache.org>
Authored: Tue Dec 30 11:47:13 2014 +0100
Committer: Mark Struberg <struberg@apache.org>
Committed: Tue Dec 30 11:47:13 2014 +0100

----------------------------------------------------------------------
 .../apache/tamaya/spi/ConfigurationContext.java | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/251432b4/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
index 932c21b..7cfadc7 100644
--- a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
+++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.spi;
 
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Central SPI for programmatically dealing with the setup of the configuration system.
@@ -48,4 +49,45 @@ public interface ConfigurationContext {
      */
     List<PropertySource> getPropertySources();
 
+
+    /**
+     * This method can be used for programmatically adding {@link PropertyConverter}s.
+     * It is not needed for normal 'usage' by end users, but only for Extension Developers!
+     *
+     * @param typeToConvert the type which the converter is for
+     * @param propertyConverter the PropertyConverters to add for this type
+     */
+    <T> void addPropertyConverter(Class<T> typeToConvert, PropertyConverter<T>
propertyConverter);
+
+    /**
+     * <p>
+     * This method returns the Map of registered PropertyConverters
+     * per type.
+     * The List for each type is ordered via their {@link javax.annotation.Priority}.
+     * </p>
+     *
+     * <p>
+     * PropertyConverters with a lower Priority come first. The PropertyConverter with the
+     * highest Priority comes last.
+     * If two PropertyConverter have the same ordinal number they will get sorted
+     * using their class name just to ensure the user at least gets the same ordering
+     * after a JVM restart.
+     * </p>
+     *
+     * <p>
+     * The scenario could be like:
+     * <pre>
+     *  {
+     *      Date.class -> {StandardDateConverter, TimezoneDateConverter, MyCustomDateConverter
}
+     *      Boolean.class -> {StandardBooleanConverter, FrenchBooleanConverter}
+     *  }
+     * </pre>
+     * </p>
+     *
+     * TODO: we need to define in which order the converters will be used later!
+     *
+     * @return map with sorted list of registered PropertySources per type.
+     */
+    Map<Class<?>, List<PropertyConverter<?>>> getPropertyConverters();
+
 }


Mime
View raw message