You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2014/12/07 02:28:39 UTC
[1/2] incubator-tamaya git commit: TAMAYA-19: Code cleanup - renamed
annotation, fixed bugs. Removed unused/useless code including tests.
Repository: incubator-tamaya
Updated Branches:
refs/heads/master a32cac85f -> 5c36d32dc
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/properties/ClasspathPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/properties/ClasspathPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/internal/properties/ClasspathPropertyProvider.java
index dc71c1a..f6aa4f6 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/properties/ClasspathPropertyProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/properties/ClasspathPropertyProvider.java
@@ -1,150 +1,150 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.internal.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.core.properties.AbstractPropertyProvider;
-import org.apache.tamaya.core.properties.ClasspathModulePropertyProvider;
-
-import java.util.*;
-
-public class ClasspathPropertyProvider extends AbstractPropertyProvider {
-
- private static final long serialVersionUID = -2193109047946712701L;
- private Map<ClassLoader,ClasspathModulePropertyProvider> configs = new HashMap<>();
- private String[] resources;
-
- public ClasspathPropertyProvider(MetaInfo metaInfo, String... resources) {
- super(metaInfo);
- Objects.requireNonNull(resources);
- this.resources = resources;
- }
-
-
- @Override
- public Map<String,String> toMap(){
- return new Map<String,String>(){
-
- @Override
- public int size(){
- return getLoaderDependentDelegate().size();
- }
-
- @Override
- public boolean isEmpty(){
- return getLoaderDependentDelegate().isEmpty();
- }
-
- @Override
- public boolean containsKey(Object key){
- return getLoaderDependentDelegate().containsKey(key);
- }
-
- @Override
- public boolean containsValue(Object value){
- return getLoaderDependentDelegate().containsValue(value);
- }
-
- @Override
- public String get(Object key){
- return getLoaderDependentDelegate().get(key);
- }
-
- @Override
- public String put(String key, String value){
- return getLoaderDependentDelegate().put(key,value);
- }
-
- @Override
- public String remove(Object key){
- return getLoaderDependentDelegate().remove(key);
- }
-
- @Override
- public void putAll(Map<? extends String,? extends String> m){
- getLoaderDependentDelegate().putAll(m);
- }
-
- @Override
- public void clear(){
- getLoaderDependentDelegate().clear();
- }
-
- @Override
- public Set<String> keySet(){
- return getLoaderDependentDelegate().keySet();
- }
-
- @Override
- public Collection<String> values(){
- return getLoaderDependentDelegate().values();
- }
-
- @Override
- public Set<Entry<String,String>> entrySet(){
- return getLoaderDependentDelegate().entrySet();
- }
-
- };
- }
-
- private Map<String, String> getLoaderDependentDelegate() {
- Map<String, String> props = new HashMap<>();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = getClass().getClassLoader();
- }
- while (cl != null) {
- ClasspathModulePropertyProvider cfg = this.configs.get(cl);
- if (cfg == null) {
- cfg = new ClasspathModulePropertyProvider(cl, this.resources);
- this.configs.put(cl, cfg);
- }
- props.putAll(cfg.toMap());
- cl = cl.getParent();
- }
- return props;
- }
-
- @Override
- public ConfigChangeSet load() {
- Map<String, String> props = new HashMap<>();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = getClass().getClassLoader();
- }
- while (cl != null) {
- ClasspathModulePropertyProvider cfg = this.configs.get(cl);
- if (cfg != null) {
- cfg.load();
- }
- cl = cl.getParent();
- }
- return super.load();
- }
-
- @Override
- public String toString(){
- return "ClasspathPropertyProvider{" +
- "configs=" + configs +
- ", resources=" + Arrays.toString(resources) +
- '}';
- }
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements. See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership. The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing,
+// * software distributed under the License is distributed on an
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// * KIND, either express or implied. See the License for the
+// * specific language governing permissions and limitations
+// * under the License.
+// */
+//package org.apache.tamaya.core.internal.properties;
+//
+//import org.apache.tamaya.ConfigChangeSet;
+//import org.apache.tamaya.MetaInfo;
+//import org.apache.tamaya.core.properties.AbstractPropertyProvider;
+//import org.apache.tamaya.core.properties.ClasspathModulePropertyProvider;
+//
+//import java.util.*;
+//
+//public class ClasspathPropertyProvider extends AbstractPropertyProvider {
+//
+// private static final long serialVersionUID = -2193109047946712701L;
+// private Map<ClassLoader,ClasspathModulePropertyProvider> configs = new HashMap<>();
+// private String[] resources;
+//
+// public ClasspathPropertyProvider(MetaInfo metaInfo, String... resources) {
+// super(metaInfo);
+// Objects.requireNonNull(resources);
+// this.resources = resources;
+// }
+//
+//
+// @Override
+// public Map<String,String> toMap(){
+// return new Map<String,String>(){
+//
+// @Override
+// public int size(){
+// return getLoaderDependentDelegate().size();
+// }
+//
+// @Override
+// public boolean isEmpty(){
+// return getLoaderDependentDelegate().isEmpty();
+// }
+//
+// @Override
+// public boolean containsKey(Object key){
+// return getLoaderDependentDelegate().containsKey(key);
+// }
+//
+// @Override
+// public boolean containsValue(Object value){
+// return getLoaderDependentDelegate().containsValue(value);
+// }
+//
+// @Override
+// public String get(Object key){
+// return getLoaderDependentDelegate().get(key);
+// }
+//
+// @Override
+// public String put(String key, String value){
+// return getLoaderDependentDelegate().put(key,value);
+// }
+//
+// @Override
+// public String remove(Object key){
+// return getLoaderDependentDelegate().remove(key);
+// }
+//
+// @Override
+// public void putAll(Map<? extends String,? extends String> m){
+// getLoaderDependentDelegate().putAll(m);
+// }
+//
+// @Override
+// public void clear(){
+// getLoaderDependentDelegate().clear();
+// }
+//
+// @Override
+// public Set<String> keySet(){
+// return getLoaderDependentDelegate().keySet();
+// }
+//
+// @Override
+// public Collection<String> values(){
+// return getLoaderDependentDelegate().values();
+// }
+//
+// @Override
+// public Set<Entry<String,String>> entrySet(){
+// return getLoaderDependentDelegate().entrySet();
+// }
+//
+// };
+// }
+//
+// private Map<String, String> getLoaderDependentDelegate() {
+// Map<String, String> props = new HashMap<>();
+// ClassLoader cl = Thread.currentThread().getContextClassLoader();
+// if (cl == null) {
+// cl = getClass().getClassLoader();
+// }
+// while (cl != null) {
+// ClasspathModulePropertyProvider cfg = this.configs.get(cl);
+// if (cfg == null) {
+// cfg = new ClasspathModulePropertyProvider(cl, this.resources);
+// this.configs.put(cl, cfg);
+// }
+// props.putAll(cfg.toMap());
+// cl = cl.getParent();
+// }
+// return props;
+// }
+//
+// @Override
+// public ConfigChangeSet load() {
+// Map<String, String> props = new HashMap<>();
+// ClassLoader cl = Thread.currentThread().getContextClassLoader();
+// if (cl == null) {
+// cl = getClass().getClassLoader();
+// }
+// while (cl != null) {
+// ClasspathModulePropertyProvider cfg = this.configs.get(cl);
+// if (cfg != null) {
+// cfg.load();
+// }
+// cl = cl.getParent();
+// }
+// return super.load();
+// }
+//
+// @Override
+// public String toString(){
+// return "ClasspathPropertyProvider{" +
+// "configs=" + configs +
+// ", resources=" + Arrays.toString(resources) +
+// '}';
+// }
+//}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyAdaptersSingletonSpi.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyAdaptersSingletonSpi.java b/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyAdaptersSingletonSpi.java
index 7323132..ba267c7 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyAdaptersSingletonSpi.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyAdaptersSingletonSpi.java
@@ -20,7 +20,7 @@ package org.apache.tamaya.core.internal.properties;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.mapping.WithPropertyAdapter;
+import org.apache.tamaya.annotation.WithPropertyAdapter;
import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
import java.math.BigDecimal;
import java.math.BigInteger;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyProviderBuilderSpi.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyProviderBuilderSpi.java b/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyProviderBuilderSpi.java
index eedeee0..fdcfc2a 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyProviderBuilderSpi.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/properties/DefaultPropertyProviderBuilderSpi.java
@@ -279,4 +279,9 @@ public class DefaultPropertyProviderBuilderSpi implements PropertyProviderBuilde
return new ReplacingPropertyProvider(metaInfo, mainMap, replacementMap);
}
+ @Override
+ public PropertyProvider build(MetaInfo metaInfo, PropertyProvider baseProvider) {
+ return new BuildablePropertyProvider(metaInfo, baseProvider);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/properties/EnvironmentPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/properties/EnvironmentPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/internal/properties/EnvironmentPropertyProvider.java
index c0ab0de..f95a6ef 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/properties/EnvironmentPropertyProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/properties/EnvironmentPropertyProvider.java
@@ -37,9 +37,7 @@ class EnvironmentPropertyProvider extends AbstractPropertyProvider {
@Override
public String toString(){
- return "EnvironmentPropertyMap{" +
- "props=" + super.toString() +
- '}';
+ return "EnvironmentPropertyProvider[" + System.getenv().size() + " environment properties]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/properties/SystemPropertiesPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/properties/SystemPropertiesPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/internal/properties/SystemPropertiesPropertyProvider.java
index f3fe1da..525da22 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/properties/SystemPropertiesPropertyProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/properties/SystemPropertiesPropertyProvider.java
@@ -49,5 +49,9 @@ class SystemPropertiesPropertyProvider extends AbstractPropertyProvider {
return Collections.unmodifiableMap(props);
}
+ @Override
+ public String toString(){
+ return "SystemPropertiesPropertyProvider[" + System.getProperties().size() + " system properties]";
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java
index 09051ae..0e637a2 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java
@@ -23,9 +23,9 @@ import java.util.regex.Pattern;
/**
* PathMatcher implementation for Ant-style path patterns. Examples are provided below.
*
- * <p>Part current this mapping code has been kindly borrowed from <a href="http://ant.apache.org">Apache Ant</a>.
+ * <p>Part current this annotation code has been kindly borrowed from <a href="http://ant.apache.org">Apache Ant</a>.
*
- * <p>The mapping matches URLs using the following rules:<br> <ul> <li>? matches one character</li> <li>* matches zero
+ * <p>The annotation matches URLs using the following rules:<br> <ul> <li>? matches one character</li> <li>* matches zero
* or more characters</li> <li>** matches zero or more 'directories' in a path</li> </ul>
*
* <p>Some examples:<br> <ul> <li>{@code com/t?st.jsp} - matches {@code com/test.jsp} but also
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
index a72fe21..0e81aa9 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
@@ -39,7 +39,7 @@ import java.util.logging.Logger;
/**
* A {@code ResourcePatternResolver} implementation that is able to resolve a
* specified resource location path into one or more matching Resources.
- * The source path may be a simple path which has a one-to-one mapping to a
+ * The source path may be a simple path which has a one-to-one annotation to a
* target {@code org.springframework.core.io.Resource}, or alternatively
* may contain the special "{@code classpath*:}" prefix and/or
* internal Ant-style regular expressions (matched using Spring's
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
deleted file mode 100644
index 2503b35..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
+++ /dev/null
@@ -1,80 +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.core.properties;
-
-import org.apache.tamaya.core.resource.ResourceLoader;
-
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.spi.Bootstrap;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.*;
-
-public class ClasspathModulePropertyProvider extends AbstractPropertyProvider{
-
- private static final long serialVersionUID = 8488347395634476626L;
- private ClassLoader classLoader;
- private String[] sources;
-
- public ClasspathModulePropertyProvider(ClassLoader classLoader, String... sources) {
- super(MetaInfoBuilder.of().set("classloader", classLoader.toString()).setSourceExpressions(sources).build());
- Objects.requireNonNull(classLoader);
- this.classLoader = classLoader;
- this.sources = sources.clone();
- load(); // trigger initialization
- }
-
- public ClassLoader getClassLoader() {
- return this.classLoader;
- }
-
-
- @Override
- public Map<String,String> toMap() {
- Map<String,String> content = new HashMap<>();
- for (String srcPattern : sources) {
- List<URI> urls = null;
- try {
- Bootstrap.getService(ResourceLoader.class).getResources(classLoader, srcPattern);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- if (urls == null) {
- return content;
- }
- MetaInfoBuilder mb = MetaInfoBuilder.of(getMetaInfo());
- for (URI url : urls) {
- InputStream is = null;
- try {
- Properties props = new Properties();
- is = url.toURL().openStream();
- props.loadFromXML(is);
- addSource(url.toString());
- for (Map.Entry<Object, Object> en : props.entrySet()) {
- content.put(en.getKey().toString(), en.getValue().toString());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- return content;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
index 924d71b..f8d4294 100644
--- a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
+++ b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
@@ -23,8 +23,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import org.apache.tamaya.mapping.ConfiguredProperty;
-import org.apache.tamaya.mapping.DefaultValue;
+import org.apache.tamaya.annotation.ConfiguredProperty;
+import org.apache.tamaya.annotation.DefaultValue;
import org.apache.tamaya.core.internal.config.DefaultConfigurationManagerSingletonSpi;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/test/java/org/apache/tamaya/core/config/ClasspathModulePropertyMapTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/config/ClasspathModulePropertyMapTest.java b/core/src/test/java/org/apache/tamaya/core/config/ClasspathModulePropertyMapTest.java
deleted file mode 100644
index a9aab61..0000000
--- a/core/src/test/java/org/apache/tamaya/core/config/ClasspathModulePropertyMapTest.java
+++ /dev/null
@@ -1,74 +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.core.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import org.apache.tamaya.core.properties.ClasspathModulePropertyProvider;
-import org.junit.Test;
-
-public class ClasspathModulePropertyMapTest{
-
- @Test
- public void testGetMetaInfoString() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testGetMetaInfo() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testClasspathModuleConfigUnit() {
- ClasspathModulePropertyProvider u = new ClasspathModulePropertyProvider(
- ClasspathModulePropertyProvider.class.getClassLoader(),
- "cfg/test.xml");
-
- System.out.println(u);
- assertEquals("testValue", u.get("testFromXml"));
- }
-
- @Test
- public void testGetClassLoader() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testGetProperty() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testGetProperties() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testIsActive() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testToString() {
- fail("Not yet implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/test/java/org/apache/tamaya/samples/annotations/ConfigTemplate.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/samples/annotations/ConfigTemplate.java b/core/src/test/java/org/apache/tamaya/samples/annotations/ConfigTemplate.java
index ed440a0..b28714e 100644
--- a/core/src/test/java/org/apache/tamaya/samples/annotations/ConfigTemplate.java
+++ b/core/src/test/java/org/apache/tamaya/samples/annotations/ConfigTemplate.java
@@ -18,8 +18,8 @@
*/
package org.apache.tamaya.samples.annotations;
-import org.apache.tamaya.mapping.ConfiguredProperty;
-import org.apache.tamaya.mapping.DefaultValue;
+import org.apache.tamaya.annotation.ConfiguredProperty;
+import org.apache.tamaya.annotation.DefaultValue;
import java.math.BigDecimal;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredClass.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredClass.java b/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredClass.java
index 41654ed..fa2868c 100644
--- a/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredClass.java
+++ b/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredClass.java
@@ -18,10 +18,10 @@
*/
package org.apache.tamaya.samples.annotations;
-import org.apache.tamaya.mapping.ConfigChangeListener;
-import org.apache.tamaya.mapping.ConfiguredProperty;
-import org.apache.tamaya.mapping.DefaultValue;
-import org.apache.tamaya.mapping.WithConfig;
+import org.apache.tamaya.annotation.ConfigChangeListener;
+import org.apache.tamaya.annotation.ConfiguredProperty;
+import org.apache.tamaya.annotation.DefaultValue;
+import org.apache.tamaya.annotation.WithConfig;
import java.beans.PropertyChangeEvent;
import java.math.BigDecimal;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/modules/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
----------------------------------------------------------------------
diff --git a/modules/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java b/modules/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
index f67dce3..d582ffc 100644
--- a/modules/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
+++ b/modules/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
@@ -1,9 +1,9 @@
package main.java.metamodel.ext.cdi;
-import org.apache.tamaya.mapping.ConfigChangeListener;
-import org.apache.tamaya.mapping.ConfiguredProperty;
-import org.apache.tamaya.mapping.DefaultValue;
-import org.apache.tamaya.mapping.WithConfig;
+import org.apache.tamaya.annotation.ConfigChangeListener;
+import org.apache.tamaya.annotation.ConfiguredProperty;
+import org.apache.tamaya.annotation.DefaultValue;
+import org.apache.tamaya.annotation.WithConfig;
import javax.inject.Singleton;
import java.beans.PropertyChangeEvent;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/modules/metamodel/pom.xml
----------------------------------------------------------------------
diff --git a/modules/metamodel/pom.xml b/modules/metamodel/pom.xml
index c8161f1..6bd6002 100644
--- a/modules/metamodel/pom.xml
+++ b/modules/metamodel/pom.xml
@@ -27,7 +27,7 @@ under the License.
<relativePath>..</relativePath>
</parent>
<artifactId>tamaya-ext-metamodel</artifactId>
- <name>Apache Tamaya Module - Management Beans</name>
+ <name>Apache Tamaya Module - Configuration Metamodels</name>
<packaging>jar</packaging>
<properties>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/modules/metamodel/src/main/java/metamodel/DefaultConfigProvider.java
----------------------------------------------------------------------
diff --git a/modules/metamodel/src/main/java/metamodel/DefaultConfigProvider.java b/modules/metamodel/src/main/java/metamodel/DefaultConfigProvider.java
new file mode 100644
index 0000000..cef6408
--- /dev/null
+++ b/modules/metamodel/src/main/java/metamodel/DefaultConfigProvider.java
@@ -0,0 +1,55 @@
+/*
+ * 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 main.java.metamodel;
+
+import org.apache.tamaya.core.experimental.ConfigurationBuilder;
+import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
+
+/**
+ * Created by Anatole on 30.09.2014.
+ */
+public class DefaultConfigProvider implements ConfigurationProviderSpi{
+
+ private Configuration config;
+
+ @Override
+ public String getConfigName(){
+ return "default";
+ }
+
+ @Override
+ public Configuration getConfiguration(){
+ if(config == null){
+ config = ConfigBuilder.create(getConfigName()
+ .addPaths(
+ "classpath*:META-INF/config/**/*.xml", "classpath*:META-INF/config/**/*.properties",
+ "classpath*:META-INF/config/**/*.init")
+ .addPaths("classpath*:META-INF/config/**/*.xml", "classpath*:META-INF/config/**/*.properties",
+ "classpath*:META-INF/config/**/*.init")
+ addConfig(AggregationPolicy.IGNORE_DUPLICATES(),
+ ConfigBuilder.create("Default Configuration")
+ .addPaths("classpath*:META-INF/config/**/*.xml",
+ "classpath*:META-INF/config/**/*" + ".properties",
+ "classpath*:META-INF/config/**/*.ini").build())
+ .addConfig(AggregationPolicy.IGNORE_DUPLICATES(), Configuration.fromEnvironmentProperties(),
+ Configuration.fromSystemProperties()).build();
+ }
+ return config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/modules/metamodel/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
----------------------------------------------------------------------
diff --git a/modules/metamodel/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi b/modules/metamodel/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
new file mode 100644
index 0000000..5865575
--- /dev/null
+++ b/modules/metamodel/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.ext.metamodel.DefaultConfigProvider
\ No newline at end of file
[2/2] incubator-tamaya git commit: TAMAYA-19: Code cleanup - renamed
annotation, fixed bugs. Removed unused/useless code including tests.
Posted by an...@apache.org.
TAMAYA-19: Code cleanup - renamed annotation, fixed bugs. Removed unused/useless code including tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/5c36d32d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/5c36d32d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/5c36d32d
Branch: refs/heads/master
Commit: 5c36d32dc5acdc173949db0ee76d59d0f9ae6fab
Parents: a32cac8
Author: anatole <an...@apache.org>
Authored: Sun Dec 7 02:28:30 2014 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Dec 7 02:28:30 2014 +0100
----------------------------------------------------------------------
.../java/org/apache/tamaya/MetaInfoBuilder.java | 7 +-
.../org/apache/tamaya/PropertyAdapters.java | 4 +-
.../org/apache/tamaya/PropertyProvider.java | 2 +-
.../apache/tamaya/PropertyProviderBuilder.java | 128 +++++++-
.../tamaya/annotation/ConfigChangeListener.java | 37 +++
.../tamaya/annotation/ConfiguredProperties.java | 41 +++
.../tamaya/annotation/ConfiguredProperty.java | 79 +++++
.../apache/tamaya/annotation/DefaultAreas.java | 43 +++
.../apache/tamaya/annotation/DefaultValue.java | 41 +++
.../apache/tamaya/annotation/LoadPolicy.java | 48 +++
.../apache/tamaya/annotation/WithConfig.java | 41 +++
.../tamaya/annotation/WithConfigOperator.java | 44 +++
.../tamaya/annotation/WithLoadPolicy.java | 36 +++
.../tamaya/annotation/WithPropertyAdapter.java | 44 +++
.../tamaya/mapping/ConfigChangeListener.java | 37 ---
.../tamaya/mapping/ConfiguredProperties.java | 41 ---
.../tamaya/mapping/ConfiguredProperty.java | 79 -----
.../org/apache/tamaya/mapping/DefaultAreas.java | 43 ---
.../org/apache/tamaya/mapping/DefaultValue.java | 41 ---
.../org/apache/tamaya/mapping/LoadPolicy.java | 48 ---
.../org/apache/tamaya/mapping/WithConfig.java | 41 ---
.../tamaya/mapping/WithConfigOperator.java | 44 ---
.../apache/tamaya/mapping/WithLoadPolicy.java | 36 ---
.../tamaya/mapping/WithPropertyAdapter.java | 44 ---
.../spi/PropertyAdaptersSingletonSpi.java | 2 +-
.../tamaya/spi/PropertyProviderBuilderSpi.java | 11 +-
.../test/java/annottext/AnnotatedConfig.java | 8 +-
.../java/annottext/AnnotatedFullConfig.java | 8 +-
.../TestPropertyAdaptersSingletonSpi.java | 2 +-
.../core/config/FreezedConfiguration.java | 2 +-
.../config/SystemPropertiesConfigProvider.java | 2 +-
.../core/internal/inject/ConfiguredField.java | 4 +-
.../core/internal/inject/ConfiguredMethod.java | 4 +-
.../core/internal/inject/ConfiguredType.java | 2 +-
.../core/internal/logging/Slf4jLogger.java | 2 +-
.../properties/BuildablePropertyProvider.java | 48 +++
.../properties/ClasspathPropertyProvider.java | 300 +++++++++----------
.../DefaultPropertyAdaptersSingletonSpi.java | 2 +-
.../DefaultPropertyProviderBuilderSpi.java | 5 +
.../properties/EnvironmentPropertyProvider.java | 4 +-
.../SystemPropertiesPropertyProvider.java | 4 +
.../internal/resources/io/AntPathMatcher.java | 4 +-
.../io/PathMatchingResourcePatternResolver.java | 2 +-
.../ClasspathModulePropertyProvider.java | 80 -----
...tionManagerSingletonSpiSingletonSpiTest.java | 4 +-
.../config/ClasspathModulePropertyMapTest.java | 74 -----
.../samples/annotations/ConfigTemplate.java | 4 +-
.../samples/annotations/ConfiguredClass.java | 8 +-
.../java/metamodel/ext/cdi/ConfiguredClass.java | 8 +-
modules/metamodel/pom.xml | 2 +-
.../java/metamodel/DefaultConfigProvider.java | 55 ++++
...che.tamaya.core.spi.ConfigurationProviderSpi | 19 ++
52 files changed, 906 insertions(+), 813 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java b/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
index a35c8e8..407b783 100644
--- a/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
@@ -134,7 +134,7 @@ public final class MetaInfoBuilder{
public MetaInfoBuilder setEnvironment(Environment configurationContext){
Objects.requireNonNull(configurationContext);
- map.put(ENVIRONMENT, configurationContext.toString());
+ map.put(ENVIRONMENT, configurationContext.getEnvironmentType()+'['+configurationContext.getEnvironmentId()+']');
return this;
}
@@ -145,6 +145,11 @@ public final class MetaInfoBuilder{
return this;
}
+ public String get(String key){
+ Objects.requireNonNull(key);
+ return map.get(key);
+ }
+
public MetaInfo build(){
return new MetaInfo(this);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
index e8348fd..59dc3b1 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya;
-import org.apache.tamaya.mapping.WithPropertyAdapter;
+import org.apache.tamaya.annotation.WithPropertyAdapter;
import org.apache.tamaya.spi.Bootstrap;
import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
import java.util.Optional;
@@ -79,7 +79,7 @@ public final class PropertyAdapters{
/**
* Get an adapter converting to the given target type.
* @param targetType the target type class
- * @param annotation the {@link org.apache.tamaya.mapping.WithPropertyAdapter} annotation, or null. If the annotation is not null and
+ * @param annotation the {@link org.apache.tamaya.annotation.WithPropertyAdapter} annotation, or null. If the annotation is not null and
* defines an overriding adapter, this instance is created and returned.
* @param <T> the target type
* @return the corresponding adapter, never null.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/PropertyProvider.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyProvider.java b/api/src/main/java/org/apache/tamaya/PropertyProvider.java
index 5284690..2e54ea2 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyProvider.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyProvider.java
@@ -153,7 +153,7 @@ public interface PropertyProvider {
}
@Override
public String toString() {
- return "Configuration ["+getMetaInfo().getOwnerInfo()+"]";
+ return "Configuration [PropertyProvider "+getMetaInfo()+"]";
}
};
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java b/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
index 99e7e9e..ab8071a 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
@@ -40,9 +40,15 @@ public final class PropertyProviderBuilder {
*/
private static final Logger LOG = Logger.getLogger(PropertyProviderBuilder.class.getName());
/**
- * The current meta info, or null, if a default should be generated.
+ * The final meta info to be used, or null, if a default should be generated.
+ */
+ private MetaInfoBuilder metaInfoBuilder;
+
+ /**
+ * Meta info used for the next operation.
*/
private MetaInfo metaInfo;
+
/**
* the current property provider, or null.
*/
@@ -56,14 +62,21 @@ public final class PropertyProviderBuilder {
* Private singleton constructor.
*/
private PropertyProviderBuilder(MetaInfo metaInfo) {
- this.metaInfo = Objects.requireNonNull(metaInfo);
+ this.metaInfoBuilder = MetaInfoBuilder.of(Objects.requireNonNull(metaInfo)).setInfo("Built by PropertyProviderBuilder.");
+ }
+
+ /**
+ * Private singleton constructor.
+ */
+ private PropertyProviderBuilder(String name) {
+ this.metaInfoBuilder = MetaInfoBuilder.of(name);
}
/**
* Private singleton constructor.
*/
private PropertyProviderBuilder(PropertyProvider provider) {
- this.metaInfo = Objects.requireNonNull(provider).getMetaInfo();
+ this.metaInfoBuilder = MetaInfoBuilder.of(Objects.requireNonNull(provider).getMetaInfo());
this.current = provider;
}
@@ -106,7 +119,7 @@ public final class PropertyProviderBuilder {
* @return a new builder instance, never null.
*/
public static PropertyProviderBuilder create(String name) {
- return create(MetaInfo.of(name));
+ return new PropertyProviderBuilder(Objects.requireNonNull(name));
}
/**
@@ -115,10 +128,12 @@ public final class PropertyProviderBuilder {
* @return a new builder instance, never null.
*/
public static PropertyProviderBuilder create() {
- return create(MetaInfo.of("<noname>"));
+ return new PropertyProviderBuilder("<noname>");
}
+
+
/**
* Sets the aggregation policy to be used, when adding additional property sets. The policy will
* be active a slong as the builder is used or it is reset to another value.
@@ -142,25 +157,64 @@ public final class PropertyProviderBuilder {
return this;
}
+ /**
+ * Adds the given providers with the current active {@link org.apache.tamaya.AggregationPolicy}. By
+ * default {@link org.apache.tamaya.AggregationPolicy#OVERRIDE} is used.
+ * @see #withAggregationPolicy(AggregationPolicy)
+ * @param providers providers to be added, not null.
+ * @return the builder for chaining.
+ */
public PropertyProviderBuilder addProviders(PropertyProvider... providers) {
+ if(providers.length==0){
+ return this;
+ }
return addProviders(Arrays.asList(providers));
}
+ /**
+ * Adds the given providers with the current active {@link org.apache.tamaya.AggregationPolicy}. By
+ * default {@link org.apache.tamaya.AggregationPolicy#OVERRIDE} is used.
+ * @see #withAggregationPolicy(AggregationPolicy)
+ * @param providers providers to be added, not null.
+ * @return the builder for chaining.
+ */
public PropertyProviderBuilder addProviders(List<PropertyProvider> providers) {
+ if(providers.isEmpty()){
+ return this;
+ }
List<PropertyProvider> allProviders = new ArrayList<>(providers);
if (this.current != null) {
allProviders.add(0, this.current);
}
+ StringBuilder b = new StringBuilder();
+ providers.forEach(p -> b.append(p.getMetaInfo().toString()).append(','));
+ b.setLength(b.length()-1);
+ String source = b.toString();
MetaInfo mi = this.metaInfo;
if (mi == null) {
- mi = MetaInfoBuilder.of("aggregate").setEnvironment(Environment.current()).build();
+ mi = MetaInfoBuilder.of("aggregate").setEnvironment(Environment.current())
+ .set(MetaInfoBuilder.SOURCE,source).build();
}
this.current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
.aggregate(mi, this.aggregationPolicy, allProviders);
+
+ addProviderChainInfo(source);
this.metaInfo = null;
return this;
}
+ private void addProviderChainInfo(String info){
+ String providerChain = metaInfoBuilder.get("providerChain");
+
+ if(providerChain == null){
+ providerChain = "\n " + info;
+ }
+ else{
+ providerChain = providerChain + ",\n " + info;
+ }
+ metaInfoBuilder.set("providerChain", providerChain);
+ }
+
/**
* Creates a new {@link PropertyProvider} using the given command line arguments and adds it
* using the current aggregation policy in place.
@@ -169,6 +223,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder addArgs(String... args) {
+ if(args.length==0){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("args").setEnvironment(Environment.current()).build();
@@ -187,6 +244,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder addPaths(String... paths) {
+ if(paths.length==0){
+ return this;
+ }
return addPaths(Arrays.asList(paths));
}
@@ -200,6 +260,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder addPaths(List<String> paths) {
+ if(paths.isEmpty()){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("aggregate").set("paths", paths.toString()).setEnvironment(Environment.current()).build();
@@ -218,6 +281,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder addURLs(URL... urls) {
+ if(urls.length==0){
+ return this;
+ }
return addURLs(Arrays.asList(urls));
}
@@ -229,6 +295,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder addURLs(List<URL> urls) {
+ if(urls.isEmpty()){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("aggregate").set("urls", urls.toString()).setEnvironment(Environment.current()).build();
@@ -248,6 +317,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder addMap(Map<String, String> map) {
+ if(map.isEmpty()){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("map").setEnvironment(Environment.current()).build();
@@ -267,7 +339,7 @@ public final class PropertyProviderBuilder {
public PropertyProviderBuilder addEnvironmentProperties() {
MetaInfo mi = this.metaInfo;
if (mi == null) {
- mi = MetaInfoBuilder.of("with env-props").setEnvironment(Environment.current()).build();
+ mi = MetaInfoBuilder.of("environment.properties").setEnvironment(Environment.current()).build();
} else {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
@@ -283,7 +355,7 @@ public final class PropertyProviderBuilder {
public PropertyProviderBuilder addSystemProperties() {
MetaInfo mi = this.metaInfo;
if (mi == null) {
- mi = MetaInfoBuilder.of("with sys-props").setEnvironment(Environment.current()).build();
+ mi = MetaInfoBuilder.of("system.properties").setEnvironment(Environment.current()).build();
} else {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
@@ -299,6 +371,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder aggregate(PropertyProvider... providers) {
+ if(providers.length==0){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("aggregate").setEnvironment(Environment.current()).build();
@@ -318,6 +393,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder aggregate(List<PropertyProvider> providers) {
+ if(providers.isEmpty()){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("aggregate").setEnvironment(Environment.current()).build();
@@ -349,6 +427,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder intersect(PropertyProvider... providers) {
+ if(providers.length==0){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("intersect").setEnvironment(Environment.current()).build();
@@ -367,6 +448,9 @@ public final class PropertyProviderBuilder {
* @return the builder for chaining.
*/
public PropertyProviderBuilder subtract(PropertyProvider... providers) {
+ if(providers.length==0){
+ return this;
+ }
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("subtract").setEnvironment(Environment.current()).build();
@@ -394,6 +478,8 @@ public final class PropertyProviderBuilder {
}
current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
.filtered(mi, filter, current);
+ addProviderChainInfo("filter->" + filter.toString());
+ this.metaInfo = null;
return this;
}
@@ -431,6 +517,21 @@ public final class PropertyProviderBuilder {
}
current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
.replacing(mi, current, replacementMap);
+ this.metaInfo = null;
+ addProviderChainInfo("replace->" + replacementMap.toString());
+ return this;
+ }
+
+ /**
+ * Sets an additional key on the final {@link org.apache.tamaya.MetaInfo} of the provider
+ * created.
+ *
+ * @param key the key to be added, not null.
+ * @param value the value to be added, not null.
+ * @return this builder for chaining
+ */
+ public PropertyProviderBuilder setMeta(String key, String value){
+ this.metaInfoBuilder.set(key, value);
return this;
}
@@ -440,10 +541,11 @@ public final class PropertyProviderBuilder {
*/
public PropertyProvider build() {
if (current != null) {
- return current; // TODO add meta info here...
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .build(metaInfoBuilder.build(), current);
}
return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .empty(metaInfo);
+ .empty(metaInfoBuilder.build());
}
/**
@@ -452,15 +554,17 @@ public final class PropertyProviderBuilder {
*
* @return the freezed instance, never null.
*/
- public PropertyProvider freeze() {
+ public PropertyProvider buildFreezed() {
MetaInfo mi = this.metaInfo;
if (mi == null) {
mi = MetaInfoBuilder.of("freezed").set("freezed", "true").setEnvironment(Environment.current()).build();
} else {
mi = MetaInfoBuilder.of(metaInfo).set("freezed", "true").setEnvironment(Environment.current()).build();
}
- return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ PropertyProvider prov = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
.freezed(mi, current);
+ this.metaInfo = null;
+ return prov;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/ConfigChangeListener.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/ConfigChangeListener.java b/api/src/main/java/org/apache/tamaya/annotation/ConfigChangeListener.java
new file mode 100644
index 0000000..5329ee6
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/ConfigChangeListener.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to annotate a method on a class to be informed on config changes.
+ * The exact behaviour, when configuration change events are sent can be configured
+ * on each configured property/method by adding the {@link org.apache.tamaya.annotation.WithLoadPolicy}
+ * annotation. By default listeners are only informed about changes that are affecting configured
+ * values current the containing class/instance.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.METHOD })
+public @interface ConfigChangeListener {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.java
new file mode 100644
index 0000000..a1af097
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperties.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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation container to enable injection current multiple {@link org.apache.tamaya.annotation.ConfiguredProperty}
+ * annotations. Hereby the ordering current annotations imply the defaulting. The first value that
+ * could be resolved successfully in the chain current annotations will be used.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD })
+public @interface ConfiguredProperties {
+
+ /**
+ * Get the different configuration keys to be looked up, in order current precedence. The first non null value
+ * found will be used.
+ */
+ ConfiguredProperty[] value() default {};
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.java
new file mode 100644
index 0000000..14c9c55
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/ConfiguredProperty.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.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation to enable injection current a configured property or define the returned data for
+ * a configuration template method. Hereby this annotation can be used in multiple ways and combined
+ * with other annotations such as {@link org.apache.tamaya.annotation.DefaultValue},
+ * {@link org.apache.tamaya.annotation.WithLoadPolicy}, {@link org.apache.tamaya.annotation.WithConfig},
+ * {@link org.apache.tamaya.annotation.WithConfigOperator}, {@link org.apache.tamaya.annotation.WithPropertyAdapter}.
+ *
+ * Below the most simple variant current a configured class is given:
+ * {@code
+ * pubic class ConfiguredItem{
+ *
+ * @ConfiguredProperty
+ * private String aValue;
+ * }
+ * When this class is configured, e.g. by passing it to {@link org.apache.tamaya.Configuration#configure(Object)},
+ * the following is happening:
+ * <ul>
+ * <li>The current valid Configuration is evaluated by calling {@code Configuration cfg = Configuration.current();}</li>
+ * <li>The current property String value is evaluated by calling {@code cfg.get("aValue");}</li>
+ * <li>if not successful, an error is thrown ({@link org.apache.tamaya.ConfigException}.</li>
+ * <li>On success, since no type conversion is involved, the value is injected.</li>
+ * <li>The configured bean is registered as a weak change listener in the config system's underlying
+ * configuration, so future config changes can be propagated (controlled by {@link org.apache.tamaya.annotation.WithLoadPolicy}
+ * annotations).</li>
+ * </ul>
+ *
+ * In the next example we explicitly define the property value:
+ * {@code
+ * pubic class ConfiguredItem{
+ *
+ * @ConfiguredProperty
+ * @ConfiguredProperty("a.b.value")
+ * @configuredProperty("a.b.deprecated.value")
+ * @DefaultValue("${env:java.version}")
+ * private String aValue;
+ * }
+ *
+ * Within this example we evaluate multiple possible keys. Evaluation is aborted if a key could be successfully
+ * resolved. Hereby the ordering current the annotations define the ordering current resolution, so in the example above
+ * resolution equals to {@code "aValue", "a.b.value", "a.b.deprecated.value"}. If no value could be read
+ * fromMap the configuration, it uses the value fromMap the {@code DefaultValue} annotation. Interesting here
+ * is that this value is not static, it is evaluated by calling
+ * {@link org.apache.tamaya.Configuration#evaluateValue(org.apache.tamaya.Configuration, String)}.
+ */
+@Repeatable(ConfiguredProperties.class)
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD })
+public @interface ConfiguredProperty {
+
+ /**
+ * Get the property names to be used. Hereby the first non null value evaluated is injected as property value.
+ *
+ * @return the property names, not null. If missing the field or method name being injected is used by default.
+ */
+ String value() default "";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java b/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.java
new file mode 100644
index 0000000..63ea137
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/DefaultAreas.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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to control injection and resolution current a configured bean. The configuration keys
+ * to be resolved are basically determined by the {@link org.apache.tamaya.annotation.ConfiguredProperty}
+ * annotation(s). Nevertheless these annotations can also have relative key names. This annotation allows
+ * to define a configuration area that is prefixed to all relative configuration keys within the
+ * corresponding class/template interface.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE })
+public @interface DefaultAreas {
+
+ /**
+ * Allows to declare an operator that should be applied before injecting values into the bean.
+ * @return the operator class to be used.
+ */
+ String[] value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java b/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.java
new file mode 100644
index 0000000..19ee341
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/DefaultValue.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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to define a default value to be returned, when no configured value could be
+ * determined for a property/template accessor. The value 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 value to be injected, if no such configuration entry was found. If value 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/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java b/api/src/main/java/org/apache/tamaya/annotation/LoadPolicy.java
new file mode 100644
index 0000000..2e0089a
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/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.annotation;
+
+/**
+ * Available policies that describe how changes affecting configured values are published/reinjected.
+ * The policy also affects the cases were any configured listeners/listener methods are called for
+ * propagation current configuration changes.
+ */
+public enum LoadPolicy {
+ /**
+ * The configuration value is evaluated once, when the owning component is loaded/configured, but never updated later.
+ */
+ INITIAL,
+ /**
+ * The configuration value is evaluated exactly once on its first use lazily, but never updated later.
+ * This feature is not applicable on field injection, but only on configuration template methods.
+ */
+ LAZY,
+ /**
+ * The configuration value is evaluated once, when the owning component is loaded/configured.
+ * Later changes on this configuration entry will be reinjected/updated and additionally triggered
+ * as {@link java.beans.PropertyChangeEvent}.
+ */
+ MANAGED,
+ /**
+ * The configuration value is evaluated once, when the owning component is loaded/configured.
+ * 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/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java b/api/src/main/java/org/apache/tamaya/annotation/WithConfig.java
new file mode 100644
index 0000000..00180a5
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/WithConfig.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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to reference an explicit {@link org.apache.tamaya.Configuration} to be used to
+ * resolve the required properties. the configured value is passed to {@code Configuration.current(String)}
+ * to evaluate the required configuration required.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
+public @interface WithConfig {
+
+ /**
+ * The name current the {@link org.apache.tamaya.Configuration} to be used to
+ * resolve the required properties, not null or empty.
+ */
+ String value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java b/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
new file mode 100644
index 0000000..d1b28be
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/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.annotation;
+
+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 value.
+ * This allows filtering current configuration, e.g. for realizing views or ensuring security
+ * constraints.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
+public @interface WithConfigOperator {
+
+ /**
+ * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
+ * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
+ * registered, it is handled as a deployment error.
+ */
+ Class<? extends ConfigOperator> value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java b/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.java
new file mode 100644
index 0000000..572a36e
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/WithLoadPolicy.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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to define how config changes are handled for a type or per property/template method.
+ * @see org.apache.tamaya.annotation.LoadPolicy
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
+public @interface WithLoadPolicy {
+
+ LoadPolicy value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java b/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
new file mode 100644
index 0000000..4001742
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/annotation/WithPropertyAdapter.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.annotation;
+
+import org.apache.tamaya.PropertyAdapter;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to define a type adapter to be used before injecting a configured value.
+ * This will override any other adapter for performing the type conversion before
+ * injecting the field value.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.METHOD })
+public @interface WithPropertyAdapter {
+
+ /**
+ * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
+ * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
+ * registered, it is handled as a deployment error.
+ */
+ Class<? extends PropertyAdapter> value();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/ConfigChangeListener.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/ConfigChangeListener.java b/api/src/main/java/org/apache/tamaya/mapping/ConfigChangeListener.java
deleted file mode 100644
index 44bc55c..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/ConfigChangeListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mapping;
-
-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.mapping.WithLoadPolicy}
- * annotation. By default listeners are only informed about changes that are affecting configured
- * values current the containing class/instance.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.METHOD })
-public @interface ConfigChangeListener {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperties.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperties.java b/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperties.java
deleted file mode 100644
index 90346b1..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperties.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mapping;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation container to enable injection current multiple {@link org.apache.tamaya.mapping.ConfiguredProperty}
- * annotations. Hereby the ordering current annotations imply the defaulting. The first value that
- * could be resolved successfully in the chain current annotations will be used.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface ConfiguredProperties {
-
- /**
- * Get the different configuration keys to be looked up, in order current precedence. The first non null value
- * found will be used.
- */
- ConfiguredProperty[] value() default {};
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperty.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperty.java b/api/src/main/java/org/apache/tamaya/mapping/ConfiguredProperty.java
deleted file mode 100644
index 069210b..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/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.mapping;
-
-import java.lang.annotation.*;
-
-/**
- * Annotation to enable injection current a configured property or define the returned data for
- * a configuration template method. Hereby this annotation can be used in multiple ways and combined
- * with other annotations such as {@link org.apache.tamaya.mapping.DefaultValue},
- * {@link org.apache.tamaya.mapping.WithLoadPolicy}, {@link org.apache.tamaya.mapping.WithConfig},
- * {@link org.apache.tamaya.mapping.WithConfigOperator}, {@link org.apache.tamaya.mapping.WithPropertyAdapter}.
- *
- * Below the most simple variant current a configured class is given:
- * {@code
- * pubic class ConfiguredItem{
- *
- * @ConfiguredProperty
- * private String aValue;
- * }
- * When this class is configured, e.g. by passing it to {@link org.apache.tamaya.Configuration#configure(Object)},
- * the following is happening:
- * <ul>
- * <li>The current valid Configuration is evaluated by calling {@code Configuration cfg = Configuration.current();}</li>
- * <li>The current property String value is evaluated by calling {@code cfg.get("aValue");}</li>
- * <li>if not successful, an error is thrown ({@link org.apache.tamaya.ConfigException}.</li>
- * <li>On success, since no type conversion is involved, the value is injected.</li>
- * <li>The configured bean is registered as a weak change listener in the config system's underlying
- * configuration, so future config changes can be propagated (controlled by {@link org.apache.tamaya.mapping.WithLoadPolicy}
- * annotations).</li>
- * </ul>
- *
- * In the next example we explicitly define the property value:
- * {@code
- * pubic class ConfiguredItem{
- *
- * @ConfiguredProperty
- * @ConfiguredProperty("a.b.value")
- * @configuredProperty("a.b.deprecated.value")
- * @DefaultValue("${env:java.version}")
- * private String aValue;
- * }
- *
- * Within this example we evaluate multiple possible keys. Evaluation is aborted if a key could be successfully
- * resolved. Hereby the ordering current the annotations define the ordering current resolution, so in the example above
- * resolution equals to {@code "aValue", "a.b.value", "a.b.deprecated.value"}. If no value could be read
- * fromMap the configuration, it uses the value fromMap the {@code DefaultValue} annotation. Interesting here
- * is that this value is not static, it is evaluated by calling
- * {@link org.apache.tamaya.Configuration#evaluateValue(org.apache.tamaya.Configuration, String)}.
- */
-@Repeatable(ConfiguredProperties.class)
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface ConfiguredProperty {
-
- /**
- * Get the property names to be used. Hereby the first non null value evaluated is injected as property value.
- *
- * @return the property names, not null. If missing the field or method name being injected is used by default.
- */
- String value() default "";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/DefaultAreas.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/DefaultAreas.java b/api/src/main/java/org/apache/tamaya/mapping/DefaultAreas.java
deleted file mode 100644
index fa79941..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/DefaultAreas.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mapping;
-
-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.mapping.ConfiguredProperty}
- * annotation(s). Nevertheless these annotations can also have relative key names. This annotation allows
- * to define a configuration area that is prefixed to all relative configuration keys within the
- * corresponding class/template interface.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE })
-public @interface DefaultAreas {
-
- /**
- * Allows to declare an operator that should be applied before injecting values into the bean.
- * @return the operator class to be used.
- */
- String[] value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/DefaultValue.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/DefaultValue.java b/api/src/main/java/org/apache/tamaya/mapping/DefaultValue.java
deleted file mode 100644
index aa923ae..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/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.mapping;
-
-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 value to be returned, when no configured value could be
- * determined for a property/template accessor. The value 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 value to be injected, if no such configuration entry was found. If value 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/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/LoadPolicy.java b/api/src/main/java/org/apache/tamaya/mapping/LoadPolicy.java
deleted file mode 100644
index 71eb2ec..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/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.mapping;
-
-/**
- * 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 value is evaluated once, when the owning component is loaded/configured, but never updated later.
- */
- INITIAL,
- /**
- * The configuration value is evaluated exactly once on its first use lazily, but never updated later.
- * This feature is not applicable on field injection, but only on configuration template methods.
- */
- LAZY,
- /**
- * The configuration value is evaluated once, when the owning component is loaded/configured.
- * Later changes on this configuration entry will be reinjected/updated and additionally triggered
- * as {@link java.beans.PropertyChangeEvent}.
- */
- MANAGED,
- /**
- * The configuration value is evaluated once, when the owning component is loaded/configured.
- * 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/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/WithConfig.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/WithConfig.java b/api/src/main/java/org/apache/tamaya/mapping/WithConfig.java
deleted file mode 100644
index ce139df..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/WithConfig.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mapping;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to reference an explicit {@link org.apache.tamaya.Configuration} to be used to
- * resolve the required properties. the configured value is passed to {@code Configuration.current(String)}
- * to evaluate the required configuration required.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
-public @interface WithConfig {
-
- /**
- * The name current the {@link org.apache.tamaya.Configuration} to be used to
- * resolve the required properties, not null or empty.
- */
- String value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/WithConfigOperator.java b/api/src/main/java/org/apache/tamaya/mapping/WithConfigOperator.java
deleted file mode 100644
index b001780..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/WithConfigOperator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mapping;
-
-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 value.
- * This allows filtering current configuration, e.g. for realizing views or ensuring security
- * constraints.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
-public @interface WithConfigOperator {
-
- /**
- * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
- * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
- * registered, it is handled as a deployment error.
- */
- Class<? extends ConfigOperator> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/WithLoadPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/WithLoadPolicy.java b/api/src/main/java/org/apache/tamaya/mapping/WithLoadPolicy.java
deleted file mode 100644
index f76a8ce..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/WithLoadPolicy.java
+++ /dev/null
@@ -1,36 +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.mapping;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to define how config changes are handled for a type or per property/template method.
- * @see org.apache.tamaya.mapping.LoadPolicy
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
-public @interface WithLoadPolicy {
-
- LoadPolicy value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/mapping/WithPropertyAdapter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/mapping/WithPropertyAdapter.java b/api/src/main/java/org/apache/tamaya/mapping/WithPropertyAdapter.java
deleted file mode 100644
index d5d0e5a..0000000
--- a/api/src/main/java/org/apache/tamaya/mapping/WithPropertyAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mapping;
-
-import org.apache.tamaya.PropertyAdapter;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to define a type adapter to be used before injecting a configured value.
- * This will override any other adapter for performing the type conversion before
- * injecting the field value.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface WithPropertyAdapter {
-
- /**
- * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
- * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
- * registered, it is handled as a deployment error.
- */
- Class<? extends PropertyAdapter> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java b/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
index 72b7bd1..edc5ed9 100644
--- a/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
+++ b/api/src/main/java/org/apache/tamaya/spi/PropertyAdaptersSingletonSpi.java
@@ -19,7 +19,7 @@
package org.apache.tamaya.spi;
import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.mapping.WithPropertyAdapter;
+import org.apache.tamaya.annotation.WithPropertyAdapter;
/**
* SPI that is used by the {@link org.apache.tamaya.PropertyAdapters} singleton as delegation instance.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java b/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
index 4c1a844..a64a1c9 100644
--- a/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
+++ b/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
@@ -110,7 +110,7 @@ public interface PropertyProviderBuilderSpi {
/**
* Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby using the given AggregationPolicy.
*
- * @param policy the mapping to be used, not null.
+ * @param policy the annotation to be used, not null.
* @param propertyMaps the maps to be included, not null.
* @return the aggregated instance containing all given maps.
*/
@@ -194,4 +194,13 @@ public interface PropertyProviderBuilderSpi {
* @return the new delegating instance.
*/
PropertyProvider replacing(MetaInfo metaInfo, PropertyProvider mainMap, Map<String, String> replacementMap);
+
+ /**
+ * Create a new PropertyProvider instance given the metaInfo and the baseProvider, masking hereby the base provider's
+ * meta information.
+ * @param metaInfo the meta information to be provided, not null.
+ * @param baseProvider the base provider to be used.
+ * @return a PropertyProvider with the given meta info, providing data from the baseProvider, never null.
+ */
+ PropertyProvider build(MetaInfo metaInfo, PropertyProvider baseProvider);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/test/java/annottext/AnnotatedConfig.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/annottext/AnnotatedConfig.java b/api/src/test/java/annottext/AnnotatedConfig.java
index f43f9ee..408cc97 100644
--- a/api/src/test/java/annottext/AnnotatedConfig.java
+++ b/api/src/test/java/annottext/AnnotatedConfig.java
@@ -18,10 +18,10 @@
*/
package annottext;
-import org.apache.tamaya.mapping.ConfiguredProperty;
-import org.apache.tamaya.mapping.WithLoadPolicy;
-import org.apache.tamaya.mapping.DefaultValue;
-import org.apache.tamaya.mapping.LoadPolicy;
+import org.apache.tamaya.annotation.ConfiguredProperty;
+import org.apache.tamaya.annotation.WithLoadPolicy;
+import org.apache.tamaya.annotation.DefaultValue;
+import org.apache.tamaya.annotation.LoadPolicy;
/**
* An example showing some basic annotations, using an interface to be proxied by the
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/test/java/annottext/AnnotatedFullConfig.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/annottext/AnnotatedFullConfig.java b/api/src/test/java/annottext/AnnotatedFullConfig.java
index 4f09ee8..474356f 100644
--- a/api/src/test/java/annottext/AnnotatedFullConfig.java
+++ b/api/src/test/java/annottext/AnnotatedFullConfig.java
@@ -19,10 +19,10 @@
package annottext;
import org.apache.tamaya.Configuration;
-import org.apache.tamaya.mapping.ConfiguredProperty;
-import org.apache.tamaya.mapping.WithLoadPolicy;
-import org.apache.tamaya.mapping.DefaultValue;
-import org.apache.tamaya.mapping.LoadPolicy;
+import org.apache.tamaya.annotation.ConfiguredProperty;
+import org.apache.tamaya.annotation.WithLoadPolicy;
+import org.apache.tamaya.annotation.DefaultValue;
+import org.apache.tamaya.annotation.LoadPolicy;
/**
* An example showing some basic annotations, using an interface to be proxied by the
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/api/src/test/java/org.apache.tamaya/TestPropertyAdaptersSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org.apache.tamaya/TestPropertyAdaptersSingletonSpi.java b/api/src/test/java/org.apache.tamaya/TestPropertyAdaptersSingletonSpi.java
index b45bfbe..2d3cfbc 100644
--- a/api/src/test/java/org.apache.tamaya/TestPropertyAdaptersSingletonSpi.java
+++ b/api/src/test/java/org.apache.tamaya/TestPropertyAdaptersSingletonSpi.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya;
-import org.apache.tamaya.mapping.WithPropertyAdapter;
+import org.apache.tamaya.annotation.WithPropertyAdapter;
import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
import java.math.BigDecimal;
import java.math.BigInteger;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java b/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
index 5830540..306925e 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
@@ -37,7 +37,7 @@ final class FreezedConfiguration extends AbstractConfiguration implements Serial
private FreezedConfiguration(Configuration config){
super(MetaInfoBuilder.of(config.getMetaInfo()).set("freezedAt", Instant.now().toString()).build());
- this.properties = PropertyProviderBuilder.create(config).freeze();
+ this.properties = PropertyProviderBuilder.create(config).buildFreezed();
this.version = Objects.requireNonNull(config.getVersion());
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java b/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
index d8314f8..d2004d8 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
@@ -34,7 +34,7 @@ public class SystemPropertiesConfigProvider implements ConfigurationProviderSpi{
private Configuration systemConfig;
public SystemPropertiesConfigProvider(){
- systemConfig = PropertyProviderBuilder.create("environment.properties").addSystemProperties().build().toConfiguration();
+ systemConfig = PropertyProviderBuilder.create("system.properties").addSystemProperties().build().toConfiguration();
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
index 81c16b8..b8b3a4e 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
@@ -22,7 +22,7 @@ import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.PropertyAdapter;
import org.apache.tamaya.PropertyAdapters;
-import org.apache.tamaya.mapping.*;
+import org.apache.tamaya.annotation.*;
import org.apache.tamaya.core.internal.Utils;
import java.lang.reflect.Field;
@@ -145,7 +145,7 @@ public class ConfiguredField {
}
}
} catch (Exception e) {
- throw new ConfigException("Failed to mapping configured field: " + this.annotatedField.getDeclaringClass()
+ throw new ConfigException("Failed to annotation configured field: " + this.annotatedField.getDeclaringClass()
.getName() + '.' + annotatedField.getName(), e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
index fcb68f1..de7eaf9 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
@@ -22,7 +22,7 @@ import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.PropertyAdapter;
import org.apache.tamaya.PropertyAdapters;
-import org.apache.tamaya.mapping.*;
+import org.apache.tamaya.annotation.*;
import org.apache.tamaya.core.internal.Utils;
import java.lang.reflect.Method;
@@ -187,7 +187,7 @@ public class ConfiguredMethod {
}
}
} catch (Exception e) {
- throw new ConfigException("Failed to mapping configured field: " + this.annotatedMethod.getDeclaringClass()
+ throw new ConfigException("Failed to annotation configured field: " + this.annotatedMethod.getDeclaringClass()
.getName() + '.' + annotatedMethod.getName(), e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredType.java b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredType.java
index 03df282..2770e8a 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredType.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredType.java
@@ -20,7 +20,7 @@ package org.apache.tamaya.core.internal.inject;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
-import org.apache.tamaya.mapping.*;
+import org.apache.tamaya.annotation.*;
import java.beans.PropertyChangeEvent;
import java.lang.reflect.Field;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java b/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
index d8dd2bd..a580128 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
@@ -32,7 +32,7 @@ import java.util.logging.LogRecord;
* {@link java.util.logging.Logger#getUseParentHandlers()} are not overrriden.
* </p>
* <p>
- * Level mapping inspired by {@link org.slf4j.bridge.SLF4JBridgeHandler}:
+ * Level annotation inspired by {@link org.slf4j.bridge.SLF4JBridgeHandler}:
* </p>
* <p/>
* <pre>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/5c36d32d/core/src/main/java/org/apache/tamaya/core/internal/properties/BuildablePropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/properties/BuildablePropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/internal/properties/BuildablePropertyProvider.java
new file mode 100644
index 0000000..6a35545
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/internal/properties/BuildablePropertyProvider.java
@@ -0,0 +1,48 @@
+package org.apache.tamaya.core.internal.properties;
+
+import org.apache.tamaya.MetaInfo;
+import org.apache.tamaya.PropertyProvider;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Created by Anatole on 07.12.2014.
+ */
+class BuildablePropertyProvider implements PropertyProvider {
+
+ private MetaInfo metaInfo;
+ private PropertyProvider baseProvider;
+
+ public BuildablePropertyProvider(MetaInfo metaInfo, PropertyProvider baseProvider) {
+ this.metaInfo = Objects.requireNonNull(metaInfo);
+ this.baseProvider = Objects.requireNonNull(baseProvider);
+ }
+
+ @Override
+ public Optional<String> get(String key) {
+ return this.baseProvider.get(key);
+ }
+
+ @Override
+ public boolean containsKey(String key) {
+ return this.baseProvider.containsKey(key);
+ }
+
+ @Override
+ public Map<String, String> toMap() {
+ return this.baseProvider.toMap();
+ }
+
+ @Override
+ public MetaInfo getMetaInfo() {
+ return this.metaInfo;
+ }
+
+ @Override
+ public String toString(){
+ return "BuildablePropertyProvider -> " + getMetaInfo().toString();
+ }
+
+}