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 A6C62C77E for ; Mon, 5 Jan 2015 13:57:37 +0000 (UTC) Received: (qmail 18233 invoked by uid 500); 5 Jan 2015 13:57:38 -0000 Delivered-To: apmail-tamaya-commits-archive@tamaya.apache.org Received: (qmail 18209 invoked by uid 500); 5 Jan 2015 13:57:38 -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 18200 invoked by uid 99); 5 Jan 2015 13:57:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2015 13:57:38 +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; Mon, 05 Jan 2015 13:57:16 +0000 Received: (qmail 18037 invoked by uid 99); 5 Jan 2015 13:57:14 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2015 13:57:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C0B59A3F895; Mon, 5 Jan 2015 13:57:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: struberg@apache.org To: commits@tamaya.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-tamaya git commit: TAMAYA-42 only resolve the ConfigurationContext once Date: Mon, 5 Jan 2015 13:57:13 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-tamaya Updated Branches: refs/heads/master 909ec1616 -> 3368db2e1 TAMAYA-42 only resolve the ConfigurationContext once The Configuration and ConfigurationConstance impls belong together 1:1. We not only don't need to proxy them internally but also shall not do this otherwise we would trash the performance. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3368db2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3368db2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3368db2e Branch: refs/heads/master Commit: 3368db2e1a8eb5b54fdc8c5320acbfbdb2cfa245 Parents: 909ec16 Author: Mark Struberg Authored: Mon Jan 5 14:55:56 2015 +0100 Committer: Mark Struberg Committed: Mon Jan 5 14:55:56 2015 +0100 ---------------------------------------------------------------------- .../tamaya/core/internal/DefaultConfiguration.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3368db2e/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java index 3769e27..651398b 100644 --- a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java +++ b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java @@ -45,6 +45,9 @@ public class DefaultConfiguration implements Configuration { private static final Logger LOG = Logger.getLogger(DefaultConfiguration.class.getName()); + private final ConfigurationContext configurationContext = ServiceContext.getInstance().getService(ConfigurationContext.class).get(); + + /** * This method evaluates the given configuration key. Hereby if goes down the chain or PropertySource instances * provided by the current {@link org.apache.tamaya.spi.ConfigurationContext}. The first non-null-value returned @@ -57,7 +60,7 @@ public class DefaultConfiguration implements Configuration { */ @Override public Optional get(String key) { - List propertySources = ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertySources(); + List propertySources = configurationContext.getPropertySources(); String unfilteredValue = null; for (PropertySource propertySource : propertySources) { Optional value = propertySource.get(key); @@ -67,8 +70,7 @@ public class DefaultConfiguration implements Configuration { } } // Apply filters to values, prevent values filtered to null! - for(PropertyFilter filter: - ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertyFilters()){ + for(PropertyFilter filter: configurationContext.getPropertyFilters()){ unfilteredValue = filter.filterProperty(key, unfilteredValue, (String k) -> key.equals(k)?null:get(k).orElse(null)); } @@ -77,8 +79,7 @@ public class DefaultConfiguration implements Configuration { @Override public Map getProperties() { - List propertySources = new ArrayList<>( - ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertySources()); + List propertySources = new ArrayList<>(configurationContext.getPropertySources()); Collections.reverse(propertySources); Map result = new HashMap<>(); for (PropertySource propertySource : propertySources) { @@ -95,7 +96,7 @@ public class DefaultConfiguration implements Configuration { } // Apply filters to values, prevent values filtered to null! for(PropertyFilter filter: - ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertyFilters()){ + configurationContext.getPropertyFilters()){ result.replaceAll((k,v) -> filter.filterProperty(k, v, (String k2) -> k2.equals(k)?null:get(k2).orElse(null))); } @@ -119,8 +120,7 @@ public class DefaultConfiguration implements Configuration { public Optional get(String key, Class type) { Optional value = get(key); if (value.isPresent()) { - List> converters = ServiceContext.getInstance().getService(ConfigurationContext.class) - .get().getPropertyConverters(type); + List> converters = configurationContext.getPropertyConverters(type); for (PropertyConverter converter : converters) { try { T t = converter.convert(value.get());