Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 872E8200BCB for ; Wed, 9 Nov 2016 12:52:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 84B53160AFD; Wed, 9 Nov 2016 11:52:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B369C160B0D for ; Wed, 9 Nov 2016 12:52:31 +0100 (CET) Received: (qmail 35520 invoked by uid 500); 9 Nov 2016 11:52:30 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 35493 invoked by uid 99); 9 Nov 2016 11:52:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2016 11:52:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A0A47F16A4; Wed, 9 Nov 2016 11:52:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rmannibucau@apache.org To: commits@deltaspike.apache.org Date: Wed, 09 Nov 2016 11:52:34 -0000 Message-Id: In-Reply-To: <6e4930cfa6f645cb8b8c4396d3c5769c@git.apache.org> References: <6e4930cfa6f645cb8b8c4396d3c5769c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [5/5] deltaspike git commit: adding prefix to @Configuration archived-at: Wed, 09 Nov 2016 11:52:32 -0000 adding prefix to @Configuration Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/8e6fa365 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/8e6fa365 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/8e6fa365 Branch: refs/heads/master Commit: 8e6fa365a3e8f52f1262320408457fa95d40cf00 Parents: b81d498 Author: rmannibucau Authored: Mon Nov 7 12:51:31 2016 +0100 Committer: rmannibucau Committed: Mon Nov 7 12:51:31 2016 +0100 ---------------------------------------------------------------------- .../core/api/config/Configuration.java | 5 +++ .../config/ProxyConfigurationLifecycle.java | 9 ++++-- .../InjectableConfigPropertyTest.java | 7 +++++ .../config/injectable/PrefixedConfigBean.java | 32 ++++++++++++++++++++ .../META-INF/apache-deltaspike.properties | 2 ++ 5 files changed, 52 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/8e6fa365/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/Configuration.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/Configuration.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/Configuration.java index 5c3e33d..d2fa689 100644 --- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/Configuration.java +++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/Configuration.java @@ -47,4 +47,9 @@ public @interface Configuration * @return the duration unit for {@see cacheFor()}. */ TimeUnit cacheUnit() default SECONDS; + + /** + * @return the key prefix to apply to all methods. + */ + String prefix() default ""; } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/8e6fa365/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ProxyConfigurationLifecycle.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ProxyConfigurationLifecycle.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ProxyConfigurationLifecycle.java index 645e227..13c687e 100644 --- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ProxyConfigurationLifecycle.java +++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ProxyConfigurationLifecycle.java @@ -56,7 +56,8 @@ class ProxyConfigurationLifecycle implements ContextualLifecycle final long cacheFor = configuration.cacheFor(); return Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), api, - new ConfigurationHandler(cacheFor <= 0 ? -1 : configuration.cacheUnit().toMillis(cacheFor))); + new ConfigurationHandler( + cacheFor <= 0 ? -1 : configuration.cacheUnit().toMillis(cacheFor), configuration.prefix())); } @Override @@ -74,10 +75,12 @@ class ProxyConfigurationLifecycle implements ContextualLifecycle private final ConcurrentMap> resolvers = new ConcurrentHashMap>(); private final long cacheMs; + private final String prefix; - private ConfigurationHandler(final long cacheMs) + private ConfigurationHandler(final long cacheMs, final String prefix) { this.cacheMs = cacheMs; + this.prefix = prefix; } @Override @@ -137,7 +140,7 @@ class ProxyConfigurationLifecycle implements ContextualLifecycle } typedResolver = delegate.asResolver( - annotation.name(), annotation.defaultValue(), returnType, + prefix + annotation.name(), annotation.defaultValue(), returnType, annotation.converter(), annotation.parameterizedBy(), annotation.projectStageAware(), annotation.evaluateVariables()); if (cacheMs > 0) http://git-wip-us.apache.org/repos/asf/deltaspike/blob/8e6fa365/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java index bb1e573..5009949 100644 --- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java +++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java @@ -149,4 +149,11 @@ public class InjectableConfigPropertyTest assertEquals(singletonList(new URL("http://127.0.0.2")), settingsBean.urlListFromProperties()); assertEquals("value", settingsBean.customSourceValue()); } + + @Test + public void proxyPrefix() throws MalformedURLException + { + PrefixedConfigBean settingsBean = BeanProvider.getContextualReference(PrefixedConfigBean.class); + assertEquals("done", settingsBean.value()); + } } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/8e6fa365/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/PrefixedConfigBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/PrefixedConfigBean.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/PrefixedConfigBean.java new file mode 100644 index 0000000..46dbd49 --- /dev/null +++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/PrefixedConfigBean.java @@ -0,0 +1,32 @@ +/* + * 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.deltaspike.test.core.api.config.injectable; + +import org.apache.deltaspike.core.api.config.ConfigProperty; +import org.apache.deltaspike.core.api.config.Configuration; + +import java.net.URL; +import java.util.List; + +@Configuration(prefix = "prefix.") +public interface PrefixedConfigBean +{ + @ConfigProperty(name = "suffix") + String value(); +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/8e6fa365/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties index 61a86bf..c4a11c1 100644 --- a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties +++ b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties @@ -50,3 +50,5 @@ my.very.secret=onlyIDoKnowIt deactivate.org.apache.deltaspike.test.core.impl.activation.DeactivatedClass=true urlListFromProperties = http://127.0.0.2 + +prefix.suffix = done