Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 583B018B03 for ; Fri, 3 Jul 2015 09:44:58 +0000 (UTC) Received: (qmail 19792 invoked by uid 500); 3 Jul 2015 09:44:58 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 19731 invoked by uid 500); 3 Jul 2015 09:44:58 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 19721 invoked by uid 99); 3 Jul 2015 09:44:58 -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; Fri, 03 Jul 2015 09:44:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0F7C8E17FA; Fri, 3 Jul 2015 09:44:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: [CXF-6483] Optimizing ConfigurerImpl sorting code Date: Fri, 3 Jul 2015 09:44:58 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 6e721a5a3 -> aa4950075 [CXF-6483] Optimizing ConfigurerImpl sorting code Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/aa495007 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/aa495007 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/aa495007 Branch: refs/heads/3.0.x-fixes Commit: aa4950075db3823b1a501cf6d81bb78da89cd2ed Parents: 6e721a5 Author: Sergey Beryozkin Authored: Fri Jul 3 10:42:20 2015 +0100 Committer: Sergey Beryozkin Committed: Fri Jul 3 10:44:40 2015 +0100 ---------------------------------------------------------------------- .../cxf/bus/blueprint/ConfigurerImpl.java | 32 +++++++------------- .../configuration/spring/ConfigurerImpl.java | 32 +++++++------------- 2 files changed, 22 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/aa495007/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java b/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java index b2a09b5..a251e4d 100644 --- a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java +++ b/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java @@ -21,11 +21,9 @@ package org.apache.cxf.bus.blueprint; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; @@ -48,15 +46,22 @@ public class ConfigurerImpl implements Configurer { BlueprintContainer container; private final Map> wildCardBeanDefinitions - = new HashMap>(); + = new TreeMap>(); - static class MatcherHolder { + static class MatcherHolder implements Comparable { Matcher matcher; String wildCardId; public MatcherHolder(String orig, Matcher matcher) { wildCardId = orig; this.matcher = matcher; } + @Override + public int compareTo(MatcherHolder mh) { + Integer literalCharsLen1 = this.wildCardId.replaceAll("\\*", "").length(); + Integer literalCharsLen2 = mh.wildCardId.replaceAll("\\*", "").length(); + // The expression with more literal characters should end up on the top of the list + return literalCharsLen1.compareTo(literalCharsLen2) * -1; + } } @@ -91,10 +96,6 @@ public class ConfigurerImpl implements Configurer { } } } - Comparator comp = new MatcherHolderComparator(); - for (Map.Entry> entry : wildCardBeanDefinitions.entrySet()) { - Collections.sort(entry.getValue(), comp); - } } public void configureBean(Object beanInstance) { @@ -181,16 +182,5 @@ public class ConfigurerImpl implements Configurer { return beanName; } - private static class MatcherHolderComparator implements Comparator { - - @Override - public int compare(MatcherHolder mh1, MatcherHolder mh2) { - Integer literalCharsLen1 = mh1.wildCardId.replaceAll("\\*", "").length(); - Integer literalCharsLen2 = mh2.wildCardId.replaceAll("\\*", "").length(); - // The expression with more literal characters should end up on the top of the list - return literalCharsLen1.compareTo(literalCharsLen2) * -1; - - } - - } + } http://git-wip-us.apache.org/repos/asf/cxf/blob/aa495007/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java b/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java index c481de3..1e745d8 100644 --- a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java +++ b/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java @@ -21,13 +21,11 @@ package org.apache.cxf.configuration.spring; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Level; import java.util.logging.Logger; @@ -61,16 +59,23 @@ public class ConfigurerImpl extends BeanConfigurerSupport private Set appContexts; private final Map> wildCardBeanDefinitions - = new HashMap>(); + = new TreeMap>(); private BeanFactory beanFactory; - static class MatcherHolder { + static class MatcherHolder implements Comparable { Matcher matcher; String wildCardId; public MatcherHolder(String orig, Matcher matcher) { wildCardId = orig; this.matcher = matcher; } + @Override + public int compareTo(MatcherHolder mh) { + Integer literalCharsLen1 = this.wildCardId.replaceAll("\\*", "").length(); + Integer literalCharsLen2 = mh.wildCardId.replaceAll("\\*", "").length(); + // The expression with more literal characters should end up on the top of the list + return literalCharsLen1.compareTo(literalCharsLen2) * -1; + } } public ConfigurerImpl() { @@ -120,10 +125,6 @@ public class ConfigurerImpl extends BeanConfigurerSupport } } } - Comparator comp = new MatcherHolderComparator(); - for (Map.Entry> entry : wildCardBeanDefinitions.entrySet()) { - Collections.sort(entry.getValue(), comp); - } } public void configureBean(Object beanInstance) { @@ -284,16 +285,5 @@ public class ConfigurerImpl extends BeanConfigurerSupport protected Set getAppContexts() { return appContexts; } - private static class MatcherHolderComparator implements Comparator { - - @Override - public int compare(MatcherHolder mh1, MatcherHolder mh2) { - Integer literalCharsLen1 = mh1.wildCardId.replaceAll("\\*", "").length(); - Integer literalCharsLen2 = mh2.wildCardId.replaceAll("\\*", "").length(); - // The expression with more literal characters should end up on the top of the list - return literalCharsLen1.compareTo(literalCharsLen2) * -1; - - } - - } + }