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 2014/12/20 23:02:09 UTC
incubator-tamaya git commit: TAMAYA-8: Enhanced javadocs for
AggregationPolicy,
Codec and Codecs TAMAYA-30: Renamed useless method name in Codecs
Repository: incubator-tamaya
Updated Branches:
refs/heads/master cf42a29b7 -> 1db383ffc
TAMAYA-8: Enhanced javadocs for AggregationPolicy, Codec and Codecs
TAMAYA-30: Renamed useless method name in Codecs
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/1db383ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/1db383ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/1db383ff
Branch: refs/heads/master
Commit: 1db383ffc54265cde9c4edd4b08581e83fe593eb
Parents: cf42a29
Author: anatole <an...@apache.org>
Authored: Sat Dec 20 23:01:59 2014 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Dec 20 23:01:59 2014 +0100
----------------------------------------------------------------------
.../org/apache/tamaya/AggregationPolicy.java | 18 +++++++++++++++++-
api/src/main/java/org/apache/tamaya/Codec.java | 10 ++++++----
api/src/main/java/org/apache/tamaya/Codecs.java | 19 ++++++++++---------
3 files changed, 33 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/1db383ff/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/AggregationPolicy.java b/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
index efb79ef..c0f7cc0 100644
--- a/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
+++ b/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
@@ -21,7 +21,23 @@ package org.apache.tamaya;
import java.util.logging.Logger;
/**
- * Policy that defines how the different aggregates should be combined.
+ * Policy that defines how the different configurations/property sources should be aggregated.
+ * This is done by a mapping function defined as follows:
+ * <pre>
+ * function f(key, value1, value2) -> result
+ *
+ * whereas
+ *
+ * key = the fully qualified property key,
+ * value1 = the value from the first configuration/property source (can be null)
+ * value2 = the value from the second configuration/property source (can be null)
+ *
+ * result = the value to be used in the aggregation, or null, which removed the
+ * key from the result.
+ * </pre>
+ *
+ * Of course, during this evaluation step additional actions can be taken, e.g. refer to #LOG_ERROR, which
+ * ignores duplicate entries, but also logs the conflict on severe/error level.
*/
public interface AggregationPolicy {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/1db383ff/api/src/main/java/org/apache/tamaya/Codec.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Codec.java b/api/src/main/java/org/apache/tamaya/Codec.java
index 55b1684..4afaacb 100644
--- a/api/src/main/java/org/apache/tamaya/Codec.java
+++ b/api/src/main/java/org/apache/tamaya/Codec.java
@@ -23,9 +23,11 @@ import org.apache.tamaya.annotation.WithCodec;
/**
* Interface for an codec that converts a configured String into something else and vice versa.
- * This is typically used for implementing type conversion fromMap String to a certain target
- * type current the configured property, e.g. multivalued types, complex subtypes or subconfigurations
- * abd collection types.
+ * This is used for implementing type conversion from a property (String) to a certain target
+ * type. Hereby the target type can be multivalued (eg eollections), complex or even contain
+ * full subconfigurations, if needed. The operation converting from a type T to a String can be
+ * used by mutable configuration/property sources, when applying a {@link org.apache.tamaya.ConfigChangeSet}
+ * to render the correct String representation of a entry changed.
*/
public interface Codec<T>{
@@ -86,7 +88,7 @@ public interface Codec<T>{
* instantiated.
*/
public static <T> Codec<T> getInstance(Class<T> targetType, WithCodec annotation){
- return Codecs.getAdapter(targetType, annotation);
+ return Codecs.getCodec(targetType, annotation);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/1db383ff/api/src/main/java/org/apache/tamaya/Codecs.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Codecs.java b/api/src/main/java/org/apache/tamaya/Codecs.java
index 85657d0..444c7c8 100644
--- a/api/src/main/java/org/apache/tamaya/Codecs.java
+++ b/api/src/main/java/org/apache/tamaya/Codecs.java
@@ -24,7 +24,8 @@ import org.apache.tamaya.spi.ServiceContext;
/**
* Singleton manager that provides {@link Codec} instance, usable for converting String
- * based configuration entries into any other target types.
+ * based configuration entries into any other target types and vice versa.
+ * @see org.apache.tamaya.Codec
*/
final class Codecs {
@@ -34,7 +35,7 @@ final class Codecs {
private Codecs(){}
/**
- * Registers a new PropertyAdapter for the given target type, hereby replacing any existing adapter for
+ * Registers a new {@link Codec} for the given target type, hereby replacing any existing adapter for
* this type.
* @param targetType The target class, not null.
* @param adapter The adapter, not null.
@@ -46,7 +47,7 @@ final class Codecs {
}
/**
- * Get an adapter converting to the given target type.
+ * Checks if a {@link Codec} for given target type is available.
* @param targetType the target type class
* @return true, if the given target type is supported.
*/
@@ -55,27 +56,27 @@ final class Codecs {
}
/**
- * Get an adapter converting to the given target type.
+ * Get an {@link Codec} converting to and from the given target type.
* @param targetType the target type class
* @param <T> the target type
- * @return the corresponding adapter, never null.
+ * @return the corresponding {@link Codec}, never null.
* @throws ConfigException if the target type is not supported.
*/
public static <T> Codec<T> getCodec(Class<T> targetType){
- return getAdapter(targetType, null);
+ return getCodec(targetType, null);
}
/**
- * Get an adapter converting to the given target type.
+ * Get an {@link Codec} converting to the given target type.
* @param targetType the target type class
* @param annotation the {@link org.apache.tamaya.annotation.WithCodec} annotation, or null. If the annotation is not null and
* defines an overriding adapter, this instance is created and returned.
* @param <T> the target type
- * @return the corresponding adapter, never null.
+ * @return the corresponding {@link Codec}, never null.
* @throws ConfigException if the target type is not supported, or the overriding adapter cannot be
* instantiated.
*/
- public static <T> Codec<T> getAdapter(Class<T> targetType, WithCodec annotation){
+ public static <T> Codec<T> getCodec(Class<T> targetType, WithCodec annotation){
return ServiceContext.getInstance().getSingleton(CodecsSingletonSpi.class).getCodec(targetType, annotation);
}