Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 62243 invoked from network); 12 Mar 2008 22:59:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2008 22:59:03 -0000 Received: (qmail 57615 invoked by uid 500); 12 Mar 2008 22:59:00 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 57479 invoked by uid 500); 12 Mar 2008 22:58:59 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 57470 invoked by uid 99); 12 Mar 2008 22:58:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Mar 2008 15:58:59 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Mar 2008 22:58:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 85D9F1A9838; Wed, 12 Mar 2008 15:58:39 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r636566 - /incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Date: Wed, 12 Mar 2008 22:58:38 -0000 To: cxf-commits@incubator.apache.org From: bimargulies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080312225839.85D9F1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bimargulies Date: Wed Mar 12 15:58:34 2008 New Revision: 636566 URL: http://svn.apache.org/viewvc?rev=636566&view=rev Log: cache method->wrapper-Class relationships, for a not entirely trivial speedup of repeated endpoint initialization. Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=636566&r1=636565&r2=636566&view=diff ============================================================================== --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java (original) +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Wed Mar 12 15:58:34 2008 @@ -25,6 +25,8 @@ import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Future; import javax.jws.Oneway; @@ -57,9 +59,20 @@ public class JaxWsServiceConfiguration extends AbstractServiceConfiguration { private JaxWsImplementorInfo implInfo; + /** + * We retrieve the wrapper methods more than once + * while creating an endpoint. So caching the wrapper + * classes saves CPU time. + * + * It would also be good to cache across creations, + * but Method.equals isn't good enough. + */ + private Map responseMethodClassCache; + private Map requestMethodClassCache; public JaxWsServiceConfiguration() { - + responseMethodClassCache = new HashMap(); + requestMethodClassCache = new HashMap(); } @Override @@ -506,6 +519,11 @@ @Override public Class getResponseWrapper(Method selected) { + Class cachedClass = responseMethodClassCache.get(selected); + if (cachedClass != null) { + return cachedClass; + } + Method m = getDeclaredMethod(selected); ResponseWrapper rw = m.getAnnotation(ResponseWrapper.class); @@ -518,8 +536,15 @@ } if (clsName.length() > 0) { + cachedClass = responseMethodClassCache.get(clsName); + if (cachedClass != null) { + return cachedClass; + } try { - return ClassLoaderUtils.loadClass(clsName, implInfo.getEndpointClass()); + Class r = ClassLoaderUtils.loadClass(clsName, implInfo.getEndpointClass()); + responseMethodClassCache.put(clsName, r); + responseMethodClassCache.put(selected, r); + return r; } catch (ClassNotFoundException e) { //do nothing, we will mock a schema for wrapper bean later on } @@ -558,6 +583,11 @@ @Override public Class getRequestWrapper(Method selected) { + Class cachedClass = requestMethodClassCache.get(selected); + if (cachedClass != null) { + return cachedClass; + } + Method m = getDeclaredMethod(selected); RequestWrapper rw = m.getAnnotation(RequestWrapper.class); @@ -569,8 +599,15 @@ } if (clsName.length() > 0) { + cachedClass = requestMethodClassCache.get(clsName); + if (cachedClass != null) { + return cachedClass; + } try { - return ClassLoaderUtils.loadClass(clsName, implInfo.getEndpointClass()); + Class r = ClassLoaderUtils.loadClass(clsName, implInfo.getEndpointClass()); + requestMethodClassCache.put(clsName, r); + requestMethodClassCache.put(selected, r); + return r; } catch (ClassNotFoundException e) { //do nothing, we will mock a schema for wrapper bean later on }