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/06 09:57:13 UTC
[5/9] incubator-tamaya git commit: Renamed some annotations to align
with new CDI based injection solution.
Renamed some annotations to align with new CDI based injection solution.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3e85e536
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3e85e536
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3e85e536
Branch: refs/heads/master
Commit: 3e85e536177ba826d7f9dd657411d01fcdc3063e
Parents: febc291
Author: anatole <an...@apache.org>
Authored: Tue Oct 6 09:49:37 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Tue Oct 6 09:55:41 2015 +0200
----------------------------------------------------------------------
.../tamaya/event/ObservesConfigChange.java | 2 +-
.../apache/tamaya/inject/ConfigAutoInject.java | 36 +++++++++
.../org/apache/tamaya/inject/ConfigDefault.java | 41 ++++++++++
.../tamaya/inject/ConfigDefaultSections.java | 43 +++++++++++
.../apache/tamaya/inject/ConfigProperty.java | 79 ++++++++++++++++++++
.../tamaya/inject/ConfiguredProperty.java | 79 --------------------
.../apache/tamaya/inject/ConfiguredType.java | 51 -------------
.../org/apache/tamaya/inject/DefaultValue.java | 41 ----------
.../tamaya/inject/internal/ConfiguredType.java | 25 ++++---
.../internal/DefaultConfigurationInjector.java | 11 +--
.../tamaya/inject/internal/InjectionUtils.java | 38 +++++-----
.../java/annottext/AnnotatedConfigBean.java | 20 ++---
.../java/annottext/AnnotatedConfigTemplate.java | 16 ++--
.../internal/DefaultDynamicValueTest.java | 8 +-
14 files changed, 261 insertions(+), 229 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/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
index 9fc6d9b..0ca0017 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/event/ObservesConfigChange.java
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
* 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.ConfiguredProperty}
+ * input configurations for configuring a class/instance. Additionally {@link org.apache.tamaya.inject.ConfigProperty}
* annotations can be added that allows to constrain changes to some limited properties.
*/
@Retention(RetentionPolicy.RUNTIME)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigAutoInject.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigAutoInject.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigAutoInject.java
new file mode 100644
index 0000000..8ab1eea
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigAutoInject.java
@@ -0,0 +1,36 @@
+/*
+ * 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 of a configured bean. The configuration keys
+ * to be resolved are basically determined by the {@link ConfigProperty}
+ * annotation(s). When this annotation is added the injection systems tries to inject all
+ * fields found, also including fields not annotated with {@code @ConfigProperty}.
+ * Fields not to be injected ccan be annotated with {@code @NoConfig} to exclude them
+ * being eleceted for injection.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE })
+public @interface ConfigAutoInject {}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/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
new file mode 100644
index 0000000..7a0b923
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/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;
+
+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/3e85e536/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
new file mode 100644
index 0000000..16e2552
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/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;
+
+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 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/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigProperty.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigProperty.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigProperty.java
new file mode 100644
index 0000000..c09c0bc
--- /dev/null
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigProperty.java
@@ -0,0 +1,79 @@
+/*
+ * 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 ConfigProperty {
+
+ /**
+ * 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/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredProperty.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredProperty.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredProperty.java
deleted file mode 100644
index b84df0d..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredProperty.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 DefaultValue},
- * {@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 DefaultValue} annotation. Interesting here
- * is that this keys is not static, it is evaluated.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface ConfiguredProperty {
-
- /**
- * 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/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredType.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredType.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredType.java
deleted file mode 100644
index 78d1ea2..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfiguredType.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 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 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 ConfiguredType {
-
- /**
- * Allows to declare an section names that are prepended to resolve relative configuration keys.
- * @return the section names to used for key resolution.
- */
- String[] defaultSections() default {};
-
- /**
- * Property that can be used to let Tamaya automatically configure all matching fields and setter methods.
- * By default the configuration keys are built using the field's or method's name.
- *
- * @return true, for letting Tamaya utomatically configure a type.
- */
- boolean autoConfigure() default false;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultValue.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultValue.java b/modules/injection/src/main/java/org/apache/tamaya/inject/DefaultValue.java
deleted file mode 100644
index ad6fb95..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/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.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 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/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
index 92281bf..697cecc 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredType.java
@@ -25,7 +25,9 @@ import java.util.*;
import java.util.logging.Logger;
import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.inject.ConfiguredProperty;
+import org.apache.tamaya.inject.ConfigAutoInject;
+import org.apache.tamaya.inject.ConfigDefaultSections;
+import org.apache.tamaya.inject.ConfigProperty;
import org.apache.tamaya.inject.NoConfig;
import org.apache.tamaya.event.ObservesConfigChange;
import org.apache.tamaya.event.PropertyChangeSet;
@@ -64,11 +66,12 @@ public class ConfiguredType {
public ConfiguredType(Class type) {
this.type = Objects.requireNonNull(type);
- org.apache.tamaya.inject.ConfiguredType confType = (org.apache.tamaya.inject.ConfiguredType)
- type.getAnnotation(org.apache.tamaya.inject.ConfiguredType.class);
+ ConfigDefaultSections confType = (ConfigDefaultSections)
+ type.getAnnotation(ConfigDefaultSections.class);
+ ConfigAutoInject autoInject = (ConfigAutoInject)type.getAnnotation(ConfigAutoInject.class);
if(confType!=null){
- initFields(type, confType.autoConfigure());
- initMethods(type, confType.autoConfigure());
+ initFields(type, autoInject!=null);
+ initMethods(type, autoInject!=null);
}else{
initFields(type, false);
initMethods(type, false);
@@ -121,7 +124,7 @@ public class ConfiguredType {
}
if(isConfiguredMethod(m) || autoConfigure) {
ObservesConfigChange observesAnnot = m.getAnnotation(ObservesConfigChange.class);
- ConfiguredProperty propAnnot = m.getAnnotation(ConfiguredProperty.class);
+ ConfigProperty propAnnot = m.getAnnotation(ConfigProperty.class);
if (type.isInterface()) {
// it is a template
if (observesAnnot != null && m.isDefault()) {
@@ -147,7 +150,7 @@ public class ConfiguredType {
}
}
- private boolean addPropertySetter(Method m, ConfiguredProperty prop) {
+ private boolean addPropertySetter(Method m, ConfigProperty prop) {
if (prop!=null) {
if (m.getParameterTypes().length == 1) {
// getter method
@@ -210,7 +213,7 @@ public class ConfiguredType {
public static boolean isConfigured(Class type) {
- if (type.getAnnotation(org.apache.tamaya.inject.ConfiguredType.class) != null) {
+ if (type.getAnnotation(ConfigDefaultSections.class) != null) {
return true;
}
// if no class level annotation is there we might have field level annotations only
@@ -229,11 +232,11 @@ public class ConfiguredType {
}
public static boolean isConfiguredField(Field field) {
- return field.isAnnotationPresent(ConfiguredProperty.class);
+ return field.isAnnotationPresent(ConfigProperty.class);
}
public static boolean isConfiguredMethod(Method method) {
- return method.isAnnotationPresent(ConfiguredProperty.class);
+ return method.isAnnotationPresent(ConfigProperty.class);
}
public Class getType() {
@@ -266,6 +269,6 @@ public class ConfiguredType {
@Override
public String toString() {
- return "ConfiguredType{"+ this.getType().getName() + '}';
+ return "ConfigDefaultSections{"+ this.getType().getName() + '}';
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
index d59f090..41ba8ec 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
@@ -20,6 +20,8 @@ package org.apache.tamaya.inject.internal;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.event.ObservesConfigChange;
+import org.apache.tamaya.inject.ConfigDefaultSections;
+import org.apache.tamaya.inject.ConfigProperty;
import org.apache.tamaya.inject.ConfigurationInjector;
import javax.annotation.Priority;
@@ -32,7 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.apache.tamaya.inject.ConfiguredItemSupplier;
-import org.apache.tamaya.inject.ConfiguredProperty;
import org.apache.tamaya.inject.NoConfig;
/**
@@ -59,7 +60,7 @@ public final class DefaultConfigurationInjector implements ConfigurationInjector
configuredTypes.put(type, confType);
}
return confType;
-// return configuredTypes.computeIfAbsent(type, ConfiguredType::new);
+// return configuredTypes.computeIfAbsent(type, ConfigDefaultSections::new);
}
/**
@@ -68,14 +69,14 @@ public final class DefaultConfigurationInjector implements ConfigurationInjector
* @return true, if the type, a method or field has Tamaya config annotation on it.
*/
private boolean isConfigured(Class<?> type) {
- if(type.getClass().isAnnotationPresent(org.apache.tamaya.inject.ConfiguredType.class)){
+ if(type.getClass().isAnnotationPresent(ConfigDefaultSections.class)){
return true;
}
for (Field f : type.getDeclaredFields()) {
if (f.isAnnotationPresent(NoConfig.class)) {
return true;
}
- if (f.isAnnotationPresent(ObservesConfigChange.class) || f.isAnnotationPresent(ConfiguredProperty.class)) {
+ if (f.isAnnotationPresent(ObservesConfigChange.class) || f.isAnnotationPresent(ConfigProperty.class)) {
return true;
}
}
@@ -83,7 +84,7 @@ public final class DefaultConfigurationInjector implements ConfigurationInjector
if (m.isAnnotationPresent(NoConfig.class)) {
return true;
}
- if (m.isAnnotationPresent(ObservesConfigChange.class) || m.isAnnotationPresent(ConfiguredProperty.class)) {
+ if (m.isAnnotationPresent(ObservesConfigChange.class) || m.isAnnotationPresent(ConfigProperty.class)) {
return true;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
index 3dddc20..ce7e43d 100644
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
+++ b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionUtils.java
@@ -32,9 +32,9 @@ import java.util.logging.Logger;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.ConfiguredType;
-import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultValue;
+import org.apache.tamaya.inject.ConfigDefaultSections;
+import org.apache.tamaya.inject.ConfigProperty;
+import org.apache.tamaya.inject.ConfigDefault;
import org.apache.tamaya.inject.WithPropertyConverter;
import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
import org.apache.tamaya.spi.PropertyConverter;
@@ -71,7 +71,7 @@ final class InjectionUtils {
* 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, ConfiguredType areasAnnot, ConfiguredProperty propertyAnnotation) {
+ public static List<String> evaluateKeys(Member member, ConfigDefaultSections areasAnnot, ConfigProperty propertyAnnotation) {
if(propertyAnnotation==null){
return evaluateKeys(member, areasAnnot);
}
@@ -86,11 +86,11 @@ final class InjectionUtils {
// absolute key, strip away brackets, take key as is
iterator.set(next.substring(1, next.length() - 1));
} else {
- if (areasAnnot != null && areasAnnot.defaultSections().length>0) {
+ 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.defaultSections()) {
+ for (String area : areasAnnot.value()) {
iterator.add(area.isEmpty() ? next : area + '.' + next);
}
}
@@ -105,7 +105,7 @@ final class InjectionUtils {
* @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, ConfiguredType areasAnnot) {
+ public static List<String> evaluateKeys(Member member, ConfigDefaultSections areasAnnot) {
List<String> keys = new ArrayList<>();
String name = member.getName();
String mainKey;
@@ -117,7 +117,7 @@ final class InjectionUtils {
keys.add(mainKey);
if (areasAnnot != null) {
// Add prefixed entries, including absolute (root) entry for "" area keys.
- for (String area : areasAnnot.defaultSections()) {
+ for (String area : areasAnnot.value()) {
if (!area.isEmpty()) {
keys.add(area + '.' + mainKey);
}
@@ -134,7 +134,7 @@ final class InjectionUtils {
* @return the keys to be returned, or null.
*/
public static String getConfigValue(Method method) {
- ConfiguredType areasAnnot = method.getDeclaringClass().getAnnotation(ConfiguredType.class);
+ ConfigDefaultSections areasAnnot = method.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
return getConfigValueInternal(method, areasAnnot);
}
@@ -145,7 +145,7 @@ final class InjectionUtils {
* @return the keys to be returned, or null.
*/
public static String getConfigValue(Field field) {
- ConfiguredType areasAnnot = field.getDeclaringClass().getAnnotation(ConfiguredType.class);
+ ConfigDefaultSections areasAnnot = field.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
return getConfigValueInternal(field, areasAnnot);
}
@@ -154,9 +154,9 @@ final class InjectionUtils {
*
* @return the keys to be returned, or null.
*/
- private static String getConfigValueInternal(AnnotatedElement element, ConfiguredType areasAnnot) {
- ConfiguredProperty prop = element.getAnnotation(ConfiguredProperty.class);
- DefaultValue defaultAnnot = element.getAnnotation(DefaultValue.class);
+ private static String getConfigValueInternal(AnnotatedElement element, ConfigDefaultSections areasAnnot) {
+ ConfigProperty prop = element.getAnnotation(ConfigProperty.class);
+ ConfigDefault defaultAnnot = element.getAnnotation(ConfigDefault.class);
List<String> keys;
if (prop == null) {
keys = InjectionUtils.evaluateKeys((Member) element, areasAnnot);
@@ -172,24 +172,24 @@ final class InjectionUtils {
/**
* Collects all keys to be be accessed as defined by any annotations of type
- * {@link ConfiguredType}, {@link org.apache.tamaya.inject.ConfiguredProperty}.
+ * {@link ConfigDefaultSections}, {@link ConfigProperty}.
* @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) {
- ConfiguredType areasAnnot = field.getDeclaringClass().getAnnotation(ConfiguredType.class);
- return InjectionUtils.evaluateKeys(field, areasAnnot, field.getAnnotation(ConfiguredProperty.class));
+ ConfigDefaultSections areasAnnot = field.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
+ return InjectionUtils.evaluateKeys(field, areasAnnot, field.getAnnotation(ConfigProperty.class));
}
/**
* Collects all keys to be be accessed as defined by any annotations of type
- * {@link ConfiguredType}, {@link org.apache.tamaya.inject.ConfiguredProperty}.
+ * {@link ConfigDefaultSections}, {@link ConfigProperty}.
* @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) {
- ConfiguredType areasAnnot = method.getDeclaringClass().getAnnotation(ConfiguredType.class);
- return InjectionUtils.evaluateKeys(method, areasAnnot, method.getAnnotation(ConfiguredProperty.class));
+ ConfigDefaultSections areasAnnot = method.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
+ return InjectionUtils.evaluateKeys(method, areasAnnot, method.getAnnotation(ConfigProperty.class));
}
private static String evaluteConfigValue(List<String> keys) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java b/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
index 8e02813..5725992 100644
--- a/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
+++ b/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
@@ -20,8 +20,8 @@ package annottext;
import org.apache.tamaya.event.ObservesConfigChange;
import org.apache.tamaya.event.PropertyChangeSet;
-import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultValue;
+import org.apache.tamaya.inject.ConfigDefault;
+import org.apache.tamaya.inject.ConfigProperty;
import org.apache.tamaya.inject.DynamicValue;
import org.apache.tamaya.inject.LoadPolicy;
import org.apache.tamaya.inject.NoConfig;
@@ -38,22 +38,22 @@ import java.util.List;
@WithLoadPolicy(LoadPolicy.INITIAL)
public class AnnotatedConfigBean {
- @ConfiguredProperty(keys = {"foo.bar.myprop", "mp", "common.testdata.myProperty"})
- @DefaultValue("ET")
+ @ConfigProperty(keys = {"foo.bar.myprop", "mp", "common.testdata.myProperty"})
+ @ConfigDefault("ET")
// @ConfigLoadPolicy(listener = MyListener.class)
public String myParameter;
- @ConfiguredProperty(keys = "simple_value")
+ @ConfigProperty(keys = "simple_value")
@WithLoadPolicy(LoadPolicy.LAZY)
public String simpleValue;
- @ConfiguredProperty
+ @ConfigProperty
String anotherValue;
- @ConfiguredProperty(keys = "host.name")
+ @ConfigProperty(keys = "host.name")
private String hostName;
- @ConfiguredProperty(keys = "host.name")
+ @ConfigProperty(keys = "host.name")
private DynamicValue<String> dynamicHostname;
@NoConfig
@@ -78,12 +78,12 @@ public class AnnotatedConfigBean {
public static final String CONSTANT = "a constant";
- @ConfiguredProperty(keys = "java.version")
+ @ConfigProperty(keys = "java.version")
void setJavaVersion(String version){
this.javaVersion = version;
}
- @ConfiguredProperty(keys="b")
+ @ConfigProperty(keys="b")
@ObservesConfigChange
public void callBackTest(PropertyChangeSet value){
this.events.add(value.toString());
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java b/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
index 900fee9..62df15d 100644
--- a/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
+++ b/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
@@ -18,8 +18,8 @@
*/
package annottext;
-import org.apache.tamaya.inject.ConfiguredProperty;
-import org.apache.tamaya.inject.DefaultValue;
+import org.apache.tamaya.inject.ConfigDefault;
+import org.apache.tamaya.inject.ConfigProperty;
import org.apache.tamaya.inject.DynamicValue;
import org.apache.tamaya.inject.LoadPolicy;
import org.apache.tamaya.inject.WithLoadPolicy;
@@ -32,22 +32,22 @@ import org.apache.tamaya.inject.WithLoadPolicy;
@WithLoadPolicy(LoadPolicy.INITIAL)
public interface AnnotatedConfigTemplate {
- @ConfiguredProperty(keys = {"foo.bar.myprop", "mp","common.testdata.myProperty"})
- @DefaultValue("ET")
+ @ConfigProperty(keys = {"foo.bar.myprop", "mp","common.testdata.myProperty"})
+ @ConfigDefault("ET")
// @ConfigLoadPolicy(listener = MyListener.class)
String myParameter();
- @ConfiguredProperty(keys = "simple_value")
+ @ConfigProperty(keys = "simple_value")
@WithLoadPolicy(LoadPolicy.LAZY)
String simpleValue();
- @ConfiguredProperty
+ @ConfigProperty
String simplestValue();
- @ConfiguredProperty(keys = "host.name")
+ @ConfigProperty(keys = "host.name")
String hostName();
- @ConfiguredProperty(keys = "host.name")
+ @ConfigProperty(keys = "host.name")
DynamicValue<String> getDynamicValue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e85e536/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java b/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
index d95123d..805ca76 100644
--- a/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
+++ b/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
@@ -21,8 +21,8 @@ package org.apache.tamaya.inject.internal;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.builder.ConfigurationBuilder;
+import org.apache.tamaya.inject.ConfigProperty;
import org.apache.tamaya.inject.ConfiguredItemSupplier;
-import org.apache.tamaya.inject.ConfiguredProperty;
import org.apache.tamaya.inject.DynamicValue;
import org.apache.tamaya.spi.PropertyConverter;
import org.apache.tamaya.spi.PropertySource;
@@ -42,13 +42,13 @@ import static org.junit.Assert.*;
*/
public class DefaultDynamicValueTest {
- @ConfiguredProperty(keys="a")
+ @ConfigProperty(keys="a")
String myValue;
- @ConfiguredProperty(keys="a")
+ @ConfigProperty(keys="a")
String myValue2;
- @ConfiguredProperty(keys="a")
+ @ConfigProperty(keys="a")
void setterMethod(String value){
}