Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 97075 invoked from network); 19 Mar 2008 18:29:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Mar 2008 18:29:05 -0000 Received: (qmail 20513 invoked by uid 500); 19 Mar 2008 18:29:01 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 20450 invoked by uid 500); 19 Mar 2008 18:29:01 -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 20409 invoked by uid 99); 19 Mar 2008 18:29:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Mar 2008 11:29:01 -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, 19 Mar 2008 18:28:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A30EC1A9832; Wed, 19 Mar 2008 11:28:42 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r638963 - in /incubator/cxf/trunk: benchmark/profiling/ benchmark/profiling/src/main/java/org/apache/cxf/profile/ common/common/src/main/java/org/apache/cxf/configuration/spring/ Date: Wed, 19 Mar 2008 18:28:41 -0000 To: cxf-commits@incubator.apache.org From: bimargulies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080319182842.A30EC1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bimargulies Date: Wed Mar 19 11:28:38 2008 New Revision: 638963 URL: http://svn.apache.org/viewvc?rev=638963&view=rev Log: A small but measurable speedup in spring initialization. Added: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java (with props) Modified: incubator/cxf/trunk/benchmark/profiling/build.xml incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java Modified: incubator/cxf/trunk/benchmark/profiling/build.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/benchmark/profiling/build.xml?rev=638963&r1=638962&r2=638963&view=diff ============================================================================== --- incubator/cxf/trunk/benchmark/profiling/build.xml (original) +++ incubator/cxf/trunk/benchmark/profiling/build.xml Wed Mar 19 11:28:38 2008 @@ -1,4 +1,4 @@ - + @@ -152,11 +152,24 @@ - + + + + + + + + + + + + + + Added: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java?rev=638963&view=auto ============================================================================== --- incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java (added) +++ incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java Wed Mar 19 11:28:38 2008 @@ -0,0 +1,53 @@ +/** + * 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.cxf.profile; + +import com.jprofiler.api.agent.Controller; + +import java.io.File; + +import org.apache.cxf.BusFactory; + +/** + * + */ +public class DefaultBusInitialization { + + public static void main(String[] args) { + Controller.stopAllocRecording(); + Controller.stopCPURecording(); + DefaultBusInitialization dbi = new DefaultBusInitialization(); + Controller.startCPURecording(true); + Controller.startAllocRecording(true); + int count = Integer.parseInt(args[0]); + for (int x = 0; x < count; x++) { + dbi.iteration(); + } + Controller.stopAllocRecording(); + Controller.stopCPURecording(); + if (args.length > 1) { + Controller.saveSnapshot(new File(args[1])); + } + } + + private void iteration() { + BusFactory.newInstance().createBus(); + } +} Propchange: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=638963&r1=638962&r2=638963&view=diff ============================================================================== --- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java (original) +++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java Wed Mar 19 11:28:38 2008 @@ -18,6 +18,7 @@ */ package org.apache.cxf.configuration.spring; +import java.util.Map; import java.util.StringTokenizer; import javax.xml.bind.JAXBContext; @@ -32,6 +33,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.cxf.common.util.CacheMap; import org.apache.cxf.helpers.DOMUtils; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.config.BeanDefinition; @@ -44,9 +46,9 @@ public abstract class AbstractBeanDefinitionParser extends org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser { - + private static Map packageContextCache = new CacheMap(); private Class beanClass; - + @Override protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) { boolean setBus = parseAttributes(element, ctx, bean); @@ -255,7 +257,11 @@ if (null != c && c.getPackage() != null) { pkg = c.getPackage().getName(); } - context = JAXBContext.newInstance(pkg, getClass().getClassLoader()); + context = packageContextCache.get(pkg); + if (context == null) { + context = JAXBContext.newInstance(pkg, getClass().getClassLoader()); + packageContextCache.put(pkg, context); + } Unmarshaller u = context.createUnmarshaller(); if (c != null) { obj = u.unmarshal(data, c);