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 15:31:08 UTC
[3/5] incubator-tamaya git commit: TAMAYA-8: Added some javadocs.
TAMAYA-30: Added Codecs TAMAYA 31: Reduced number of annotations TAMAYA 34:
Added Config overrides.
TAMAYA-8: Added some javadocs.
TAMAYA-30: Added Codecs
TAMAYA 31: Reduced number of annotations
TAMAYA 34: Added Config overrides.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c9e62e24
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c9e62e24
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c9e62e24
Branch: refs/heads/master
Commit: c9e62e24f4e71647acb94aec1197a4330146e3cd
Parents: eb59d86
Author: anatole <an...@apache.org>
Authored: Sat Dec 20 15:22:43 2014 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Dec 20 15:22:43 2014 +0100
----------------------------------------------------------------------
.../org/apache/tamaya/AggregationPolicy.java | 16 +-
api/src/main/java/org/apache/tamaya/Codec.java | 92 ++++++++++
api/src/main/java/org/apache/tamaya/Codecs.java | 82 +++++++++
.../apache/tamaya/ConfigChangeSetBuilder.java | 54 +++---
.../java/org/apache/tamaya/Configuration.java | 87 ++++------
.../org/apache/tamaya/ConfigurationManager.java | 45 ++---
.../java/org/apache/tamaya/Environment.java | 2 +-
.../main/java/org/apache/tamaya/MetaInfo.java | 68 +++++++-
.../java/org/apache/tamaya/MetaInfoBuilder.java | 47 +----
.../java/org/apache/tamaya/PropertyAdapter.java | 87 ----------
.../org/apache/tamaya/PropertyAdapters.java | 82 ---------
.../java/org/apache/tamaya/PropertySource.java | 6 +-
.../tamaya/annotation/ConfiguredProperties.java | 4 +-
.../tamaya/annotation/ConfiguredProperty.java | 34 ++--
.../apache/tamaya/annotation/DefaultValue.java | 6 +-
.../apache/tamaya/annotation/LoadPolicy.java | 8 +-
.../org/apache/tamaya/annotation/WithCodec.java | 44 +++++
.../apache/tamaya/annotation/WithConfig.java | 41 -----
.../tamaya/annotation/WithConfigOperator.java | 4 +-
.../tamaya/annotation/WithPropertyAdapter.java | 44 -----
.../apache/tamaya/spi/CodecsSingletonSpi.java | 89 ++++++++++
.../spi/ConfigurationManagerSingletonSpi.java | 37 ++--
.../java/org/apache/tamaya/spi/Orderable.java | 4 +-
.../spi/PropertyAdaptersSingletonSpi.java | 63 -------
.../test/java/annottext/AnnotatedConfig.java | 10 +-
.../java/annottext/AnnotatedFullConfig.java | 10 +-
.../tamaya/TestConfigServiceSingletonSpi.java | 37 ++--
.../TestPropertyAdaptersSingletonSpi.java | 69 ++++----
.../org.apache.tamaya.spi.CodecsSingletonSpi | 19 +++
...ache.tamaya.spi.PropertyAdaptersSingletonSpi | 19 ---
.../core/config/AbstractConfiguration.java | 4 +-
.../tamaya/core/config/ConfigFunctions.java | 2 +-
.../core/config/ConfigurationBuilder.java | 4 +-
.../tamaya/core/config/MappedConfiguration.java | 6 +-
.../tamaya/core/env/EnvironmentBuilder.java | 2 +-
.../org/apache/tamaya/core/internal/Utils.java | 4 +-
.../config/ConfigTemplateInvocationHandler.java | 52 ------
...DefaultConfigurationManagerSingletonSpi.java | 89 +++++-----
.../internal/el/DefaultExpressionEvaluator.java | 12 +-
.../el/EnvironmentPropertyResolver.java | 5 +-
.../internal/el/SystemPropertyResolver.java | 4 +-
.../inject/ConfigTemplateInvocationHandler.java | 65 +++++++
.../internal/inject/ConfigurationInjector.java | 25 ++-
.../core/internal/inject/ConfiguredField.java | 157 ++++-------------
.../inject/ConfiguredInstancesManager.java | 85 ----------
.../core/internal/inject/ConfiguredMethod.java | 141 +++------------
.../core/internal/inject/ConfiguredType.java | 100 ++++++-----
.../core/internal/inject/InjectionUtils.java | 170 +++++++++++++++++++
.../properties/DefaultCodecsSingletonSpi.java | 162 ++++++++++++++++++
.../DefaultPropertyAdaptersSingletonSpi.java | 100 -----------
.../internal/resources/io/AntPathMatcher.java | 8 +-
.../core/internal/resources/io/ClassUtils.java | 36 ++--
.../resources/io/DefaultResourceLoader.java | 2 +-
.../resources/io/FileSystemResource.java | 4 +-
.../core/internal/resources/io/StringUtils.java | 16 +-
.../internal/resources/io/WritableResource.java | 2 +-
.../core/properties/AbstractPropertySource.java | 2 +-
.../properties/AggregatedPropertySource.java | 7 +-
.../properties/ContextualPropertySource.java | 4 +-
.../core/properties/FilteredPropertySource.java | 5 +-
.../core/properties/MapBasedPropertySource.java | 2 +-
.../core/properties/PropertySourceBuilder.java | 6 +-
.../properties/ReplacingPropertySource.java | 4 +-
.../properties/SubtractingPropertySource.java | 5 +-
.../apache/tamaya/core/resource/Resource.java | 2 +-
.../tamaya/core/spi/AdapterProviderSpi.java | 7 +-
.../tamaya/core/spi/ExpressionEvaluator.java | 15 +-
.../tamaya/core/spi/ExpressionResolver.java | 7 +-
.../tamaya/core/spi/PropertyAdapterService.java | 30 ++--
.../org.apache.tamaya.spi.CodecsSingletonSpi | 19 +++
...ache.tamaya.spi.PropertyAdaptersSingletonSpi | 19 ---
.../tamaya/core/config/MutableConfigTest.java | 3 +-
.../internal/MutableTestConfigProvider.java | 2 +-
.../tamaya/internal/TestConfigProvider.java | 14 +-
.../samples/annotations/ConfigTemplate.java | 9 +-
.../samples/annotations/ConfiguredClass.java | 21 +--
.../samples/annotations/ConfiguredTest.java | 10 +-
.../apache/tamaya/ucs/UC1ReadProperties.java | 10 +-
.../apache/tamaya/ucs/UC2CombineProperties.java | 2 +-
.../tamaya/integration/cdi/ConfiguredClass.java | 14 +-
.../integration/cdi/TestConfigProvider.java | 14 +-
81 files changed, 1347 insertions(+), 1353 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/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 67d644e..efb79ef 100644
--- a/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
+++ b/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
@@ -28,9 +28,9 @@ public interface AggregationPolicy {
/**
* Method which decides how keys/values are aggregated.
* @param key the key current the entry, must not be {@code null}.
- * @param currentValue the current value, or {@code null}.
- * @param newValue the new value, never {@code null}.
- * @return the target value to be used in the resulting property set, or null, to remove the property.
+ * @param currentValue the current keys, or {@code null}.
+ * @param newValue the new keys, never {@code null}.
+ * @return the target keys to be used in the resulting property set, or null, to remove the property.
*/
public String aggregate(String key, String currentValue, String newValue);
@@ -54,7 +54,7 @@ public interface AggregationPolicy {
public static final AggregationPolicy EXCEPTION =
(String key, String value, String newValue) -> {
if(value!=null && newValue!=null && !value.equals(newValue)){
- throw new ConfigException("Conflicting values encountered key="+key+", value="+value+", newValue="+newValue);
+ throw new ConfigException("Conflicting values encountered key="+key+", keys="+value+", newValue="+newValue);
}
return newValue;
};
@@ -66,7 +66,7 @@ public interface AggregationPolicy {
(String key, String value, String newValue) -> {
if(value!=null && newValue!=null && !value.equals(newValue)){
Logger.getLogger(AggregationPolicy.class.getName())
- .severe(() -> "Conflicting values encountered key=" + key + ", value=" + value + ", newValue=" + newValue);
+ .severe(() -> "Conflicting values encountered key=" + key + ", keys=" + value + ", newValue=" + newValue);
return value;
}
return newValue;
@@ -79,7 +79,7 @@ public interface AggregationPolicy {
(String key, String value, String newValue) -> {
if(value!=null && newValue!=null && !value.equals(newValue)){
Logger.getLogger(AggregationPolicy.class.getName())
- .warning(() -> "Conflicting values encountered key=" + key + ", value=" + value + ", newValue=" + newValue);
+ .warning(() -> "Conflicting values encountered key=" + key + ", keys=" + value + ", newValue=" + newValue);
return value;
}
return newValue;
@@ -92,7 +92,7 @@ public interface AggregationPolicy {
(String key, String value, String newValue) -> {
if(value!=null && newValue!=null && !value.equals(newValue)){
Logger.getLogger(AggregationPolicy.class.getName())
- .info(() -> "Conflicting values encountered key=" + key + ", value=" + value + ", newValue=" + newValue);
+ .info(() -> "Conflicting values encountered key=" + key + ", keys=" + value + ", newValue=" + newValue);
return value;
}
return newValue;
@@ -105,7 +105,7 @@ public interface AggregationPolicy {
(String key, String value, String newValue) -> {
if(value!=null && newValue!=null && !value.equals(newValue)){
Logger.getLogger(AggregationPolicy.class.getName())
- .finest(() -> "Conflicting values encountered key=" + key + ", value=" + value + ", newValue=" + newValue);
+ .finest(() -> "Conflicting values encountered key=" + key + ", keys=" + value + ", newValue=" + newValue);
return value;
}
return newValue;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/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
new file mode 100644
index 0000000..55b1684
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/Codec.java
@@ -0,0 +1,92 @@
+/*
+ * 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;
+
+
+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.
+ */
+public interface Codec<T>{
+
+ /**
+ * Adapt the given configuration keys to the required target type.
+ * @param value the configuration keys
+ * @return adapted keys
+ */
+ T deserialize(String value);
+
+ /**
+ * Adapt the given configuration keys to the required target type.
+ * @param value the configuration keys
+ * @return adapted keys
+ */
+ String serialize(T value);
+
+ /**
+ * Registers a new PropertyAdapter 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.
+ * @param <T> The target type
+ * @return any adapter replaced with the new adapter, or null.
+ */
+ public static <T> Codec<T> register(Class<T> targetType, Codec<T> adapter){
+ return Codecs.register(targetType, adapter);
+ }
+
+ /**
+ * Get an adapter converting to the given target type.
+ * @param targetType the target type class
+ * @return true, if the given target type is supported.
+ */
+ public static boolean isTargetTypeSupported(Class<?> targetType){
+ return Codecs.isTargetTypeSupported(targetType);
+ }
+
+ /**
+ * Get an adapter converting to the given target type.
+ * @param targetType the target type class
+ * @param <T> the target type
+ * @return the corresponding adapter, never null.
+ * @throws ConfigException if the target type is not supported.
+ */
+ public static <T> Codec<T> getInstance(Class<T> targetType){
+ return Codecs.getCodec(targetType);
+ }
+
+ /**
+ * Get an adapter 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.
+ * @throws ConfigException if the target type is not supported, or the overriding adapter cannot be
+ * instantiated.
+ */
+ public static <T> Codec<T> getInstance(Class<T> targetType, WithCodec annotation){
+ return Codecs.getAdapter(targetType, annotation);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/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
new file mode 100644
index 0000000..85657d0
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/Codecs.java
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+import org.apache.tamaya.annotation.WithCodec;
+import org.apache.tamaya.spi.CodecsSingletonSpi;
+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.
+ */
+final class Codecs {
+
+ /**
+ * Orivate singleton constructor.
+ */
+ private Codecs(){}
+
+ /**
+ * Registers a new PropertyAdapter 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.
+ * @param <T> The target type
+ * @return any adapter replaced with the new adapter, or null.
+ */
+ public static <T> Codec<T> register(Class<T> targetType, Codec<T> adapter){
+ return ServiceContext.getInstance().getSingleton(CodecsSingletonSpi.class).register(targetType, adapter);
+ }
+
+ /**
+ * Get an adapter converting to the given target type.
+ * @param targetType the target type class
+ * @return true, if the given target type is supported.
+ */
+ public static boolean isTargetTypeSupported(Class<?> targetType){
+ return ServiceContext.getInstance().getSingleton(CodecsSingletonSpi.class).isTargetTypeSupported(targetType);
+ }
+
+ /**
+ * Get an adapter converting to the given target type.
+ * @param targetType the target type class
+ * @param <T> the target type
+ * @return the corresponding adapter, never null.
+ * @throws ConfigException if the target type is not supported.
+ */
+ public static <T> Codec<T> getCodec(Class<T> targetType){
+ return getAdapter(targetType, null);
+ }
+
+ /**
+ * Get an adapter 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.
+ * @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){
+ return ServiceContext.getInstance().getSingleton(CodecsSingletonSpi.class).getCodec(targetType, annotation);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java b/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
index f9ba38a..28c1810 100644
--- a/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
@@ -25,7 +25,7 @@ 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 apply the changes to the provider/configuration, including triggering current regarding
+ * version given and applyChanges the changes to the provider/configuration, including triggering current regarding
* change events.
*
* Created by Anatole on 06.09.2014.
@@ -84,6 +84,7 @@ public final class ConfigChangeSetBuilder {
*/
public ConfigChangeSetBuilder addChange(PropertyChangeEvent changeEvent) {
Objects.requireNonNull(changeEvent);
+ // todo consider any codecs
this.delta.put(changeEvent.getPropertyName(), changeEvent);
return this;
}
@@ -102,7 +103,7 @@ public final class ConfigChangeSetBuilder {
/**
* Get the current values, also considering any changes recorded within this change set.
* @param key the key current the entry, not null.
- * @return the value, or null.
+ * @return the keys, or null.
*/
public String get(String key) {
PropertyChangeEvent change = this.delta.get(key);
@@ -135,20 +136,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
- * @return the builder for chaining.
- */
- public ConfigChangeSetBuilder put(String key, String value) {
- this.delta.put(key, new PropertyChangeEvent(this.source, key, this.source.get(key).orElse(null), Objects.requireNonNull(value)));
- return this;
- }
-
- /**
- * Applies the given value.
- * @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, boolean value) {
@@ -157,9 +147,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, byte value) {
@@ -168,9 +158,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, char value) {
@@ -179,9 +169,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, short value) {
@@ -190,9 +180,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, int value) {
@@ -201,9 +191,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, long value) {
@@ -212,9 +202,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, float value) {
@@ -223,9 +213,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, double value) {
@@ -234,9 +224,9 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Applies the given value.
+ * Applies the given keys.
* @param key the key current the entry, not null.
- * @param value the value to be applied, not null.
+ * @param value the keys to be applied, not null.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder put(String key, Object value) {
@@ -249,7 +239,7 @@ public final class ConfigChangeSetBuilder {
* @param changes the changes to be applied, not null.
* @return the builder for chaining.
*/
- public ConfigChangeSetBuilder putAll(Map<String,String> changes) {
+ public ConfigChangeSetBuilder putAll(Map<String,Object> changes) {
changes.forEach((k,v) ->
this.delta.put(k, new PropertyChangeEvent(this.source, k, this.source.get(k).orElse(null), v)));
return this;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/Configuration.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Configuration.java b/api/src/main/java/org/apache/tamaya/Configuration.java
index ac988ac..f3a11c5 100644
--- a/api/src/main/java/org/apache/tamaya/Configuration.java
+++ b/api/src/main/java/org/apache/tamaya/Configuration.java
@@ -44,11 +44,11 @@ import java.util.stream.Collectors;
public interface Configuration extends PropertySource {
/**
- * Get the property value as {@link Boolean}.
+ * Get the property keys as {@link Boolean}.
*
* @param key the property's absolute, or relative path, e.g. {@code
* a/b/c/d.myProperty}.
- * @return the property's value.
+ * @return the property's keys.
*/
default Boolean getBoolean(String key) {
Optional<Boolean> val = get(key, Boolean.class);
@@ -59,11 +59,11 @@ public interface Configuration extends PropertySource {
}
/**
- * Get the property value as {@link Integer}.
+ * Get the property keys as {@link Integer}.
*
* @param key the property's absolute, or relative path, e.g. @code
* a/b/c/d.myProperty}.
- * @return the property's value.
+ * @return the property's keys.
*/
default OptionalInt getInteger(String key){
Optional<Integer> val = get(key, Integer.class);
@@ -75,11 +75,11 @@ public interface Configuration extends PropertySource {
/**
- * Get the property value as {@link Long}.
+ * Get the property keys as {@link Long}.
*
* @param key the property's absolute, or relative path, e.g. @code
* a/b/c/d.myProperty}.
- * @return the property's value.
+ * @return the property's keys.
*/
default OptionalLong getLong(String key){
Optional<Long> val = get(key, Long.class);
@@ -91,11 +91,11 @@ public interface Configuration extends PropertySource {
/**
- * Get the property value as {@link Double}.
+ * Get the property keys as {@link Double}.
*
* @param key the property's absolute, or relative path, e.g. @code
* a/b/c/d.myProperty}.
- * @return the property's value.
+ * @return the property's keys.
* @throws IllegalArgumentException if no such property exists.
*/
default OptionalDouble getDouble(String key){
@@ -109,7 +109,7 @@ public interface Configuration extends PropertySource {
/**
- * Get the property value as type {@code Class<T>}.
+ * Get the property keys as type {@code Class<T>}.
* <p>
* If {@code Class<T>} is not one current
* {@code Boolean, Short, Integer, Long, Float, Double, BigInteger,
@@ -121,33 +121,33 @@ public interface Configuration extends PropertySource {
* a/b/c/d.myProperty}.
* @param adapter the PropertyAdapter to perform the conversion fromMap
* {@link String} to {@code Class<T>}, not {@code null}.
- * @return the property's value.
- * @throws IllegalArgumentException if the value could not be converted to the required target
+ * @return the property's keys.
+ * @throws IllegalArgumentException if the keys could not be converted to the required target
* type, or no such property exists.
*/
- default <T> Optional<T> getAdapted(String key, PropertyAdapter<T> adapter){
+ default <T> Optional<T> getAdapted(String key, Codec<T> adapter){
Optional<String> value = get(key);
if(value.isPresent()) {
- return Optional.ofNullable(adapter.adapt(value.get()));
+ return Optional.ofNullable(adapter.deserialize(value.get()));
}
return Optional.empty();
}
/**
- * Get the property value as type T. This will implicitly require a corresponding {@link
- * PropertyAdapter} to be available that is capable current providing type T
- * fromMap the given String value.
+ * Get the property keys as type T. This will implicitly require a corresponding {@link
+ * Codec} to be available that is capable current providing type T
+ * fromMap the given String keys.
*
* @param key the property's absolute, or relative path, e.g. @code
* a/b/c/d.myProperty}.
* @param type The target type required, not null.
- * @return the property's value.
- * @throws IllegalArgumentException if the value could not be converted to the required target
+ * @return the property's keys.
+ * @throws IllegalArgumentException if the keys could not be converted to the required target
* type.
*/
default <T> Optional<T> get(String key, Class<T> type){
- return getAdapted(key, PropertyAdapters.getAdapter(type));
+ return getAdapted(key, Codecs.getCodec(type));
}
/**
@@ -245,7 +245,7 @@ public interface Configuration extends PropertySource {
}
/**
- * Query some value fromMap a configuration.
+ * Query some keys fromMap a configuration.
*
* @param query the query, never {@code null}.
* @return the result
@@ -255,7 +255,7 @@ public interface Configuration extends PropertySource {
}
/**
- * Field that allows property config to be versioned, meaning that each change on a provider requires this value
+ * Field that allows property config to be versioned, meaning that each change on a provider requires this keys
* to be incremented by one. This can be easily used to implement versioning (and optimistic locking)
* in distributed (remote) usage scenarios.
* @return the version current the current instance, or 'N/A'.
@@ -273,19 +273,6 @@ public interface Configuration extends PropertySource {
return ConfigurationManager.isConfigurationDefined(name);
}
- /**
- * Access a configuration by name.
- *
- * @param name the configuration's name, not null, not empty.
- * @param template the annotated configuration's
- * template interface, not null.
- * @return the corresponding Configuration instance, never null.
- * @throws ConfigException if no such configuration is defined.
- */
- public static <T> T current(String name, Class<T> template){
- return ConfigurationManager.getConfiguration(name, template);
- }
-
/**
* Access a configuration by name.
@@ -313,11 +300,14 @@ public interface Configuration extends PropertySource {
*
* @param type the annotated configuration type (could be an interface or
* a non abstract class), not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @return the corresponding typed Configuration instance, never null.
* @throws ConfigException if the configuration could not be resolved.
*/
- public static <T> T current(Class<T> type){
- return ConfigurationManager.getConfiguration(type);
+ public static <T> T createTemplate(Class<T> type, Configuration... configurations){
+ return ConfigurationManager.createTemplate(type, configurations);
}
/**
@@ -325,32 +315,27 @@ public interface Configuration extends PropertySource {
* entries.
*
* @param instance the instance with configuration annotations, not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @return the corresponding typed Configuration instance, never null.
* @throws ConfigException if the configuration could not be resolved.
*/
- public static void configure(Object instance){
- ConfigurationManager.configure(instance);
- }
-
- /**
- * Evaluate the current expression based on the current configuration valid.
- *
- * @param expression the expression, not null.
- * @return the evaluated config expression.
- */
- public static String evaluateValue(String expression){
- return ConfigurationManager.evaluateValue(expression);
+ public static void configure(Object instance, Configuration... configurations){
+ ConfigurationManager.configure(instance, configurations);
}
/**
* Evaluate the current expression based on the current configuration valid.
*
- * @param config The configuration to be used for evluating, not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @param expression the expression, not null.
* @return the evaluated config expression.
*/
- public static String evaluateValue(Configuration config, String expression){
- return ConfigurationManager.evaluateValue(config, expression);
+ public static String evaluateValue(String expression, Configuration... configurations){
+ return ConfigurationManager.evaluateValue(expression, configurations);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigurationManager.java b/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
index 9915d64..6c3c009 100644
--- a/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
+++ b/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
@@ -47,19 +47,6 @@ final class ConfigurationManager{
return ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).isConfigurationDefined(name);
}
- /**
- * Access a configuration by name.
- *
- * @param name the configuration's name, not null, not empty.
- * @param template the annotated configuration's
- * template interface, not null.
- * @return the corresponding Configuration instance, never null.
- * @throws ConfigException if no such configuration is defined.
- */
- public static <T> T getConfiguration(String name, Class<T> template){
- return ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).getConfiguration(name, template);
- }
-
/**
* Access a configuration by name.
@@ -87,11 +74,14 @@ final class ConfigurationManager{
*
* @param type the annotated configuration type (could be an interface or
* a non abstract class), not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @return the corresponding typed Configuration instance, never null.
* @throws ConfigException if the configuration could not be resolved.
*/
- public static <T> T getConfiguration(Class<T> type){
- return ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).getConfiguration(type);
+ public static <T> T createTemplate(Class<T> type, Configuration... configurations){
+ return ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).createTemplate(type, configurations);
}
/**
@@ -99,32 +89,25 @@ final class ConfigurationManager{
* entries.
*
* @param instance the instance with configuration annotations, not null.
- * @return the corresponding typed Configuration instance, never null.
+ * @param configurations the configurations to be used for evaluating the values for injection into {@code instance}.
+ * If no items are passed, the default configuration is used.
* @throws ConfigException if the configuration could not be resolved.
*/
- public static void configure(Object instance){
- ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).configure(instance);
- }
-
- /**
- * Evaluate the current expression based on the current configuration valid.
- *
- * @param expression the expression, not null.
- * @return the evaluated config expression.
- */
- public static String evaluateValue(String expression){
- return evaluateValue(getConfiguration(), expression);
+ public static void configure(Object instance, Configuration... configurations){
+ ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).configure(instance, configurations);
}
/**
* Evaluate the current expression based on the current configuration valid.
*
- * @param config The configuration to be used for evluating, not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @param expression the expression, not null.
* @return the evaluated config expression.
*/
- public static String evaluateValue(Configuration config, String expression){
- return ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).evaluateValue(config, expression);
+ public static String evaluateValue(String expression, Configuration... configurations){
+ return ServiceContext.getInstance().getSingleton(ConfigurationManagerSingletonSpi.class).evaluateValue(expression, configurations);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/Environment.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Environment.java b/api/src/main/java/org/apache/tamaya/Environment.java
index c52b21e..11e7100 100644
--- a/api/src/main/java/org/apache/tamaya/Environment.java
+++ b/api/src/main/java/org/apache/tamaya/Environment.java
@@ -39,7 +39,7 @@ public interface Environment{
/**
* Access a property.
* @param key the property's key, not null.
- * @return the property's value.
+ * @return the property's keys.
*/
Optional<String> get(String key);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/MetaInfo.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/MetaInfo.java b/api/src/main/java/org/apache/tamaya/MetaInfo.java
index 9dd98fb..e701529 100644
--- a/api/src/main/java/org/apache/tamaya/MetaInfo.java
+++ b/api/src/main/java/org/apache/tamaya/MetaInfo.java
@@ -25,8 +25,16 @@ import java.util.*;
* configuration or some if its entries.
*/
public final class MetaInfo{
- /** The key used for storing the data owner. */
- private static final String OWNER_KEY = "_owner";
+ public static final String TIMESTAMP = "timestamp";
+ public static final String CONTEXT = "context";
+ public static final String NAME = "name";
+ public static final String INFO = "info";
+ public static final String TYPE = "type";
+ public static final String SOURCE = "source";
+ public static final String SOURCE_EXPRESSION = "source-expression";
+
+// /** The key used for storing the data owner. */
+// private static final String OWNER_KEY = "_owner";
/** The meta information data. */
private final Map<String, String> metaInfo = new HashMap<>();
@@ -51,7 +59,7 @@ public final class MetaInfo{
/**
* Access a meta data property.
* @param key the property key, not null.
- * @return the corresponding property value, or null.
+ * @return the corresponding property keys, or null.
*/
public String get(String key){
return this.metaInfo.get(key);
@@ -62,8 +70,56 @@ public final class MetaInfo{
* Get the information about the data owner.
* @return the data owner info, or null.
*/
- public String getOwnerInfo(){
- return this.metaInfo.get(OWNER_KEY);
+ public String getName(){
+ return this.metaInfo.get(NAME);
+ }
+
+ /**
+ * Get the type of configuration.
+ * @return the type, or null.
+ */
+ public String getType(){
+ return this.metaInfo.get(TYPE);
+ }
+
+ /**
+ * Get the info of configuration.
+ * @return the info, or null.
+ */
+ public String getInfo(){
+ return this.metaInfo.get(INFO);
+ }
+
+ /**
+ * Get the source of configuration.
+ * @return the source, or null.
+ */
+ public String getSource(){
+ return this.metaInfo.get(SOURCE);
+ }
+
+ /**
+ * Get the source expression to load thr configuration.
+ * @return the info, or null.
+ */
+ public String getSourceExpression(){
+ return this.metaInfo.get(SOURCE_EXPRESSION);
+ }
+
+ /**
+ * Get the context of configuration.
+ * @return the context, or null.
+ */
+ public String getContext(){
+ return this.metaInfo.get(CONTEXT);
+ }
+
+ /**
+ * Get the context of configuration.
+ * @return the context, or null.
+ */
+ public String getTimestamp(){
+ return this.metaInfo.get(TIMESTAMP);
}
/**
@@ -97,7 +153,7 @@ public final class MetaInfo{
/**
* Helper method to escape "=\\[]".
- * @param val the input value, not null.
+ * @param val the input keys, not null.
* @return the escaped String, not null.
*/
static String escape(String val){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java b/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
index 277f34d..b5433ef 100644
--- a/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
@@ -28,16 +28,6 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public final class MetaInfoBuilder{
- public static final String METAINFO = "_metainfo";
- public static final String TIMESTAMP = "timestamp";
- public static final String CONTEXT = "context";
- public static final String NAME = "name";
- public static final String INFO = "info";
- public static final String TYPE = "type";
- public static final String SOURCE = "source";
- public static final String ENVIRONMENT = "environment";
- public static final String SOURCE_EXPRESSION = "source-expression";
-
Map<String,String> map = new ConcurrentHashMap<>();
private MetaInfoBuilder(MetaInfo metaInfo){
@@ -47,7 +37,7 @@ public final class MetaInfoBuilder{
}
private MetaInfoBuilder(String name){
- this.map.put(NAME, Objects.requireNonNull(name));
+ this.map.put(MetaInfo.NAME, Objects.requireNonNull(name));
}
public static MetaInfoBuilder of(MetaInfo metaInfo){
@@ -62,48 +52,27 @@ public final class MetaInfoBuilder{
return new MetaInfoBuilder("<noname>");
}
- public MetaInfoBuilder withName(String name){
- Objects.requireNonNull(name);
- map.put(NAME, name);
- return this;
- }
-
public MetaInfoBuilder setName(String name){
Objects.requireNonNull(name);
- map.put(NAME, name);
+ map.put(MetaInfo.NAME, name);
return this;
}
public MetaInfoBuilder setType(String type){
Objects.requireNonNull(type);
- map.put(TYPE, type);
+ map.put(MetaInfo.TYPE, type);
return this;
}
public MetaInfoBuilder setInfo(String info){
Objects.requireNonNull(info);
- map.put(INFO, info);
+ map.put(MetaInfo.INFO, info);
return this;
}
public MetaInfoBuilder setSources(String... sources){
Objects.requireNonNull(sources);
- map.put(SOURCE, Arrays.toString(sources));
- return this;
- }
-
- public MetaInfoBuilder setMetaInfo(String key, String metaInfo){
- Objects.requireNonNull(metaInfo);
- Objects.requireNonNull(key);
- map.put(key + '.' + METAINFO, metaInfo);
- return this;
- }
-
- public MetaInfoBuilder setMetaInfo(String metaInfo){
- if(metaInfo!=null){
- Objects.requireNonNull(metaInfo);
- map.put(METAINFO, metaInfo);
- }
+ map.put(MetaInfo.SOURCE, Arrays.toString(sources));
return this;
}
@@ -117,18 +86,18 @@ public final class MetaInfoBuilder{
public MetaInfoBuilder setSourceExpressions(String... sourceExpressions){
Objects.requireNonNull(sourceExpressions);
- map.put(SOURCE_EXPRESSION, Arrays.toString(sourceExpressions));
+ map.put(MetaInfo.SOURCE_EXPRESSION, Arrays.toString(sourceExpressions));
return this;
}
public MetaInfoBuilder setTimestamp(long timestamp){
- map.put(TIMESTAMP, String.valueOf(timestamp));
+ map.put(MetaInfo.TIMESTAMP, String.valueOf(timestamp));
return this;
}
public MetaInfoBuilder setContext(String context){
Objects.requireNonNull(context);
- map.put(CONTEXT, context);
+ map.put(MetaInfo.CONTEXT, context);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapter.java b/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
deleted file mode 100644
index 5ee0eb7..0000000
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
+++ /dev/null
@@ -1,87 +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;
-
-
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
-import org.apache.tamaya.spi.ServiceContext;
-
-/**
- * Interface for an adapter that converts a configured String into something else.
- * This is typically used for implementing type conversion fromMap String to a certain target
- * type current the configured property.
- */
-@FunctionalInterface
-public interface PropertyAdapter<T>{
-
- /**
- * Adapt the given configuration value to the required target type.
- * @param value the configuration value
- * @return adapted value
- */
- T adapt(String value);
-
- /**
- * Registers a new PropertyAdapter 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.
- * @param <T> The target type
- * @return any adapter replaced with the new adapter, or null.
- */
- public static <T> PropertyAdapter<T> register(Class<T> targetType, PropertyAdapter<T> adapter){
- return PropertyAdapters.register(targetType, adapter);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @return true, if the given target type is supported.
- */
- public static boolean isTargetTypeSupported(Class<?> targetType){
- return PropertyAdapters.isTargetTypeSupported(targetType);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @param <T> the target type
- * @return the corresponding adapter, never null.
- * @throws ConfigException if the target type is not supported.
- */
- public static <T> PropertyAdapter<T> getAdapter(Class<T> targetType){
- return PropertyAdapters.getAdapter(targetType);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @param annotation the {@link org.apache.tamaya.annotation.WithPropertyAdapter} 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.
- * @throws ConfigException if the target type is not supported, or the overriding adapter cannot be
- * instantiated.
- */
- public static <T> PropertyAdapter<T> getAdapter(Class<T> targetType, WithPropertyAdapter annotation){
- return PropertyAdapters.getAdapter(targetType, annotation);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
deleted file mode 100644
index 90b29d7..0000000
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
+++ /dev/null
@@ -1,82 +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;
-
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-import org.apache.tamaya.spi.ServiceContext;
-import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
-
-/**
- * Singleton manager that provides {@link PropertyAdapter} instance, usable for converting String
- * based configuration entries into any other target types.
- */
-final class PropertyAdapters{
-
- /**
- * Orivate singleton constructor.
- */
- private PropertyAdapters(){}
-
- /**
- * Registers a new PropertyAdapter 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.
- * @param <T> The target type
- * @return any adapter replaced with the new adapter, or null.
- */
- public static <T> PropertyAdapter<T> register(Class<T> targetType, PropertyAdapter<T> adapter){
- return ServiceContext.getInstance().getSingleton(PropertyAdaptersSingletonSpi.class).register(targetType, adapter);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @return true, if the given target type is supported.
- */
- public static boolean isTargetTypeSupported(Class<?> targetType){
- return ServiceContext.getInstance().getSingleton(PropertyAdaptersSingletonSpi.class).isTargetTypeSupported(targetType);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @param <T> the target type
- * @return the corresponding adapter, never null.
- * @throws ConfigException if the target type is not supported.
- */
- public static <T> PropertyAdapter<T> getAdapter(Class<T> targetType){
- return getAdapter(targetType, null);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @param annotation the {@link org.apache.tamaya.annotation.WithPropertyAdapter} 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.
- * @throws ConfigException if the target type is not supported, or the overriding adapter cannot be
- * instantiated.
- */
- public static <T> PropertyAdapter<T> getAdapter(Class<T> targetType, WithPropertyAdapter annotation){
- return ServiceContext.getInstance().getSingleton(PropertyAdaptersSingletonSpi.class).getAdapter(targetType, annotation);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/PropertySource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertySource.java b/api/src/main/java/org/apache/tamaya/PropertySource.java
index f44d561..9179c8f 100644
--- a/api/src/main/java/org/apache/tamaya/PropertySource.java
+++ b/api/src/main/java/org/apache/tamaya/PropertySource.java
@@ -75,7 +75,7 @@ public interface PropertySource {
* Access a property.
*
* @param key the property's key, not null.
- * @return the property's value.
+ * @return the property's keys.
*/
Optional<String> get(String key);
@@ -132,7 +132,7 @@ public interface PropertySource {
* Allows to evaluate if the provider is mutable.
*
* @return true, if the provider is mutable.
- * @see #apply(ConfigChangeSet)
+ * @see #applyChanges(ConfigChangeSet)
*/
default boolean isMutable() {
return false;
@@ -146,7 +146,7 @@ public interface PropertySource {
* @throws UnsupportedOperationException when the configuration is not writable.
* @see #isMutable()
*/
- default void apply(ConfigChangeSet change) {
+ default void applyChanges(ConfigChangeSet change) {
throw new UnsupportedOperationException("Config/properties not mutable: " + this);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
index a1af097..e1d773d 100644
--- a/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
+++ b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
@@ -25,7 +25,7 @@ import java.lang.annotation.Target;
/**
* Annotation container to enable injection current multiple {@link org.apache.tamaya.annotation.ConfiguredProperty}
- * annotations. Hereby the ordering current annotations imply the defaulting. The first value that
+ * annotations. Hereby the ordering current annotations imply the defaulting. The first keys that
* could be resolved successfully in the chain current annotations will be used.
*/
@Retention(RetentionPolicy.RUNTIME)
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
public @interface ConfiguredProperties {
/**
- * Get the different configuration keys to be looked up, in order current precedence. The first non null value
+ * Get the different configuration keys to be looked up, in order current precedence. The first non null keys
* found will be used.
*/
ConfiguredProperty[] value() default {};
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
index 14c9c55..a29ef8b 100644
--- a/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
+++ b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
@@ -25,7 +25,7 @@ import java.lang.annotation.*;
* a configuration template method. Hereby this annotation can be used in multiple ways and combined
* with other annotations such as {@link org.apache.tamaya.annotation.DefaultValue},
* {@link org.apache.tamaya.annotation.WithLoadPolicy}, {@link org.apache.tamaya.annotation.WithConfig},
- * {@link org.apache.tamaya.annotation.WithConfigOperator}, {@link org.apache.tamaya.annotation.WithPropertyAdapter}.
+ * {@link org.apache.tamaya.annotation.WithConfigOperator}, {@link WithCodec}.
*
* Below the most simple variant current a configured class is given:
* {@code
@@ -38,31 +38,31 @@ import java.lang.annotation.*;
* the following is happening:
* <ul>
* <li>The current valid Configuration is evaluated by calling {@code Configuration cfg = Configuration.current();}</li>
- * <li>The current property String value is evaluated by calling {@code cfg.get("aValue");}</li>
+ * <li>The current property String keys is evaluated by calling {@code cfg.get("aValue");}</li>
* <li>if not successful, an error is thrown ({@link org.apache.tamaya.ConfigException}.</li>
- * <li>On success, since no type conversion is involved, the value is injected.</li>
+ * <li>On success, since no type conversion is involved, the keys is injected.</li>
* <li>The configured bean is registered as a weak change listener in the config system's underlying
* configuration, so future config changes can be propagated (controlled by {@link org.apache.tamaya.annotation.WithLoadPolicy}
* annotations).</li>
* </ul>
*
- * In the next example we explicitly define the property value:
+ * In the next example we explicitly define the property keys:
* {@code
* pubic class ConfiguredItem{
*
* @ConfiguredProperty
- * @ConfiguredProperty("a.b.value")
- * @configuredProperty("a.b.deprecated.value")
- * @DefaultValue("${env:java.version}")
+ * @ConfiguredProperty({"a.b.value", "a.b.deprecated.keys", "${env:java.version}"})
+ * @ConfiguredProperty(configuration={"a", "b"}
+ * @ConfiguredProperty(configuration={"a", "b", keys={"a.b.keys", "a.b.deprecated.keys", "${env:java.version}"}}
* private String aValue;
* }
*
* Within this example we evaluate multiple possible keys. Evaluation is aborted if a key could be successfully
* resolved. Hereby the ordering current the annotations define the ordering current resolution, so in the example above
- * resolution equals to {@code "aValue", "a.b.value", "a.b.deprecated.value"}. If no value could be read
- * fromMap the configuration, it uses the value fromMap the {@code DefaultValue} annotation. Interesting here
- * is that this value is not static, it is evaluated by calling
- * {@link org.apache.tamaya.Configuration#evaluateValue(org.apache.tamaya.Configuration, String)}.
+ * resolution equals to {@code "aValue", "a.b.keys", "a.b.deprecated.keys"}. If no keys could be read
+ * fromMap the configuration, it uses the keys fromMap the {@code DefaultValue} annotation. Interesting here
+ * is that this keys is not static, it is evaluated by calling
+ * {@link org.apache.tamaya.Configuration#evaluateValue(String, org.apache.tamaya.Configuration...)}.
*/
@Repeatable(ConfiguredProperties.class)
@Retention(RetentionPolicy.RUNTIME)
@@ -70,10 +70,18 @@ import java.lang.annotation.*;
public @interface ConfiguredProperty {
/**
- * Get the property names to be used. Hereby the first non null value evaluated is injected as property value.
+ * Annotation to reference an explicit {@link org.apache.tamaya.Configuration} to be used to
+ * resolve the required properties. the configured keys is passed to {@code Configuration.current(String)}
+ * to evaluate the required configuration required.
+ * @return the configurations to be looked up for the given keys.
+ */
+ String config() default "";
+
+ /**
+ * Get the property names to be used. Hereby the first non null keys evaluated is injected as property keys.
*
* @return the property names, not null. If missing the field or method name being injected is used by default.
*/
- String value() default "";
+ String[] keys() default {};
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java b/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
index 19ee341..c4b2e3a 100644
--- a/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
+++ b/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
@@ -24,8 +24,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Annotation to define a default value to be returned, when no configured value could be
- * determined for a property/template accessor. The value hereby can also contain a
+ * Annotation to define a default keys to be returned, when no configured keys could be
+ * determined for a property/template accessor. The keys hereby can also contain a
* dynamic expression that is evaluated by the configuration system.
*/
@Retention(RetentionPolicy.RUNTIME)
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
public @interface DefaultValue {
/**
- * The default value to be injected, if no such configuration entry was found. If value was found and no default
+ * The default keys to be injected, if no such configuration entry was found. If keys was found and no default
* is defined, it is handled as a deployment error.
*/
String value() default "";
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java b/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
index 2e0089a..116a2c1 100644
--- a/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
+++ b/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
@@ -25,22 +25,22 @@ package org.apache.tamaya.annotation;
*/
public enum LoadPolicy {
/**
- * The configuration value is evaluated once, when the owning component is loaded/configured, but never updated later.
+ * The configuration keys is evaluated once, when the owning component is loaded/configured, but never updated later.
*/
INITIAL,
/**
- * The configuration value is evaluated exactly once on its first use lazily, but never updated later.
+ * The configuration keys is evaluated exactly once on its first use lazily, but never updated later.
* This feature is not applicable on field injection, but only on configuration template methods.
*/
LAZY,
/**
- * The configuration value is evaluated once, when the owning component is loaded/configured.
+ * The configuration keys is evaluated once, when the owning component is loaded/configured.
* Later changes on this configuration entry will be reinjected/updated and additionally triggered
* as {@link java.beans.PropertyChangeEvent}.
*/
MANAGED,
/**
- * The configuration value is evaluated once, when the owning component is loaded/configured.
+ * The configuration keys is evaluated once, when the owning component is loaded/configured.
* Later changes on this configuration entry will be reinjected/updated, but no {@link java.beans.PropertyChangeEvent}
* will be triggered.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/WithCodec.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithCodec.java b/api/src/main/java/org/apache/tamaya/annotation/WithCodec.java
new file mode 100644
index 0000000..3a092b2
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/WithCodec.java
@@ -0,0 +1,44 @@
+/*
+ * 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.annotation;
+
+import org.apache.tamaya.Codec;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to define a type adapter to be used before injecting a configured keys, or for applying changes.
+ * This will override any other adapter for performing the type conversion before
+ * injecting the field keys.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD })
+public @interface WithCodec {
+
+ /**
+ * Define a custom adapter or codec that should be used to deserialize the configuration entry injected. This overrides any
+ * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
+ * registered, it is handled as a deployment error.
+ */
+ Class<? extends Codec> value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java b/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java
deleted file mode 100644
index 00180a5..0000000
--- a/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java
+++ /dev/null
@@ -1,41 +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.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to reference an explicit {@link org.apache.tamaya.Configuration} to be used to
- * resolve the required properties. the configured value is passed to {@code Configuration.current(String)}
- * to evaluate the required configuration required.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
-public @interface WithConfig {
-
- /**
- * The name current the {@link org.apache.tamaya.Configuration} to be used to
- * resolve the required properties, not null or empty.
- */
- String value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java b/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
index 28bf814..0ede2c2 100644
--- a/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
+++ b/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
import java.util.function.UnaryOperator;
/**
- * Annotation to define an configuration operator to be used before accessing a configured value.
+ * Annotation to define an configuration operator to be used before accessing a configured keys.
* This allows filtering current configuration, e.g. for realizing views or ensuring security
* constraints.
*/
@@ -36,7 +36,7 @@ import java.util.function.UnaryOperator;
public @interface WithConfigOperator {
/**
- * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
+ * Define a custom adapter that should be used to deserialize the configuration entry injected. This overrides any
* general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
* registered, it is handled as a deployment error.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java b/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
deleted file mode 100644
index 4001742..0000000
--- a/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
+++ /dev/null
@@ -1,44 +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.annotation;
-
-import org.apache.tamaya.PropertyAdapter;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to define a type adapter to be used before injecting a configured value.
- * This will override any other adapter for performing the type conversion before
- * injecting the field value.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface WithPropertyAdapter {
-
- /**
- * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
- * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
- * registered, it is handled as a deployment error.
- */
- Class<? extends PropertyAdapter> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/spi/CodecsSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/CodecsSingletonSpi.java b/api/src/main/java/org/apache/tamaya/spi/CodecsSingletonSpi.java
new file mode 100644
index 0000000..07993e5
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/spi/CodecsSingletonSpi.java
@@ -0,0 +1,89 @@
+/*
+ * 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.Codec;
+import org.apache.tamaya.annotation.WithCodec;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * SPI that is used by the {@link org.apache.tamaya.Codecs} singleton as delegation instance.
+ */
+public interface CodecsSingletonSpi {
+
+ /**
+ * Registers a new PropertyAdapter 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.
+ * @param <T> The target type
+ * @return any adapter replaced with the new adapter, or null.
+ */
+ <T> Codec<T> register(Class<T> targetType, Codec<T> adapter);
+
+ default <T> Codec<T> register(Class<T> targetType, Function<String,T> decoder, Function<T, String> encoder){
+ Objects.requireNonNull(targetType);
+ Objects.requireNonNull(decoder);
+ Objects.requireNonNull(encoder);
+ return register(targetType, new Codec<T>(){
+
+ @Override
+ public T deserialize(String value) {
+ return decoder.apply(value);
+ }
+
+ @Override
+ public String serialize(T value) {
+ return encoder.apply(value);
+ }
+
+ @Override
+ public String toString(){
+ return "Codec(decoder="+decoder.getClass().getName()+", encoder="+encoder.getClass().getName()+")";
+ }
+ });
+ }
+
+ /**
+ * Get an adapter converting to the given target type.
+ * @param targetType the target type class
+ * @return true, if the given target type is supported.
+ */
+ default <T> Codec<T> getAdapter(Class<T> targetType){
+ return getCodec(targetType, null);
+ }
+
+ /**
+ * Get an adapter converting to the given target type.
+ * @param targetType the target type class
+ * @param <T> the target type
+ * @return the corresponding adapter, never null.
+ * @throws org.apache.tamaya.ConfigException if the target type is not supported.
+ */
+ <T> Codec<T> getCodec(Class<T> targetType, WithCodec annotation);
+
+ /**
+ * Checks if the given target type is supported, i.e. a adapter is registered and accessible.
+ * @param targetType the target type class
+ * @return true, if the given target type is supported.
+ */
+ boolean isTargetTypeSupported(Class<?> targetType);
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
index 46f9a10..2bbc180 100644
--- a/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
+++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
@@ -49,9 +49,7 @@ public interface ConfigurationManagerSingletonSpi{
* @return the corresponding Configuration instance, never null.
* @throws org.apache.tamaya.ConfigException if no such configuration is defined.
*/
- default Configuration getConfiguration(String name){
- return getConfiguration(name, Configuration.class);
- }
+ Configuration getConfiguration(String name);
/**
* Access the default configuration.
@@ -59,7 +57,7 @@ public interface ConfigurationManagerSingletonSpi{
* @throws org.apache.tamaya.ConfigException if no such configuration is defined.
*/
default Configuration getConfiguration(){
- return getConfiguration("default", Configuration.class);
+ return getConfiguration("default");
}
/**
@@ -67,40 +65,33 @@ public interface ConfigurationManagerSingletonSpi{
* entries.
*
* @param instance the instance with configuration annotations, not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @throws org.apache.tamaya.ConfigException if any required configuration could not be resolved/injected.
*/
- void configure(Object instance);
+ void configure(Object instance, Configuration... configurations);
/**
* Access a configuration by name.
*
- * @param name the configuration's name, not null, not empty.
- * @param template the annotated configuration's
- * template interface, not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @return the corresponding Configuration instance, never null.
* @throws org.apache.tamaya.ConfigException if no such configuration is defined.
*/
- <T> T getConfiguration(String name, Class<T> template);
-
- /**
- * Access a typed configuration.
- *
- * @param type the annotated configuration type (could be an interface or
- * a non abstract class), not null.
- * @return the corresponding typed Configuration instance, never null.
- * @throws org.apache.tamaya.ConfigException if the configuration could not be resolved.
- */
- default <T> T getConfiguration(Class<T> type){
- return getConfiguration("default", type);
- }
+ <T> T createTemplate(Class<T> template, Configuration... configurations);
/**
* Evaluate the current expression based on the current configuration valid.
- * @param config The configuration to be used for evaluating, using EL, not null.
+ * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
+ * If no such config is passed, the default configurationa provided by the current
+ * registered providers are used.
* @param expression the expression, not null.
* @return the evaluated config expression.
*/
- String evaluateValue(Configuration config, String expression);
+ String evaluateValue(String expression, Configuration... configurations);
/**
* Add a ConfigChangeSet listener to the given configuration instance.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/spi/Orderable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/Orderable.java b/api/src/main/java/org/apache/tamaya/spi/Orderable.java
index 4a314f6..56a99d7 100644
--- a/api/src/main/java/org/apache/tamaya/spi/Orderable.java
+++ b/api/src/main/java/org/apache/tamaya/spi/Orderable.java
@@ -27,8 +27,8 @@ package org.apache.tamaya.spi;
@FunctionalInterface
public interface Orderable {
/**
- * Get the ordinal value for the component, by default 0.
- * @return the ordinal value
+ * Get the ordinal keys for the component, by default 0.
+ * @return the ordinal keys
*/
int order();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java b/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
deleted file mode 100644
index edc5ed9..0000000
--- a/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
+++ /dev/null
@@ -1,63 +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.spi;
-
-import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-
-/**
- * SPI that is used by the {@link org.apache.tamaya.PropertyAdapters} singleton as delegation instance.
- */
-public interface PropertyAdaptersSingletonSpi{
-
- /**
- * Registers a new PropertyAdapter 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.
- * @param <T> The target type
- * @return any adapter replaced with the new adapter, or null.
- */
- <T> PropertyAdapter<T> register(Class<T> targetType, PropertyAdapter<T> adapter);
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @return true, if the given target type is supported.
- */
- default <T> PropertyAdapter<T> getAdapter(Class<T> targetType){
- return getAdapter(targetType, null);
- }
-
- /**
- * Get an adapter converting to the given target type.
- * @param targetType the target type class
- * @param <T> the target type
- * @return the corresponding adapter, never null.
- * @throws org.apache.tamaya.ConfigException if the target type is not supported.
- */
- <T> PropertyAdapter<T> getAdapter(Class<T> targetType, WithPropertyAdapter annotation);
-
- /**
- * Checks if the given target type is supported, i.e. a adapter is registered and accessible.
- * @param targetType the target type class
- * @return true, if the given target type is supported.
- */
- boolean isTargetTypeSupported(Class<?> targetType);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/test/java/annottext/AnnotatedConfig.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/annottext/AnnotatedConfig.java b/api/src/test/java/annottext/AnnotatedConfig.java
index 408cc97..20b135f 100644
--- a/api/src/test/java/annottext/AnnotatedConfig.java
+++ b/api/src/test/java/annottext/AnnotatedConfig.java
@@ -31,21 +31,21 @@ import org.apache.tamaya.annotation.LoadPolicy;
@WithLoadPolicy(LoadPolicy.INITIAL)
public interface AnnotatedConfig {
- @ConfiguredProperty("foo.bar.myprop")
- @ConfiguredProperty("mp")
- @ConfiguredProperty("common.test.myProperty")
+ @ConfiguredProperty(keys = "foo.bar.myprop")
+ @ConfiguredProperty(keys = "mp")
+ @ConfiguredProperty(keys = "common.test.myProperty")
@DefaultValue("myValue_$[env.stage]")
// @ConfigLoadPolicy(listener = MyListener.class)
String myParameter();
- @ConfiguredProperty("simple_value")
+ @ConfiguredProperty(keys = "simple_value")
@WithLoadPolicy(LoadPolicy.LAZY)
String simpleValue();
@ConfiguredProperty
String simplestValue();
- @ConfiguredProperty("env.host.name")
+ @ConfiguredProperty(keys = "env.host.name")
String hostName();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c9e62e24/api/src/test/java/annottext/AnnotatedFullConfig.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/annottext/AnnotatedFullConfig.java b/api/src/test/java/annottext/AnnotatedFullConfig.java
index 474356f..df39d12 100644
--- a/api/src/test/java/annottext/AnnotatedFullConfig.java
+++ b/api/src/test/java/annottext/AnnotatedFullConfig.java
@@ -32,21 +32,21 @@ import org.apache.tamaya.annotation.LoadPolicy;
@WithLoadPolicy(LoadPolicy.INITIAL)
public interface AnnotatedFullConfig extends Configuration{
- @ConfiguredProperty("foo.bar.myprop")
- @ConfiguredProperty("mp")
- @ConfiguredProperty("common.test.myProperty")
+ @ConfiguredProperty(keys = "foo.bar.myprop")
+ @ConfiguredProperty(keys = "mp")
+ @ConfiguredProperty(keys = "common.test.myProperty")
@DefaultValue("myValue_$[env.stage]")
// @ConfigLoadPolicy(listener = MyListener.class)
String myParameter();
- @ConfiguredProperty("simple_value")
+ @ConfiguredProperty(keys = "simple_value")
@WithLoadPolicy(LoadPolicy.LAZY)
String simpleValue();
@ConfiguredProperty
String simplestValue();
- @ConfiguredProperty("env.host.name")
+ @ConfiguredProperty(keys = "env.host.name")
String hostName();
}