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/10/16 20:59:47 UTC
[05/11] incubator-tamaya git commit: TAMAYA-124: Unifying annotations
for SE and EE based injection.
TAMAYA-124: Unifying annotations for SE and EE based injection.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3beb5a44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3beb5a44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3beb5a44
Branch: refs/heads/master
Commit: 3beb5a44e0db97676a8535f9429ff19174b94a78
Parents: bb9e0f9
Author: anatole <an...@apache.org>
Authored: Fri Oct 16 19:31:25 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Fri Oct 16 19:31:25 2015 +0200
----------------------------------------------------------------------
.../resources/findbugs/findbugs-exclude.xml | 7 +
.../tamaya/examples/injection/Example.java | 8 +-
.../examples/injection/ExampleTemplate.java | 4 -
.../tamaya/clsupport/spi/package-info.java | 22 -
.../tamaya/inject/api/BaseDynamicValue.java | 123 ++++++
.../org/apache/tamaya/inject/api/Config.java | 80 ++++
.../apache/tamaya/inject/api/ConfigDefault.java | 41 ++
.../inject/api/ConfigDefaultSections.java | 43 ++
.../inject/api/ConfiguredItemSupplier.java | 41 ++
.../apache/tamaya/inject/api/DynamicValue.java | 183 ++++++++
.../tamaya/inject/api/InjectionUtils.java | 124 ++++++
.../apache/tamaya/inject/api/LoadPolicy.java | 48 +++
.../tamaya/inject/api/WithConfigOperator.java | 44 ++
.../inject/api/WithPropertyConverter.java | 45 ++
.../apache/tamaya/inject/api/package-info.java | 22 +
.../tamaya/event/ObservesConfigChange.java | 38 --
.../apache/tamaya/event/PropertyChangeSet.java | 125 ------
.../tamaya/event/PropertyChangeSetBuilder.java | 164 -------
.../org/apache/tamaya/event/package-info.java | 22 -
.../apache/tamaya/inject/BaseDynamicValue.java | 41 --
.../java/org/apache/tamaya/inject/Config.java | 79 ----
.../org/apache/tamaya/inject/ConfigDefault.java | 41 --
.../tamaya/inject/ConfigDefaultSections.java | 43 --
.../tamaya/inject/ConfigurationInjector.java | 2 +
.../tamaya/inject/ConfiguredItemSupplier.java | 41 --
.../org/apache/tamaya/inject/DynamicValue.java | 183 --------
.../org/apache/tamaya/inject/LoadPolicy.java | 48 ---
.../tamaya/inject/WithConfigOperator.java | 45 --
.../apache/tamaya/inject/WithLoadPolicy.java | 40 --
.../tamaya/inject/WithPropertyConverter.java | 45 --
.../internal/ConfigChangeCallbackMethod.java | 64 ---
.../ConfigTemplateInvocationHandler.java | 6 +-
.../tamaya/inject/internal/ConfiguredField.java | 9 +-
.../inject/internal/ConfiguredSetterMethod.java | 7 +-
.../tamaya/inject/internal/ConfiguredType.java | 68 +--
.../internal/DefaultConfigurationInjector.java | 17 +-
.../inject/internal/DefaultDynamicValue.java | 150 ++-----
.../tamaya/inject/internal/InjectionHelper.java | 183 ++++++++
.../tamaya/inject/internal/InjectionUtils.java | 271 ------------
.../tamaya/inject/internal/ModelPopulator.java | 1 +
.../internal/PropertyChangeSetListener.java | 37 --
.../internal/WeakConfigListenerManager.java | 124 ------
.../java/annottext/AnnotatedConfigBean.java | 28 +-
.../java/annottext/AnnotatedConfigTemplate.java | 18 +-
.../internal/DefaultDynamicValueTest.java | 12 +-
.../internal/WeakConfigListenerManagerTest.java | 91 ----
.../cdi/internal/CDIAwareServiceContext.java | 2 +-
.../tamaya/integration/cdi/ConfiguredClass.java | 21 +-
.../tamaya/integration/cdi/ConfiguredTest.java | 2 -
.../META-INF/javaconfiguration.properties | 18 +
.../apache/tamaya/integration/cdi/Config.java | 80 ----
.../tamaya/integration/cdi/ConfigDefault.java | 41 --
.../integration/cdi/ConfigDefaultSections.java | 43 --
.../integration/cdi/ConfigurationExtension.java | 11 +-
.../integration/cdi/ConfigurationProducer.java | 23 +-
.../integration/cdi/DefaultDynamicValue.java | 424 +++++++++++++++++++
.../integration/cdi/WithConfigOperator.java | 44 --
.../integration/cdi/WithPropertyConverter.java | 45 --
.../cdi/ConfigurationProducerTest.java | 4 +
.../integration/cdi/NotFoundNoDefault.java | 1 +
modules/pom.xml | 1 +
61 files changed, 1560 insertions(+), 2078 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
----------------------------------------------------------------------
diff --git a/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml b/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
index be0102f..0741f0e 100644
--- a/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
+++ b/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
@@ -111,4 +111,11 @@ under the License.
<Method name="checkConfigurationUpdate" />
</Match>
+ <Match>
+ <Class name="org.apache.tamaya.inject.internal.DefaultDynamicValue"/>
+ </Match>
+ <Match>
+ <Class name="org.apache.tamaya.integration.cdi.DefaultDynamicValue"/>
+ </Match>
+
</FindBugsFilter>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/Example.java
----------------------------------------------------------------------
diff --git a/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/Example.java b/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/Example.java
index 25db2a1..c4eec9b 100644
--- a/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/Example.java
+++ b/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/Example.java
@@ -18,9 +18,9 @@
*/
package org.apache.tamaya.examples.injection;
-import org.apache.tamaya.inject.ConfigDefaultSections;
-import org.apache.tamaya.inject.Config;
-import org.apache.tamaya.inject.ConfigDefault;
+import org.apache.tamaya.inject.api.Config;
+import org.apache.tamaya.inject.api.ConfigDefault;
+import org.apache.tamaya.inject.api.ConfigDefaultSections;
/**
* Simple example bean, mapped by default names mostly.
@@ -34,7 +34,7 @@ public class Example {
@ConfigDefault("No description available.")
private String description;
private int version;
- @Config(keys = "author")
+ @Config("author")
private String exampleAuthor;
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/ExampleTemplate.java
----------------------------------------------------------------------
diff --git a/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/ExampleTemplate.java b/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/ExampleTemplate.java
index 9592b1e..cfff52a 100644
--- a/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/ExampleTemplate.java
+++ b/examples/5-injection-example/src/main/java/org/apache/tamaya/examples/injection/ExampleTemplate.java
@@ -18,10 +18,6 @@
*/
package org.apache.tamaya.examples.injection;
-import org.apache.tamaya.inject.ConfigDefault;
-import org.apache.tamaya.inject.ConfigDefaultSections;
-import org.apache.tamaya.inject.Config;
-
/**
* Simple example bean, mapped by default names mostly.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/spi/package-info.java
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/spi/package-info.java b/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/spi/package-info.java
deleted file mode 100644
index 6eb85d3..0000000
--- a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/spi/package-info.java
+++ /dev/null
@@ -1,22 +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.
- */
-/**
- * Defines the SPI of the classloader support module.
- */
-package org.apache.tamaya.clsupport.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java
new file mode 100644
index 0000000..4c05da1
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java
@@ -0,0 +1,123 @@
+/*
+ * 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.inject.api;
+
+
+import java.io.Serializable;
+
+/**
+ * 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 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.<br/>
+ * Types of this interface can be used as injection targets in injected beans or as template resiult on configuration
+ * templates.
+ * <h3>Implementation Specification</h3>
+ * Implementation of this interface must be
+ * <ul>
+ * <li>Serializable, when also the item stored is serializable</li>
+ * <li>Thread safe</li>
+ * </ul>
+ *
+ * @param <T> The type of the value.
+ */
+public abstract class BaseDynamicValue<T> implements DynamicValue<T>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Performs a commit, if necessary, and returns the current value.
+ *
+ * @return the non-null value held by this {@code DynamicValue}
+ * @throws org.apache.tamaya.ConfigException if there is no value present
+ * @see DynamicValue#isPresent()
+ */
+ public T commitAndGet() {
+ commit();
+ return get();
+ }
+
+ /**
+ * 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 get() != null;
+ }
+
+
+ /**
+ * 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) {
+ T value = get();
+ if (value == null) {
+ return other;
+ }
+ return value;
+ }
+
+ /**
+ * Return the value if present, otherwise invoke {@code other} and return
+ * the result of that invocation.
+ *
+ * @param other a {@code ConfiguredItemSupplier} 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(ConfiguredItemSupplier<? extends T> other) {
+ T value = get();
+ if (value == null) {
+ return other.get();
+ }
+ return value;
+ }
+
+ /**
+ * Return the contained value, if present, otherwise throw an exception
+ * to be created by the provided supplier.
+ * <p>
+ * NOTE 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(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X {
+ T value = get();
+ if (value == null) {
+ throw exceptionSupplier.get();
+ }
+ return value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java
new file mode 100644
index 0000000..c63e5ad
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java
@@ -0,0 +1,80 @@
+/*
+ * 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.inject.api;
+
+
+import javax.enterprise.util.Nonbinding;
+import javax.inject.Qualifier;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 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 ConfigDefault}, {@link WithConfigOperator}, {@link WithPropertyConverter}.
+ *
+ * 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 = ConfigurationProvider.getConfiguration();}</li>
+ * <li>The current possible property keys are evaluated by calling {@code cfg.get("aValue");}</li>
+ * <li>if not successful, and a @ConfigDefault annotation is present, the default value is used.
+ * <li>If no value could be evaluated a ({@link org.apache.tamaya.ConfigException} is thrown.</li>
+ * <li>On success, since no type conversion is involved, the value is injected.</li>
+ * </ul>
+ *
+ * In the next example we explicitly define the property keys:
+ * {@code
+ * @ConfigDefaultSections("section1")
+ * pubic class ConfiguredItem{
+ *
+ * @ConfiguredProperty({"b", "[a.b.deprecated.keys]", "a"})
+ * @ConfigDefault("myDefaultValue")
+ * private String aValue;
+ * }
+ *
+ * Within this example we evaluate multiple possible keys (section1.b, a.b.deprecated.keys, section1.a). 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 "section1.b", "a.b.deprecated.keys", "section1.a"}. If no value has bee found,
+ * the configured default {@code myDefaultValue} is returned.
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
+public @interface Config {
+
+ /**
+ * 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.
+ */
+ @Nonbinding
+ String[] value() default {};
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefault.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefault.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefault.java
new file mode 100644
index 0000000..5b43a20
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefault.java
@@ -0,0 +1,41 @@
+/*
+ * 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.inject.api;
+
+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, ElementType.PARAMETER })
+public @interface ConfigDefault {
+
+ /**
+ * 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/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java
new file mode 100644
index 0000000..c6cec50
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java
@@ -0,0 +1,43 @@
+/*
+ * 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.inject.api;
+
+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.inject.ConfigProperty}
+ * 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 ConfigDefaultSections {
+
+ /**
+ * Allows to declare an section names that are prepended to resolve relative configuration keys.
+ * @return the section names to used for key resolution.
+ */
+ String[] value() default {};
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java
new file mode 100644
index 0000000..4775ef6
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java
@@ -0,0 +1,41 @@
+/*
+ * 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.inject.api;
+
+/**
+ * Represents a supplier of results.
+ * <p>
+ * <p>There is no requirement that a new or distinct result be returned each
+ * time the supplier is invoked.
+ * <p>
+ * <p>This is a functional interface,
+ * whose functional method is {@link #get()}.
+ *
+ * @param <T> the type of results supplied by this supplier
+ */
+//@FunctionalInterface
+public interface ConfiguredItemSupplier<T> {
+
+ /**
+ * Gets a result.
+ *
+ * @return a result
+ */
+ T get();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java
new file mode 100644
index 0000000..72c3ee9
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java
@@ -0,0 +1,183 @@
+/*
+ * 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.inject.api;
+
+import java.beans.PropertyChangeListener;
+
+
+/**
+ * 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 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.<br/>
+ * Types of this interface can be used as injection targets in injected beans or as template resiult on configuration
+ * templates.
+ * <h3>Implementation Specification</h3>
+ * Implementation of this interface must be
+ * <ul>
+ * <li>Serializable, when also the item stored is serializable</li>
+ * <li>Thread safe</li>
+ * </ul>
+ * @param <T> The type of the value.
+ */
+public interface DynamicValue<T> {
+
+ /**
+ * 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
+ }
+
+ /**
+ * Performs a commit, if necessary, and returns the current value.
+ *
+ * @return the non-null value held by this {@code DynamicValue}
+ * @throws org.apache.tamaya.ConfigException if there is no value present
+ *
+ * @see DynamicValue#isPresent()
+ */
+ T commitAndGet();
+
+ /**
+ * 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.
+ */
+ void commit();
+
+ /**
+ * Discards a new value that was published. No listeners will be informed.
+ */
+ void discard();
+
+ /**
+ * Access the {@link UpdatePolicy} used for updating this value.
+ * @return the update policy, never null.
+ */
+ UpdatePolicy getUpdatePolicy();
+
+ /**
+ * Add a listener to be called as weak reference, when this value has been changed.
+ * @param l the listener, not null
+ */
+ void addListener(PropertyChangeListener l);
+
+ /**
+ * Removes a listener to be called, when this value has been changed.
+ * @param l the listner to be removed, not null
+ */
+ void removeListener(PropertyChangeListener l);
+
+ /**
+ * If a value is present in this {@code DynamicValue}, 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()
+ */
+ T get();
+
+ /**
+ * Method to check for and apply a new value. Depending on the {@link UpdatePolicy}
+ * the value is immediately or deferred visible (or it may even be ignored completely).
+ * @return true, if a new value has been detected. The value may not be visible depending on the current
+ * {@link DynamicValue.UpdatePolicy} in place.
+ */
+ boolean updateValue();
+
+ /**
+ * Evaluates the current value dynamically from the underlying configuration.
+ * @return the current actual value, or null.
+ */
+ T evaluateValue();
+
+ /**
+ * Sets a new {@link UpdatePolicy}.
+ * @param updatePolicy the new policy, not null.
+ */
+ void setUpdatePolicy(UpdatePolicy updatePolicy);
+
+ /**
+ * Access a new value that has not yet been committed.
+ * @return the uncommitted new value, or null.
+ */
+ T getNewValue();
+
+ /**
+ * Return {@code true} if there is a value present, otherwise {@code false}.
+ *
+ * @return {@code true} if there is a value present, otherwise {@code false}
+ */
+ boolean isPresent();
+
+ /**
+ * 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}
+ */
+ T orElse(T other);
+
+ /**
+ * Return the value if present, otherwise invoke {@code other} and return
+ * the result of that invocation.
+ *
+ * @param other a {@code ConfiguredItemSupplier} 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
+ */
+ T orElseGet(ConfiguredItemSupplier<? extends T> other);
+
+ /**
+ * Return the contained value, if present, otherwise throw an exception
+ * to be created by the provided supplier.
+ *
+ * NOTE 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
+ */
+ <X extends Throwable> T orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java
new file mode 100644
index 0000000..43fe757
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java
@@ -0,0 +1,124 @@
+/*
+ * 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.inject.api;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Created by Anatole on 16.10.2015.
+ */
+public final class InjectionUtils {
+
+ private InjectionUtils(){}
+
+
+ /**
+ * Collects all keys to be be accessed as defined by any annotations of type
+ * {@link ConfigDefaultSections}, {@link Config}.
+ * @param field the (optionally) annotated field instance
+ * @return the regarding key list to be accessed fomr the {@link org.apache.tamaya.Configuration}.
+ */
+ public static List<String> getKeys(Field field) {
+ ConfigDefaultSections areasAnnot = field.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
+ return InjectionUtils.evaluateKeys(field, areasAnnot, field.getAnnotation(Config.class));
+ }
+
+ /**
+ * Collects all keys to be be accessed as defined by any annotations of type
+ * {@link ConfigDefaultSections}, {@link Config}.
+ * @param method the (optionally) annotated method instance
+ * @return the regarding key list to be accessed fomr the {@link org.apache.tamaya.Configuration}.
+ */
+ public static List<String> getKeys(Method method) {
+ ConfigDefaultSections areasAnnot = method.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
+ return InjectionUtils.evaluateKeys(method, areasAnnot, method.getAnnotation(Config.class));
+ }
+
+ /**
+ * Evaluates all absolute configuration key based on the member name found.
+ *
+ * @param areasAnnot the (optional) annotation definining areas to be looked up.
+ * @return the list current keys in order how they should be processed/looked up.
+ */
+ public static List<String> evaluateKeys(Member member, ConfigDefaultSections areasAnnot) {
+ List<String> keys = new ArrayList<>();
+ String name = member.getName();
+ String mainKey;
+ if (name.startsWith("get") || name.startsWith("set")) {
+ mainKey = Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ } else {
+ mainKey = Character.toLowerCase(name.charAt(0)) + name.substring(1);
+ }
+ keys.add(mainKey);
+ if (areasAnnot != null) {
+ // Add prefixed entries, including absolute (root) entry for "" area keys.
+ for (String area : areasAnnot.value()) {
+ if (!area.isEmpty()) {
+ keys.add(area + '.' + mainKey);
+ }
+ }
+ } else { // add package name
+ keys.add(member.getDeclaringClass().getName() + '.' + mainKey);
+ }
+ return keys;
+ }
+
+ /**
+ * Evaluates all absolute configuration key based on the annotations found on a class.
+ *
+ * @param areasAnnot the (optional) annotation definining areas to be looked up.
+ * @param propertyAnnotation the annotation on field/method level that may defined one or
+ * several keys to be looked up (in absolute or relative form).
+ * @return the list current keys in order how they should be processed/looked up.
+ */
+ public static List<String> evaluateKeys(Member member, ConfigDefaultSections areasAnnot, Config propertyAnnotation) {
+ if(propertyAnnotation==null){
+ return evaluateKeys(member, areasAnnot);
+ }
+ List<String> keys = new ArrayList<>(Arrays.asList(propertyAnnotation.value()));
+ if (keys.isEmpty()) {
+ keys.add(member.getName());
+ }
+ ListIterator<String> iterator = keys.listIterator();
+ while (iterator.hasNext()) {
+ String next = iterator.next();
+ if (next.startsWith("[") && next.endsWith("]")) {
+ // absolute key, strip away brackets, take key as is
+ iterator.set(next.substring(1, next.length() - 1));
+ } else {
+ if (areasAnnot != null && areasAnnot.value().length>0) {
+ // Remove original entry, since it will be replaced with prefixed entries
+ iterator.remove();
+ // Add prefixed entries, including absolute (root) entry for "" area keys.
+ for (String area : areasAnnot.value()) {
+ iterator.add(area.isEmpty() ? next : area + '.' + next);
+ }
+ }
+ }
+ }
+ return keys;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
new file mode 100644
index 0000000..7924222
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
@@ -0,0 +1,48 @@
+/*
+ * 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.inject.api;
+
+/**
+ * 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/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java
new file mode 100644
index 0000000..0574de8
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.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.inject.api;
+
+import org.apache.tamaya.ConfigOperator;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 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.TYPE, ElementType.METHOD, ElementType.PARAMETER})
+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 ConfigOperator> value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java
new file mode 100644
index 0000000..7abd8df
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java
@@ -0,0 +1,45 @@
+/*
+ * 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.inject.api;
+
+
+import org.apache.tamaya.spi.PropertyConverter;
+
+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, ElementType.PARAMETER})
+public @interface WithPropertyConverter {
+
+ /**
+ * 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.
+ */
+ Class<? extends PropertyConverter<?>> value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java
new file mode 100644
index 0000000..b5d8bc3
--- /dev/null
+++ b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+/**
+ * Common njection API.
+ */
+package org.apache.tamaya.inject.api;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java b/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
deleted file mode 100644
index 3c251ef..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/event/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.event;
-
-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.inject.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.inject.Config}
- * 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/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java b/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java
deleted file mode 100644
index 079f333..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSet.java
+++ /dev/null
@@ -1,125 +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.event;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * Event that contains a set of changed keys of a {@link org.apache.tamaya.spi.PropertySource}. Any values must
- * be obtained by calling the {@link org.apache.tamaya.Configuration} due to security reasons. This event can be used
- * by the {@link org.apache.tamaya.spi.PropertySource} implementation to cleanup caches as needed.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertyChangeSetBuilder}.
- */
-public final class PropertyChangeSet implements Serializable{
- /** The serialVersionUID. */
- private static final long serialVersionUID = 1L;
- /** The base property source name. */
- private String propertySourceName;
- /** The timestamp of the change. */
- private long timestamp = System.currentTimeMillis();
- /**
- * The recorded keys added.
- */
- final SortedSet<String> addedKeys = new TreeSet<>();
-
- /**
- * The recorded keys updated.
- */
- final SortedSet<String> updatedKeys = new TreeSet<>();
-
- /**
- * The recorded keys removed.
- */
- final SortedSet<String> removedKeys = new TreeSet<>();
-
-
- /**
- * Constructor used by {@link PropertyChangeSetBuilder}.
- * @param builder The builder instance, not null.
- */
- PropertyChangeSet(PropertyChangeSetBuilder builder) {
- this.propertySourceName = Objects.requireNonNull(builder.propertySourceName);
- this.addedKeys.addAll(builder.addedKeys);
- this.removedKeys.addAll(builder.removedKeys);
- this.updatedKeys.addAll(builder.updatedKeys);
- }
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, never null.
- */
- public String getPropertySourceName(){
- return this.propertySourceName;
- }
-
- /**
- * Get the timestamp of this changeset. This allows to track, if a ChangeSet was already applied.
- * @return the timestamp
- */
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the keys added.
- * @return the added keys, never null.
- */
- public Collection<String> getKeysAdded(){
- return Collections.unmodifiableCollection(this.addedKeys);
- }
-
- /**
- * Get the keys removed.
- * @return the removed keys, never null.
- */
- public Collection<String> getKeysRemoved(){
- return Collections.unmodifiableCollection(this.removedKeys);
- }
-
- /**
- * Get the updated keys.
- * @return the updated keys, never null.
- */
- public Collection<String> getKeysUpdated(){
- return Collections.unmodifiableCollection(this.addedKeys);
- }
-
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.addedKeys.isEmpty() && this.updatedKeys.isEmpty() && this.removedKeys.isEmpty();
- }
-
-
- @Override
- public String toString() {
- return "ConfigChangeSet{" +
- "propertySourceName=" + propertySourceName +
- ", timestamp=" + timestamp +
- ", addedKeys=" + addedKeys +
- ", updatedKeys=" + updatedKeys +
- ", removedKeys=" + removedKeys +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java b/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java
deleted file mode 100644
index 73fb53f..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/event/PropertyChangeSetBuilder.java
+++ /dev/null
@@ -1,164 +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.event;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * 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 applyChanges the changes to the provider/configuration, including triggering current regarding
- * change events.
- * <p>
- * For appropriate conversion a {@code Function<String, Codec>} can be applied, which performs correct conversion,
- * when changed values are set. This function enables connecting e.g. setters on a configuration template with
- * the corresponding conversion logic, so the template calls are correctly converted back.
- */
-public final class PropertyChangeSetBuilder {
- /**
- * The recorded changes.
- */
- final SortedSet<String> addedKeys = new TreeSet<>();
-
- /**
- * The recorded changes.
- */
- final SortedSet<String> updatedKeys = new TreeSet<>();
-
- /**
- * The recorded changes.
- */
- final SortedSet<String> removedKeys = new TreeSet<>();
-
- /**
- * The underlying configuration/provider.
- */
- String propertySourceName;
-
- /**
- * Constructor.
- *
- * @param source the underlying configuration/provider, not null.
- */
- private PropertyChangeSetBuilder(PropertySource source) {
- this.propertySourceName = Objects.requireNonNull(source).getName();
- }
-
- /**
- * Creates a new instance current this builder.
- *
- * @param source the underlying property provider/configuration, not null.
- * @return the builder for chaining.
- */
- public static PropertyChangeSetBuilder of(PropertySource source) {
- return new PropertyChangeSetBuilder(source);
- }
-
-
- /**
- * Marks the given key(s) as removed.
- *
- * @param keys the keys removed
- * @return the builder for chaining.
- */
- public PropertyChangeSetBuilder remove(String... keys) {
- for (String removeKey : keys) {
- this.removedKeys.add(removeKey);
- }
- return this;
- }
-
- /**
- * Marks the given key(s) as added.
- *
- * @param keys the keys added
- * @return the builder for chaining.
- */
- public PropertyChangeSetBuilder add(String... keys) {
- for (String addKey : keys) {
- this.addedKeys.add(addKey);
- }
- return this;
- }
-
- /**
- * Marks the given key(s) as updaed.
- *
- * @param keys the keys updated
- * @return the builder for chaining.
- */
- public PropertyChangeSetBuilder update(String... keys) {
- for (String uptKey : keys) {
- this.updatedKeys.add(uptKey);
- }
- return this;
- }
-
-
- /**
- * Compares the two property maps and adds the corresponding updated/aded/removed keys to the builder.
- *
- * @param map1 the source map, not null.
- * @param map2 the target map, not null.
- * @return the builder for chaining.
- */
- public PropertyChangeSetBuilder addChanges(Map<String, String> map1, Map<String, String> map2) {
- for (Map.Entry<String, String> en : map1.entrySet()) {
- String val = map2.get(en.getKey());
- if (val == null) {
- remove(en.getKey());
- } else if (!val.equals(en.getValue())) {
- update(en.getKey());
- }
- }
- for (Map.Entry<String, String> en : map2.entrySet()) {
- String val = map1.get(en.getKey());
- if (val == null) {
- add(en.getKey());
- }
- // update case already handled before!
- }
- return this;
- }
-
- /**
- * Builds s new change set.
- *
- * @return a new change set, never null.
- */
- public PropertyChangeSet build() {
- return new PropertyChangeSet(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "PropertyChangeEventBuilder [propertySourceName=" + propertySourceName + ", " +
- ", added=" + addedKeys + ", updated=" + updatedKeys + ", removed=" + removedKeys + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/event/package-info.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/event/package-info.java b/modules/injection/src/main/java/org/apache/tamaya/event/package-info.java
deleted file mode 100644
index e1e5a33..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/event/package-info.java
+++ /dev/null
@@ -1,22 +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.
- */
-/**
- * This package provides artifacts to distribute property changes, so instances can observe the changes.
- */
-package org.apache.tamaya.event;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/BaseDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/BaseDynamicValue.java b/modules/injection/src/main/java/org/apache/tamaya/inject/BaseDynamicValue.java
deleted file mode 100644
index c905ad2..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/BaseDynamicValue.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.inject;
-
-
-/**
- * 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 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.<br/>
- * Types of this interface can be used as injection targets in injected beans or as template resiult on configuration
- * templates.
- * <h3>Implementation Specification</h3>
- * Implementation of this interface must be
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- *
- * @param <T> The type of the value.
- */
-public abstract class BaseDynamicValue<T> implements DynamicValue<T> {
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/Config.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/Config.java b/modules/injection/src/main/java/org/apache/tamaya/inject/Config.java
deleted file mode 100644
index 0b1abb6..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/Config.java
+++ /dev/null
@@ -1,79 +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.inject;
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * 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 ConfigDefault},
- * {@link WithLoadPolicy}, {@link WithConfigOperator}, {@link WithPropertyConverter}.
- *
- * 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 WithLoadPolicy}
- * annotations).</li>
- * </ul>
- *
- * In the next example we explicitly define the property keys:
- * {@code
- * pubic class ConfiguredItem{
- *
- * @ConfiguredProperty
- * @ConfiguredProperty(keys={"a.b.value", "a.b.deprecated.keys"})
- * @ConfiguredProperty(keys="a")
- * 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 ConfigDefault} annotation. Interesting here
- * is that this keys is not static, it is evaluated.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface Config {
-
- /**
- * 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/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefault.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefault.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefault.java
deleted file mode 100644
index 7a0b923..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefault.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.inject;
-
-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 ConfigDefault {
-
- /**
- * 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/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefaultSections.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefaultSections.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefaultSections.java
deleted file mode 100644
index 023fb72..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigDefaultSections.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.inject;
-
-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 Config}
- * 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 ConfigDefaultSections {
-
- /**
- * Allows to declare an section names that are prepended to resolve relative configuration keys.
- * @return the section names to used for key resolution.
- */
- String[] value() default {};
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
index 16a2a90..9432ba2 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
@@ -19,6 +19,8 @@
package org.apache.tamaya.inject;
+import org.apache.tamaya.inject.api.ConfiguredItemSupplier;
+
/**
* Accessor interface for injection of configuration and configuration templates.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredItemSupplier.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredItemSupplier.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredItemSupplier.java
deleted file mode 100644
index 2cb9af1..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredItemSupplier.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.inject;
-
-/**
- * Represents a supplier of results.
- * <p>
- * <p>There is no requirement that a new or distinct result be returned each
- * time the supplier is invoked.
- * <p>
- * <p>This is a functional interface,
- * whose functional method is {@link #get()}.
- *
- * @param <T> the type of results supplied by this supplier
- */
-//@FunctionalInterface
-public interface ConfiguredItemSupplier<T> {
-
- /**
- * Gets a result.
- *
- * @return a result
- */
- T get();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/DynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/DynamicValue.java b/modules/injection/src/main/java/org/apache/tamaya/inject/DynamicValue.java
deleted file mode 100644
index b420c71..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/DynamicValue.java
+++ /dev/null
@@ -1,183 +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.inject;
-
-import java.beans.PropertyChangeListener;
-
-
-/**
- * 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 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.<br/>
- * Types of this interface can be used as injection targets in injected beans or as template resiult on configuration
- * templates.
- * <h3>Implementation Specification</h3>
- * Implementation of this interface must be
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- * @param <T> The type of the value.
- */
-public interface DynamicValue<T> {
-
- /**
- * 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
- }
-
- /**
- * Performs a commit, if necessary, and returns the current value.
- *
- * @return the non-null value held by this {@code DynamicValue}
- * @throws org.apache.tamaya.ConfigException if there is no value present
- *
- * @see DynamicValue#isPresent()
- */
- T commitAndGet();
-
- /**
- * 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.
- */
- void commit();
-
- /**
- * Discards a new value that was published. No listeners will be informed.
- */
- void discard();
-
- /**
- * Access the {@link UpdatePolicy} used for updating this value.
- * @return the update policy, never null.
- */
- UpdatePolicy getUpdatePolicy();
-
- /**
- * Add a listener to be called as weak reference, when this value has been changed.
- * @param l the listener, not null
- */
- void addListener(PropertyChangeListener l);
-
- /**
- * Removes a listener to be called, when this value has been changed.
- * @param l the listner to be removed, not null
- */
- void removeListener(PropertyChangeListener l);
-
- /**
- * If a value is present in this {@code DynamicValue}, 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()
- */
- T get();
-
- /**
- * Method to check for and apply a new value. Depending on the {@link UpdatePolicy}
- * the value is immediately or deferred visible (or it may even be ignored completely).
- * @return true, if a new value has been detected. The value may not be visible depending on the current
- * {@link org.apache.tamaya.inject.DynamicValue.UpdatePolicy} in place.
- */
- boolean updateValue();
-
- /**
- * Evaluates the current value dynamically from the underlying configuration.
- * @return the current actual value, or null.
- */
- T evaluateValue();
-
- /**
- * Sets a new {@link UpdatePolicy}.
- * @param updatePolicy the new policy, not null.
- */
- void setUpdatePolicy(UpdatePolicy updatePolicy);
-
- /**
- * Access a new value that has not yet been committed.
- * @return the uncommitted new value, or null.
- */
- T getNewValue();
-
- /**
- * Return {@code true} if there is a value present, otherwise {@code false}.
- *
- * @return {@code true} if there is a value present, otherwise {@code false}
- */
- boolean isPresent();
-
- /**
- * 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}
- */
- T orElse(T other);
-
- /**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
- *
- * @param other a {@code ConfiguredItemSupplier} 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
- */
- T orElseGet(ConfiguredItemSupplier<? extends T> other);
-
- /**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
- *
- * NOTE 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
- */
- <X extends Throwable> T orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/LoadPolicy.java b/modules/injection/src/main/java/org/apache/tamaya/inject/LoadPolicy.java
deleted file mode 100644
index 90c1e8f..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/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.inject;
-
-/**
- * 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/3beb5a44/modules/injection/src/main/java/org/apache/tamaya/inject/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/WithConfigOperator.java b/modules/injection/src/main/java/org/apache/tamaya/inject/WithConfigOperator.java
deleted file mode 100644
index e43ebc3..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/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.inject;
-
-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.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();
-
-}