You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/01/03 12:59:23 UTC
[14/27] incubator-tamaya git commit: TAMAYA-19: Reorganized dormant
part for better focus of future discussions.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java b/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java
deleted file mode 100644
index b8e0cf5..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java
+++ /dev/null
@@ -1,500 +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 java.beans.PropertyChangeEvent;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.ref.WeakReference;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.logging.Logger;
-
-/**
- * A accessor for a single configured value. This can be used to support values that may change during runtime, reconfigured or
- * final. Hereby external code (could be Tamaya configuration listners or client code), can set a new value. Depending on the
- * {@link org.apache.tamaya.DynamicValue.UpdatePolicy} the new value is immedeately active or it requires an active commit
- * by client code. Similarly an instance also can ignore all later changes to the value.
- * <h3>Implementation Details</h3>
- * This class is
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- */
-public final class DynamicValue<T> implements Serializable{
-
- /**
- * Policy to control how new values are applied to this instance.
- */
- enum UpdatePolicy{
- /** New values are applied immedately and registered listeners are informed about the change. */
- IMMEDIATE,
- /** New values or not applied, but stored in the newValue property. Explcit call to #commit
- of #commitAndGet are required to accept the change and inform the listeners about the change.
- */
- EXPLCIT,
- /**
- * New values are always immedately discarded.
- */
- NEVER,
- /**
- * Changes are logged before the are discarded.
- */
- LOG_AND_DISCARD
- }
-
-
- /** The property name of the entry. */
- private String propertyName;
- /**
- * Policy that defines how new values are applied, be default it is applied initially once, but never updated anymore.
- */
- private UpdatePolicy updatePolicy = UpdatePolicy.NEVER;
- /** The current value, never null. */
- private transient Optional<T> value;
- /** The new value, or null. */
- private transient Optional<T> newValue;
- /** List of listeners that listen for changes. */
- private transient WeakList<Consumer<PropertyChangeEvent>> listeners;
-
- /**
- * Returns an empty {@code Optional} instance. No value is present for this
- * Optional.
- *
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
- * Instead, use {@link #isPresent()}.
- *
- * @param <T> Type of the non-existent value
- * @return an empty {@code Optional}
- */
- public static <T> DynamicValue<T> empty(String propertyName) {
- DynamicValue v = new DynamicValue<T>(propertyName, null);
- return v;
- }
-
- /**
- * Constructor.
- * @param propertyName the name of the value in the format {@code <configName>:<propertyName>}.</config>
- * @param item the initial value.
- */
- private DynamicValue(String propertyName, Optional<T> item){
- this.propertyName = Objects.requireNonNull(propertyName);
- this.value = item;
- }
-
- /**
- * Creates a new instance.
- * @param propertyName the name of the value in the format {@code <configName>:<propertyName>}.</config>
- * @param value the initial value, not null.
- * @param <T> the type
- * @return a new instance, never null
- */
- public static <T> DynamicValue<T> of(String propertyName, T value){
- return new DynamicValue(propertyName, Optional.of(value));
- }
-
- /**
- * Creates a new instance.
- * @param propertyName the name of the value in the format {@code <configName>:<propertyName>}.</config>
- * @param value the initial value
- * @param <T> the target type.
- * @return a new instance, never null
- */
- public static <T> DynamicValue<T> ofNullable(String propertyName, T value){
- return value == null ? empty(propertyName) : of(propertyName, value);
- }
-
- /**
- * Performs a commit, if necessary and returns the current value.
- * otherwise throws {@code ConfigException}.
- *
- * @return the non-null value held by this {@code Optional}
- * @throws org.apache.tamaya.ConfigException if there is no value present
- *
- * @see DynamicValue#isPresent()
- */
- public T commitAndGet(){
- commit();
- return get();
- }
-
- /**
- * Commits a new value that has not been committed yet, make it the new value of the instance. On change any registered listeners will be triggered.
- */
- public void commit(){
- synchronized (value){
- if(newValue!=null){
- PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, value.orElse(null), newValue.orElse(null));
- value = newValue;
- newValue = null;
- for(Consumer<PropertyChangeEvent> consumer: listeners.get()){
- consumer.accept(evt);
- }
- }
- }
- }
-
- /**
- * Discards a new value that was published. No listeners will be informed.
- */
- public void discard(){
- newValue = null;
- }
-
-
-
- /**
- * Access the {@link UpdatePolicy} used for updating this value.
- * @return the update policy, never null.
- */
- public UpdatePolicy getUpdatePolicy() {
- return updatePolicy;
- }
-
- /**
- * Add a listener to be called as weak reference, when this value has been changed.
- * @param l the listner, not null
- */
- public void addListener(Consumer<PropertyChangeEvent> l) {
- if(listeners==null){
- listeners = new WeakList<>();
- }
- listeners.add(l);
- }
-
- /**
- * Removes a listener to be called, when this value has been changed.
- * @param l the listner to be removed, not null
- */
- public void removeListener(Consumer<PropertyChangeEvent> l) {
- if(listeners!=null){
- listeners.remove(l);
- }
- }
-
- /**
- * If a value is present in this {@code ConfiguredValue}, returns the value,
- * otherwise throws {@code ConfigException}.
- *
- * @return the non-null value held by this {@code Optional}
- * @throws org.apache.tamaya.ConfigException if there is no value present
- *
- * @see DynamicValue#isPresent()
- */
- public T get() {
- return value.get();
- }
-
- /**
- * Method to apply a new value. Depending on the {@link org.apache.tamaya.DynamicValue.UpdatePolicy}
- * the value is immediately or deferred visible (or it may even be ignored completely).
- * @param newValue the new value, may also be null.
- */
- public void setNewValue(T newValue){
- switch(this.updatePolicy){
- case IMMEDIATE:
- this.newValue = Optional.ofNullable(newValue);
- commit();
- break;
- case EXPLCIT:
- this.newValue = Optional.ofNullable(newValue);
- break;
- case LOG_AND_DISCARD:
- Logger.getLogger(getClass().getName()).info("Discard change on " + this + ", newValue="+newValue);
- this.newValue = null;
- break;
- case NEVER:
- this.newValue = null;
- break;
- }
-
- }
-
- /**
- * Sets a new {@link org.apache.tamaya.DynamicValue.UpdatePolicy}.
- * @param updatePolicy the new policy, not null.
- */
- public void setUpdatePolicy(UpdatePolicy updatePolicy){
- this.updatePolicy = Objects.requireNonNull(updatePolicy);
- }
-
- /**
- * Access a new value that has not yet been committed.
- * @return the uncommitted new value, or null.
- */
- public T getNewValue(){
- Optional<T> nv = newValue;
- if(nv!=null){
- return nv.orElse(null);
- }
- return null;
- }
-
- /**
- * Return {@code true} if there is a value present, otherwise {@code false}.
- *
- * @return {@code true} if there is a value present, otherwise {@code false}
- */
- public boolean isPresent() {
- return value.isPresent();
- }
-
- /**
- * If a value is present, invoke the specified consumer with the value,
- * otherwise do nothing.
- *
- * @param consumer block to be executed if a value is present
- * @throws NullPointerException if value is present and {@code consumer} is
- * null
- */
- public void ifPresent(Consumer<? super T> consumer) {
- value.ifPresent(consumer);
- }
-
- /**
- * If a value is present, and the value matches the given predicate,
- * return an {@code Optional} describing the value, otherwise return an
- * empty {@code Optional}.
- *
- * @param predicate a predicate to apply to the value, if present
- * @return an {@code Optional} describing the value of this {@code Optional}
- * if a value is present and the value matches the given predicate,
- * otherwise an empty {@code Optional}
- * @throws NullPointerException if the predicate is null
- */
- public DynamicValue<T> filter(Predicate<? super T> predicate) {
- Objects.requireNonNull(predicate);
- if (!isPresent())
- return this;
- else
- return predicate.test(value.get()) ? this : empty(propertyName);
- }
-
- /**
- * If a value is present, apply the provided mapping function to it,
- * and if the result is non-null, return an {@code Optional} describing the
- * result. Otherwise return an empty {@code Optional}.
- *
- * @apiNote This method supports post-processing on optional values, without
- * the need to explicitly check for a return status. For example, the
- * following code traverses a stream of file names, selects one that has
- * not yet been processed, and then opens that file, returning an
- * {@code Optional<FileInputStream>}:
- *
- * <pre>{@code
- * Optional<FileInputStream> fis =
- * names.stream().filter(name -> !isProcessedYet(name))
- * .findFirst()
- * .map(name -> new FileInputStream(name));
- * }</pre>
- *
- * Here, {@code findFirst} returns an {@code Optional<String>}, and then
- * {@code map} returns an {@code Optional<FileInputStream>} for the desired
- * file if one exists.
- *
- * @param <U> The type of the result of the mapping function
- * @param mapper a mapping function to apply to the value, if present
- * @return an {@code Optional} describing the result of applying a mapping
- * function to the value of this {@code Optional}, if a value is present,
- * otherwise an empty {@code Optional}
- * @throws NullPointerException if the mapping function is null
- */
- public <U> DynamicValue<U> map(Function<? super T, ? extends U> mapper) {
- Objects.requireNonNull(mapper);
- if (!isPresent())
- return empty(propertyName);
- else {
- return DynamicValue.ofNullable(propertyName, mapper.apply(value.get()));
- }
- }
-
- /**
- * If a value is present, apply the provided {@code Optional}-bearing
- * mapping function to it, return that result, otherwise return an empty
- * {@code Optional}. This method is similar to {@link #map(Function)},
- * but the provided mapper is one whose result is already an {@code Optional},
- * and if invoked, {@code flatMap} does not wrap it with an additional
- * {@code Optional}.
- *
- * @param <U> The type parameter to the {@code Optional} returned by
- * @param mapper a mapping function to apply to the value, if present
- * the mapping function
- * @return the result of applying an {@code Optional}-bearing mapping
- * function to the value of this {@code Optional}, if a value is present,
- * otherwise an empty {@code Optional}
- * @throws NullPointerException if the mapping function is null or returns
- * a null result
- */
- public <U> DynamicValue<U> flatMap(Function<? super T, DynamicValue<U>> mapper) {
- Objects.requireNonNull(mapper);
- if (!isPresent())
- return empty(propertyName);
- else {
- return Objects.requireNonNull(mapper.apply(value.get()));
- }
- }
-
- /**
- * Return the value if present, otherwise return {@code other}.
- *
- * @param other the value to be returned if there is no value present, may
- * be null
- * @return the value, if present, otherwise {@code other}
- */
- public T orElse(T other) {
- return value.orElse(other);
- }
-
- /**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
- *
- * @param other a {@code Supplier} whose result is returned if no value
- * is present
- * @return the value if present otherwise the result of {@code other.get()}
- * @throws NullPointerException if value is not present and {@code other} is
- * null
- */
- public T orElseGet(Supplier<? extends T> other) {
- return value.orElseGet(other);
- }
-
- /**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
- *
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
- * {@code IllegalStateException::new}
- *
- * @param <X> Type of the exception to be thrown
- * @param exceptionSupplier The supplier which will return the exception to
- * be thrown
- * @return the present value
- * @throws X if there is no value present
- * @throws NullPointerException if no value is present and
- * {@code exceptionSupplier} is null
- */
- public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
- return value.orElseThrow(exceptionSupplier);
- }
-
- /**
- * Converts the instance to an {@link java.util.Optional} instance.
- * @return the corresponding Optional value.
- */
- public Optional<T> toOptional(){
- return value;
- }
-
- /**
- * Serialization implementation that strips away the non serializable Optional part.
- * @param oos the output stream
- * @throws IOException if serialization fails.
- */
- private void writeObject(ObjectOutputStream oos)throws IOException {
- oos.writeObject(updatePolicy);
- if(isPresent()) {
- oos.writeObject(this.value.get());
- }
- else{
- oos.writeObject(null);
- }
- }
-
- /**
- * Reads an instance from the input stream.
- * @param ois the object input stream
- * @throws IOException if deserialization fails.
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- this.updatePolicy = (UpdatePolicy)ois.readObject();
- if(isPresent()) {
- this.value = Optional.of((T) ois.readObject());
- }
- newValue = null;
- }
-
-
- /**
- * Simple helper that allows keeping the listeners registered as weak references, hereby avoiding any
- * memory leaks.
- * @param <T> the type
- */
- private class WeakList<T>{
- List<WeakReference<T>> refs = new LinkedList<>();
-
- /**
- * Adds a new instance.
- * @param t the new instance, not null.
- */
- void add(T t){
- refs.add(new WeakReference(t));
- }
-
- /**
- * Removes a instance.
- * @param t the instance to be removed.
- */
- void remove(T t){
- synchronized (refs){
- for(Iterator<WeakReference<T>> iterator = refs.iterator();iterator.hasNext();){
- WeakReference<T> ref = iterator.next();
- T instance = ref.get();
- if(instance==null || instance == t){
- iterator.remove();
- break;
- }
- }
- }
- }
-
-
- /**
- * Access a list (copy) of the current instances that were not discarded by the GC.
- * @return the list of accessible items.
- */
- public List<T> get() {
- synchronized (refs) {
- List<T> res = new ArrayList<>();
- for (Iterator<WeakReference<T>> iterator = refs.iterator(); iterator.hasNext(); ) {
- WeakReference<T> ref = iterator.next();
- T instance = ref.get();
- if(instance==null){
- iterator.remove();
- }
- else{
- res.add(instance);
- }
- }
- return res;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/PropertyMapSupplier.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/PropertyMapSupplier.java b/dormant/api/src/main/java/org/apache/tamaya/PropertyMapSupplier.java
deleted file mode 100644
index 69dd308..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/PropertyMapSupplier.java
+++ /dev/null
@@ -1,37 +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 java.util.Map;
-
-/**
- * Supplier for a property map.
- */
-@FunctionalInterface
-public interface PropertyMapSupplier {
-
- /**
- * Access the current properties as Map. The resulting Map may not return all items accessible, e.g.
- * when the underlying storage does not support iteration of its entries.
- *
- * @return the a corresponding map, never null.
- */
- Map<String,String> getProperties();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
deleted file mode 100644
index e1d773d..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.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 container to enable injection current multiple {@link org.apache.tamaya.annotation.ConfiguredProperty}
- * 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)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface ConfiguredProperties {
-
- /**
- * 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/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
deleted file mode 100644
index 21d4e3a..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.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.annotation;
-
-import java.lang.annotation.*;
-
-/**
- * Annotation to enable injection current a configured property or define the returned data for
- * 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 WithPropertyAdapter}.
- *
- * Below the most simple variant current a configured class is given:
- * {@code
- * pubic class ConfiguredItem{
- *
- * @ConfiguredProperty
- * private String aValue;
- * }
- * When this class is configured, e.g. by passing it to {@link org.apache.tamaya.Configuration#configure(Object)},
- * 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 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 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 keys:
- * {@code
- * pubic class ConfiguredItem{
- *
- * @ConfiguredProperty
- * @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.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)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface ConfiguredProperty {
-
- /**
- * 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[] keys() default {};
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java
deleted file mode 100644
index 63ea137..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to control injection and resolution current a configured bean. The configuration keys
- * to be resolved are basically determined by the {@link org.apache.tamaya.annotation.ConfiguredProperty}
- * annotation(s). Nevertheless these annotations can also have relative key names. This annotation allows
- * to define a configuration area that is prefixed to all relative configuration keys within the
- * corresponding class/template interface.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE })
-public @interface DefaultAreas {
-
- /**
- * Allows to declare an operator that should be applied before injecting values into the bean.
- * @return the operator class to be used.
- */
- String[] value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
deleted file mode 100644
index c4b2e3a..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.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 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)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface DefaultValue {
-
- /**
- * 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/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
deleted file mode 100644
index 116a2c1..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
+++ /dev/null
@@ -1,48 +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;
-
-/**
- * Available policies that describe how changes affecting configured values are published/reinjected.
- * The policy also affects the cases were any configured listeners/listener methods are called for
- * propagation current configuration changes.
- */
-public enum LoadPolicy {
- /**
- * The configuration keys is evaluated once, when the owning component is loaded/configured, but never updated later.
- */
- INITIAL,
- /**
- * 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 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 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.
- */
- SILENT
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/NoConfig.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/NoConfig.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/NoConfig.java
deleted file mode 100644
index 845ec4c..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/NoConfig.java
+++ /dev/null
@@ -1,32 +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.*;
-
-/**
- * This is a small marker annotations to inform Tamaya that the annotated element should never be injected with
- * configured data. This is useful because by default Tamaya tries to lookup and inject configuration also by
- * using property or method names without annotations. With that annotation none of these will be happen.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface NoConfig {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/ObservesConfigChange.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/ObservesConfigChange.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/ObservesConfigChange.java
deleted file mode 100644
index ef92b25..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/ObservesConfigChange.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to annotate a method on a class to be informed on config changes.
- * The exact behaviour, when configuration change events are sent can be configured
- * on each configured property/method by adding the {@link org.apache.tamaya.annotation.WithLoadPolicy}
- * annotation. By default listeners are informed on all changes of configurations that were used as
- * input configurations for configuring a class/instance. Additionally {@link org.apache.tamaya.annotation.ConfiguredProperty}
- * annotations can be added that allows to constrain changes to some limited properties.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.METHOD })
-public @interface ObservesConfigChange {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
deleted file mode 100644
index 9f6c4f5..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
+++ /dev/null
@@ -1,45 +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.Configuration;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.function.UnaryOperator;
-
-/**
- * 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.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
-public @interface WithConfigOperator {
-
- /**
- * 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 UnaryOperator<Configuration>> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java
deleted file mode 100644
index e469f5a..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java
+++ /dev/null
@@ -1,40 +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 define how config changes are handled for a type or per property/template method.
- * @see org.apache.tamaya.annotation.LoadPolicy
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
-public @interface WithLoadPolicy {
-
- /**
- * The load policy to be used. If this annotation is present a load policy must be defined.
- * @return The load policy to be used, not null.
- */
- LoadPolicy value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java b/dormant/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
deleted file mode 100644
index fa9cfdf..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
+++ /dev/null
@@ -1,45 +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 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 WithPropertyAdapter {
-
- /**
- * Define a custom adapter or codec 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.
- */
- @SuppressWarnings("rawtypes")
- Class<? extends PropertyAdapter> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationFactorySpi.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationFactorySpi.java b/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationFactorySpi.java
deleted file mode 100644
index 3b167cc..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationFactorySpi.java
+++ /dev/null
@@ -1,60 +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.Configuration;
-import org.apache.tamaya.PropertySource;
-
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Factory to create configurations from property sources. If not defines a default is used.
- */
-public interface ConfigurationFactorySpi {
- /**
- * Creates a configuration from a {@link org.apache.tamaya.PropertySource}.
- *
- * @param propertySource the property source
- * @return the corresponding Configuration instance, never null.
- */
- default Configuration from(PropertySource propertySource){
- return new Configuration() {
- @Override
- public String getName() {
- return propertySource.getName();
- }
-
- @Override
- public Optional<String> get(String key) {
- return propertySource.get(key);
- }
-
- @Override
- public Map<String, String> getProperties() {
- return propertySource.getProperties();
- }
-
- @Override
- public String toString(){
- return "Configuration, based on " + propertySource;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationSpi.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationSpi.java b/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationSpi.java
deleted file mode 100644
index 5891dc2..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/spi/ConfigurationSpi.java
+++ /dev/null
@@ -1,98 +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.Configuration;
-import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.PropertySource;
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-
-import java.util.Map;
-import java.util.Optional;
-
-
-/**
- * Manager for {@link org.apache.tamaya.Configuration} instances. Implementations must register an instance
- * using the {@link ServiceContextManager} mechanism in place (by default this is based on the {@link java.util.ServiceLoader}.
- * The {@link org.apache.tamaya.Configuration} Singleton in the API delegates its corresponding calls to the
- * instance returned by the current bootstrap service in place.
- *
- * @see org.apache.tamaya.Configuration
- * @see ServiceContextManager
- */
-public interface ConfigurationSpi {
-
- /**
- * Allows to check if a configuration with a given name is defined.
- * @param name the configuration's name, not null, not empty.
- * @return true, if such a configuration is defined.
- */
- boolean isConfigurationAvailable(String name);
-
- /**
- * Access a configuration by name.
- * @param name the configuration's name, not null, not empty.
- * @return the corresponding Configuration instance, never null.
- * @throws org.apache.tamaya.ConfigException if no such configuration is defined.
- */
- Configuration getConfiguration(String name);
-
- /**
- * Access the default configuration.
- * @return the corresponding Configuration instance, never null.
- * @throws org.apache.tamaya.ConfigException if no such configuration is defined.
- */
- default Configuration getConfiguration(){
- return getConfiguration("default");
- }
-
- /**
- * Configures an instance, by resolving and injecting the configuration
- * 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, Configuration... configurations);
-
- /**
- * Access a configuration by name.
- *
- * @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 createTemplate(Class<T> template, Configuration... configurations);
-
- /**
- * Evaluate the current expression based on the current configuration valid.
- * @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(String expression, Configuration... configurations);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java b/dormant/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java
deleted file mode 100644
index a1222a4..0000000
--- a/dormant/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java
+++ /dev/null
@@ -1,72 +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.Configuration;
-import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-
-
-/**
- * Manager for {@link org.apache.tamaya.Configuration} instances. Implementations must register an instance
- * using the {@link org.apache.tamaya.spi.ServiceContextManager} mechanism in place (by default this is based on the {@link java.util.ServiceLoader}.
- * The {@link org.apache.tamaya.Configuration} Singleton in the API delegates its corresponding calls to the
- * instance returned by the current bootstrap service in place.
- *
- * @see org.apache.tamaya.Configuration
- * @see org.apache.tamaya.spi.ServiceContextManager
- */
-public interface PropertyAdapterSpi {
-
-
- /**
- * 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 getPropertyAdapter(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> getPropertyAdapter(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/b56817f7/dormant/api/src/test/java/annottext/AnnotatedConfig.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/java/annottext/AnnotatedConfig.java b/dormant/api/src/test/java/annottext/AnnotatedConfig.java
deleted file mode 100644
index 20b135f..0000000
--- a/dormant/api/src/test/java/annottext/AnnotatedConfig.java
+++ /dev/null
@@ -1,51 +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 annottext;
-
-import org.apache.tamaya.annotation.ConfiguredProperty;
-import org.apache.tamaya.annotation.WithLoadPolicy;
-import org.apache.tamaya.annotation.DefaultValue;
-import org.apache.tamaya.annotation.LoadPolicy;
-
-/**
- * An example showing some basic annotations, using an interface to be proxied by the
- * configuration system.
- * Created by Anatole on 15.02.14.
- */
-@WithLoadPolicy(LoadPolicy.INITIAL)
-public interface AnnotatedConfig {
-
- @ConfiguredProperty(keys = "foo.bar.myprop")
- @ConfiguredProperty(keys = "mp")
- @ConfiguredProperty(keys = "common.test.myProperty")
- @DefaultValue("myValue_$[env.stage]")
- // @ConfigLoadPolicy(listener = MyListener.class)
- String myParameter();
-
- @ConfiguredProperty(keys = "simple_value")
- @WithLoadPolicy(LoadPolicy.LAZY)
- String simpleValue();
-
- @ConfiguredProperty
- String simplestValue();
-
- @ConfiguredProperty(keys = "env.host.name")
- String hostName();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/test/java/annottext/AnnotatedFullConfig.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/java/annottext/AnnotatedFullConfig.java b/dormant/api/src/test/java/annottext/AnnotatedFullConfig.java
deleted file mode 100644
index df39d12..0000000
--- a/dormant/api/src/test/java/annottext/AnnotatedFullConfig.java
+++ /dev/null
@@ -1,52 +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 annottext;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.annotation.ConfiguredProperty;
-import org.apache.tamaya.annotation.WithLoadPolicy;
-import org.apache.tamaya.annotation.DefaultValue;
-import org.apache.tamaya.annotation.LoadPolicy;
-
-/**
- * An example showing some basic annotations, using an interface to be proxied by the
- * configuration system, nevertheless extending the overall Configuration interface.
- * Created by Anatole on 15.02.14.
- */
-@WithLoadPolicy(LoadPolicy.INITIAL)
-public interface AnnotatedFullConfig extends Configuration{
-
- @ConfiguredProperty(keys = "foo.bar.myprop")
- @ConfiguredProperty(keys = "mp")
- @ConfiguredProperty(keys = "common.test.myProperty")
- @DefaultValue("myValue_$[env.stage]")
- // @ConfigLoadPolicy(listener = MyListener.class)
- String myParameter();
-
- @ConfiguredProperty(keys = "simple_value")
- @WithLoadPolicy(LoadPolicy.LAZY)
- String simpleValue();
-
- @ConfiguredProperty
- String simplestValue();
-
- @ConfiguredProperty(keys = "env.host.name")
- String hostName();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/test/java/org/apache/tamaya/TestConfigServiceSingletonSpi.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/java/org/apache/tamaya/TestConfigServiceSingletonSpi.java b/dormant/api/src/test/java/org/apache/tamaya/TestConfigServiceSingletonSpi.java
deleted file mode 100644
index 858786d..0000000
--- a/dormant/api/src/test/java/org/apache/tamaya/TestConfigServiceSingletonSpi.java
+++ /dev/null
@@ -1,90 +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 java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Consumer;
-
-import org.apache.tamaya.spi.ConfigurationSpi;
-
-/**
- * Created by Anatole on 09.09.2014.
- */
-public class TestConfigServiceSingletonSpi implements ConfigurationSpi {
-
-
- private Map<String, Configuration> configs = new ConcurrentHashMap<>();
-
- public TestConfigServiceSingletonSpi(){
- Map<String,String> config = new HashMap<>();
- config.put("a.b.c.key1", "keys current a.b.c.key1");
- config.put("a.b.c.key2", "keys current a.b.c.key2");
- config.put("a.b.key3", "keys current a.b.key3");
- config.put("a.b.key4", "keys current a.b.key4");
- config.put("a.key5", "keys current a.key5");
- config.put("a.key6", "keys current a.key6");
- config.put("int1", "123456");
- config.put("int2", "111222");
- config.put("booleanT", "true");
- config.put("double1", "1234.5678");
- config.put("BD", "123456789123456789123456789123456789.123456789123456789123456789123456789");
- config.put("testProperty", "keys current testProperty");
- config.put("runtimeVersion", "${java.version}");
- // configs.put("test", new MapConfiguration(MetaInfoBuilder.current().setName("test").build(), config));
- }
-
-
-
- @Override
- public boolean isConfigurationAvailable(String name){
- return configs.containsKey(name);
- }
-
- @Override
- public Configuration getConfiguration(String name) {
- // TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- @Override
- public <T> T createTemplate(Class<T> type, Configuration... configurations) {
- // TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- @Override
- public void configure(Object instance, Configuration... configurations) {
- // TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- @Override
- public String evaluateValue(String expression, Configuration... configurations) {
- // TODO improve this ugly implementation...
- for (Configuration config : configurations) {
- for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
- expression = expression.replaceAll("\\$\\{" + en.getKey() + "\\}", en.getValue());
- }
- }
- return expression;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/test/java/org/apache/tamaya/TestPropertyAdaptersSingletonSpi.java
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/java/org/apache/tamaya/TestPropertyAdaptersSingletonSpi.java b/dormant/api/src/test/java/org/apache/tamaya/TestPropertyAdaptersSingletonSpi.java
deleted file mode 100644
index 65e6c1d..0000000
--- a/dormant/api/src/test/java/org/apache/tamaya/TestPropertyAdaptersSingletonSpi.java
+++ /dev/null
@@ -1,99 +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 java.math.BigDecimal;
-import java.math.BigInteger;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
-import java.util.Currency;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-import org.apache.tamaya.spi.PropertyAdapterSpi;
-
-/**
- * Test implementation current {@link org.apache.tamaya.spi.PropertyAdapterSpi}, which provides propertyAdapters
- * for some basic types.
- */
-@SuppressWarnings({"unchecked", "rawtypes"})
-public final class TestPropertyAdaptersSingletonSpi implements PropertyAdapterSpi {
-
- private Map<Class, PropertyAdapter<?>> propertyAdapters = new ConcurrentHashMap<>();
-
- private TestPropertyAdaptersSingletonSpi(){
- register(char.class, (s) -> s.charAt(0));
- register(int.class, Integer::parseInt);
- register(byte.class, Byte::parseByte);
- register(short.class, Short::parseShort);
- register(boolean.class, Boolean::parseBoolean);
- register(float.class, Float::parseFloat);
- register(double.class, Double::parseDouble);
-
- register(Character.class, (s) -> s.charAt(0));
- register(Integer.class, Integer::valueOf);
- register(Byte.class, Byte::valueOf);
- register(Short.class, Short::valueOf);
- register(Boolean.class, Boolean::valueOf);
- register(Float.class, Float::valueOf);
- register(Double.class, Double::valueOf);
- register(BigDecimal.class, BigDecimal::new);
- register(BigInteger.class, BigInteger::new);
-
- register(Currency.class, Currency::getInstance);
-
- register(LocalDate.class, LocalDate::parse);
- register(LocalTime.class, LocalTime::parse);
- register(LocalDateTime.class, LocalDateTime::parse);
- register(ZoneId.class, ZoneId::of);
- }
-
-
- @Override
- public <T> PropertyAdapter<T> register(Class<T> targetType, PropertyAdapter<T> codec){
- Objects.requireNonNull(targetType);
- Objects.requireNonNull(codec);
- return (PropertyAdapter<T>) propertyAdapters.put(targetType, codec);
- }
-
- @Override
- public <T> PropertyAdapter<T> getPropertyAdapter(Class<T> targetType, WithPropertyAdapter annotation){
- if(annotation!=null){
- Class<?> adapterType = annotation.value();
- if(!adapterType.equals(PropertyAdapter.class)){
- try{
- return (PropertyAdapter<T>)adapterType.newInstance();
- }
- catch(Exception e){
- throw new ConfigException("Failed to load PropertyAdapter: " + adapterType, e);
- }
- }
- }
- return (PropertyAdapter<T>) propertyAdapters.get(targetType);
- }
-
- @Override
- public boolean isTargetTypeSupported(Class<?> targetType){
- return propertyAdapters.containsKey(targetType);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/resources/META-INF/beans.xml b/dormant/api/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index 5207c9a..0000000
--- a/dormant/api/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy current the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
-</beans>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi b/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi
deleted file mode 100644
index 1b0cdd4..0000000
--- a/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationSpi
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.TestConfigServiceSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdapterSpi
----------------------------------------------------------------------
diff --git a/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdapterSpi b/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdapterSpi
deleted file mode 100644
index e9b04b4..0000000
--- a/dormant/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdapterSpi
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.TestPropertyAdaptersSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/old/AbstractClasspathAwarePropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/AbstractClasspathAwarePropertySource.java b/dormant/core/src/main/java/old/AbstractClasspathAwarePropertySource.java
new file mode 100644
index 0000000..47eb150
--- /dev/null
+++ b/dormant/core/src/main/java/old/AbstractClasspathAwarePropertySource.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.core.properties;
+
+import org.apache.tamaya.core.resource.Resource;
+import org.apache.tamaya.spi.ServiceContext;
+import org.apache.tamaya.core.resource.ResourceLoader;
+
+import java.util.*;
+
+public abstract class AbstractClasspathAwarePropertySource extends AbstractPropertySource {
+
+ private static final long serialVersionUID = 5484306410557548246L;
+ private ClassLoader classLoader;
+ private AbstractClasspathAwarePropertySource parentConfig;
+ private Set<String> sources;
+
+
+ public AbstractClasspathAwarePropertySource(ClassLoader classLoader, AbstractClasspathAwarePropertySource parentConfig,
+ Set<String> sourceExpressions, long configReadDT, Map<String, String> entries,
+ String name, Set<String> sources, List<Throwable> errors){
+ super(name);
+ Objects.requireNonNull(sources, "sources required.");
+ Objects.requireNonNull(classLoader, "classLoader required.");
+ this.sources = sources;
+ this.classLoader = classLoader;
+ this.parentConfig = parentConfig;
+ }
+
+ public AbstractClasspathAwarePropertySource(ClassLoader classLoader, AbstractClasspathAwarePropertySource parentConfig,
+ String sourceExpression){
+ super(parentConfig.getName());
+ Objects.requireNonNull(sources, "sources required.");
+ Objects.requireNonNull(sourceExpression, "sourceExpression required.");
+ List<Resource> resources = ServiceContext.getInstance().getSingleton(ResourceLoader.class).getResources(classLoader, sourceExpression);
+ for(Resource res : resources){
+ addSource(res.toString());
+ }
+ this.classLoader = classLoader;
+ this.parentConfig = parentConfig;
+ }
+
+ protected abstract void readSource(Map<String,String> targetMap, String source);
+
+ @Override
+ public Map<String,String> getProperties(){
+ Map<String,String> result = new HashMap<>();
+ for(String source : sources){
+ // if(!isSourceRead(source)){
+ readSource(result, source);
+ // }
+ }
+ return result;
+ }
+
+
+ public ClassLoader getClassLoader(){
+ return classLoader;
+ }
+
+ public AbstractClasspathAwarePropertySource getParentConfig(){
+ return this.parentConfig;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/old/AbstractPropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/AbstractPropertySource.java b/dormant/core/src/main/java/old/AbstractPropertySource.java
new file mode 100644
index 0000000..7d188b5
--- /dev/null
+++ b/dormant/core/src/main/java/old/AbstractPropertySource.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.properties;
+
+import java.io.Serializable;
+import java.util.*;
+
+import org.apache.tamaya.PropertySource;
+
+/**
+ * Abstract base class for implementing a {@link org.apache.tamaya.PropertySource}.
+ */
+public abstract class AbstractPropertySource implements PropertySource, Serializable{
+ /**
+ * serialVersionUID.
+ */
+ private static final long serialVersionUID = -6553955893879292837L;
+
+ protected String name;
+
+ /**
+ * Constructor.
+ */
+ protected AbstractPropertySource(String name){
+ this.name = Objects.requireNonNull(name);
+ }
+
+ @Override
+ public String getName(){
+ return name;
+ }
+
+
+ @Override
+ public Optional<String> get(String key){
+ return Optional.ofNullable(getProperties().get(key));
+ }
+
+ @Override
+ public String toString(){
+ return getClass().getSimpleName()) + "(name=" + getName()+")");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/old/AggregatedPropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/AggregatedPropertySource.java b/dormant/core/src/main/java/old/AggregatedPropertySource.java
new file mode 100644
index 0000000..14ea651
--- /dev/null
+++ b/dormant/core/src/main/java/old/AggregatedPropertySource.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.properties;
+
+import org.apache.tamaya.*;
+
+import java.util.*;
+
+/**
+ * Implementation for a {@link org.apache.tamaya.PropertySource} that is an aggregate current
+ * multiple child instances. Controlled by an {@link org.apache.tamaya.AggregationPolicy} the
+ * following aggregations are supported:
+ * <ul>
+ * <li><b>IGNORE_DUPLICATES: </b>Ignore all overrides.</li>
+ * <li><b>: </b></li>
+ * <li><b>: </b></li>
+ * <li><b>: </b></li>
+ * </ul>
+ */
+class AggregatedPropertySource extends AbstractPropertySource {
+
+ private static final long serialVersionUID = -1419376385695224799L;
+ private AggregationPolicy policy = AggregationPolicy.COMBINE;
+ private List<PropertySource> units = new ArrayList<>();
+ private PropertySource mutableProvider;
+
+ /**
+ * Creates a new instance.
+ * @param mutableProvider the provider instance that would be used for delegating
+ * change requests.
+ * @param policy
+ * The aggregation policy to be used.
+ * @param propertyMaps
+ * The property sets to be included.
+ */
+ public AggregatedPropertySource(String name, PropertySource mutableProvider, AggregationPolicy policy, List<PropertySource> propertyMaps) {
+ super(name);
+ this.policy = Objects.requireNonNull(policy);
+ units.addAll(propertyMaps);
+ this.mutableProvider = mutableProvider;
+ }
+
+ /**
+ * Get the {@link AggregationPolicy} for this instance.
+ *
+ * @return the {@link AggregationPolicy}, never {@code null}.
+ */
+ public AggregationPolicy getAggregationPolicy() {
+ return policy;
+ }
+
+ /**
+ * Return the names current the {@link org.apache.tamaya.PropertySource} instances to be
+ * aggregated in this instance, in the order current precedence (the first are
+ * the weakest).
+ *
+ * @return the ordered list current aggregated scope identifiers, never
+ * {@code null}.
+ */
+ public List<PropertySource> getConfigurationUnits() {
+ return Collections.unmodifiableList(units);
+ }
+
+ @Override
+ public Map<String,String> getProperties() {
+ Map<String, String> value = new HashMap<>();
+ for (PropertySource unit : units) {
+ for (Map.Entry<String, String> entry : unit.getProperties()
+ .entrySet()) {
+ String valueToAdd = this.policy.aggregate(entry.getKey(), value.get(entry.getKey()), entry.getValue());
+ if(valueToAdd==null){
+ value.remove(entry.getKey());
+ }
+ else{
+ value.put(entry.getKey(), valueToAdd);
+ }
+ }
+ }
+ return value;
+ }
+
+}