Return-Path: X-Original-To: apmail-tamaya-commits-archive@minotaur.apache.org Delivered-To: apmail-tamaya-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 940E910A17 for ; Sun, 7 Dec 2014 01:29:16 +0000 (UTC) Received: (qmail 60786 invoked by uid 500); 7 Dec 2014 01:29:16 -0000 Delivered-To: apmail-tamaya-commits-archive@tamaya.apache.org Received: (qmail 60766 invoked by uid 500); 7 Dec 2014 01:29:16 -0000 Mailing-List: contact commits-help@tamaya.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tamaya.incubator.apache.org Delivered-To: mailing list commits@tamaya.incubator.apache.org Received: (qmail 60757 invoked by uid 99); 7 Dec 2014 01:29:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Dec 2014 01:29:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 07 Dec 2014 01:28:43 +0000 Received: (qmail 60620 invoked by uid 99); 7 Dec 2014 01:28:40 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Dec 2014 01:28:40 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id EAECE9BE6ED; Sun, 7 Dec 2014 01:28:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anatole@apache.org To: commits@tamaya.incubator.apache.org Date: Sun, 07 Dec 2014 01:28:40 -0000 Message-Id: <43fdebe2d666496ebf676c4d99d44581@git.apache.org> In-Reply-To: <8088b221fbc5412494bb8dd0c08d663e@git.apache.org> References: <8088b221fbc5412494bb8dd0c08d663e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] incubator-tamaya git commit: TAMAYA-19: Code cleanup - renamed annotation, fixed bugs. Removed unused/useless code including tests. X-Virus-Checked: Checked by ClamAV on 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 Authored: Sun Dec 7 02:28:30 2014 +0100 Committer: anatole 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 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("")); + return new PropertyProviderBuilder(""); } + + /** * 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 providers) { + if(providers.isEmpty()){ + return this; + } List 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 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 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 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 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: + *
    + *
  • The current valid Configuration is evaluated by calling {@code Configuration cfg = Configuration.current();}
  • + *
  • The current property String value is evaluated by calling {@code cfg.get("aValue");}
  • + *
  • if not successful, an error is thrown ({@link org.apache.tamaya.ConfigException}.
  • + *
  • On success, since no type conversion is involved, the value is injected.
  • + *
  • 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).
  • + *
+ * + * 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 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 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: - *
    - *
  • The current valid Configuration is evaluated by calling {@code Configuration cfg = Configuration.current();}
  • - *
  • The current property String value is evaluated by calling {@code cfg.get("aValue");}
  • - *
  • if not successful, an error is thrown ({@link org.apache.tamaya.ConfigException}.
  • - *
  • On success, since no type conversion is involved, the value is injected.
  • - *
  • 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).
  • - *
- * - * 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 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 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 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. *

*

- * Level mapping inspired by {@link org.slf4j.bridge.SLF4JBridgeHandler}: + * Level annotation inspired by {@link org.slf4j.bridge.SLF4JBridgeHandler}: *

*

*


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 get(String key) {
+        return this.baseProvider.get(key);
+    }
+
+    @Override
+    public boolean containsKey(String key) {
+        return this.baseProvider.containsKey(key);
+    }
+
+    @Override
+    public Map toMap() {
+        return this.baseProvider.toMap();
+    }
+
+    @Override
+    public MetaInfo getMetaInfo() {
+        return this.metaInfo;
+    }
+
+    @Override
+    public String toString(){
+        return "BuildablePropertyProvider -> " + getMetaInfo().toString();
+    }
+
+}