Return-Path: Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: (qmail 56569 invoked from network); 11 Mar 2011 19:04:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Mar 2011 19:04:00 -0000 Received: (qmail 48421 invoked by uid 500); 11 Mar 2011 19:04:00 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 48389 invoked by uid 500); 11 Mar 2011 19:04:00 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 48381 invoked by uid 99); 11 Mar 2011 19:04:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Mar 2011 19:04:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Mar 2011 19:03:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 95F5C238890D; Fri, 11 Mar 2011 19:03:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1080727 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/BeanManagerImpl.java intercept/WebBeansInterceptorConfig.java Date: Fri, 11 Mar 2011 19:03:36 -0000 To: commits@openwebbeans.apache.org From: struberg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110311190336.95F5C238890D@eris.apache.org> Author: struberg Date: Fri Mar 11 19:03:36 2011 New Revision: 1080727 URL: http://svn.apache.org/viewvc?rev=1080727&view=rev Log: OWB-544 drop concurrent Collections where not needed Most of our Sets and Lists in BeanManagerImpl will only get filled at startup time. Thus we don't need them to be concurrency aware. This just costs performance Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1080727&r1=1080726&r2=1080727&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Fri Mar 11 19:03:36 2011 @@ -313,7 +313,7 @@ public class BeansDeployer beans.clear(); //Adding interceptors to validate - Set> interceptors = manager.getInterceptors(); + List> interceptors = manager.getInterceptors(); for(javax.enterprise.inject.spi.Interceptor interceptor : interceptors) { WebBeansInterceptor wbInt = (WebBeansInterceptor)interceptor; Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1080727&r1=1080726&r2=1080727&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Fri Mar 11 19:03:36 2011 @@ -24,6 +24,7 @@ import java.lang.reflect.ParameterizedTy import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Iterator; @@ -31,7 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; import javax.el.ELResolver; @@ -113,14 +113,31 @@ public class BeanManagerImpl implements { private static final long serialVersionUID = 1L; - /**Holds the context with key scope*/ - private Map, List> contextMap = new ConcurrentHashMap, List>(); + /** + * Holds the non-standard contexts with key = scope type + * This will get used if more than 1 scope exists. + * Since the contexts will only get added through the + * {@link org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl} + * we don't even need a ConcurrentHashMap. + * @see #singleContextMap + */ + private Map, List> contextMap = new HashMap, List>(); + + /** + * This will hold non-standard contexts where only one Context implementation got registered + * for the given key = scope type + * Since the contexts will only get added through the + * {@link org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl} + * we don't even need a ConcurrentHashMap. + * @see #contextMap + */ + private Map, Context> singleContextMap = new HashMap, Context>(); /**Deployment archive beans*/ private Set> deploymentBeans = new CopyOnWriteArraySet>(); /**Activity interceptors*/ - private Set> webBeansInterceptors = new CopyOnWriteArraySet>(); + private List> webBeansInterceptors = new ArrayList>(); /**Normal scoped cache proxies*/ private Map, Object> cacheProxies = new ConcurrentHashMap, Object>(); @@ -138,26 +155,26 @@ public class BeanManagerImpl implements private WebBeansXMLConfigurator xmlConfigurator = null; /**Additional decorator class*/ - private List> additionalDecoratorClasses = new CopyOnWriteArrayList>(); + private List> additionalDecoratorClasses = new ArrayList>(); /**Additional interceptor class*/ - private List> additionalInterceptorClasses = new CopyOnWriteArrayList>(); + private List> additionalInterceptorClasses = new ArrayList>(); /** * This list contains additional qualifiers which got set via the {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addQualifier(Class)} * event function. */ - private List> additionalQualifiers = Collections.synchronizedList(new ArrayList>()); + private List> additionalQualifiers = new ArrayList>(); /** * This list contains additional scopes which got set via the * {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addScope(Class, boolean, boolean)} event function. */ - private List additionalScopes = Collections.synchronizedList(new ArrayList()); + private List additionalScopes = new ArrayList(); private ErrorStack errorStack = new ErrorStack(); - private List> additionalAnnotatedTypes = new CopyOnWriteArrayList>(); + private List> additionalAnnotatedTypes = new ArrayList>(); /** * This map stores all beans along with their unique {@link javax.enterprise.inject.spi.PassivationCapable} id. @@ -277,15 +294,26 @@ public class BeanManagerImpl implements { Asserts.assertNotNull(scopeType, "scopeType paramter can not be null"); - Context standardContext = null; - - standardContext = webBeansContext.getContextFactory().getStandardContext(scopeType); + Context standardContext = webBeansContext.getContextFactory().getStandardContext(scopeType); if(standardContext != null && standardContext.isActive()) { return standardContext; } - + + // this is by far the most case + Context singleContext = singleContextMap.get(scopeType); + if (singleContext != null) + { + if (!singleContext.isActive()) + { + throw new ContextNotActiveException("WebBeans context with scope type annotation @" + scopeType.getSimpleName() + " does not exist within current thread"); + } + return singleContext; + } + + // the spec also allows for multiple contexts existing for the same scope type + // but in this case only one must be active at a time (for the current thread) List others = contextMap.get(scopeType); Context found = null; @@ -612,7 +640,7 @@ public class BeanManagerImpl implements return this.deploymentBeans; } - public Set> getInterceptors() + public List> getInterceptors() { return this.webBeansInterceptors; } @@ -632,10 +660,21 @@ public class BeanManagerImpl implements if(contextList == null) { - contextList = new CopyOnWriteArrayList(); - contextList.add(context); - - contextMap.put(scopeType, contextList); + Context singleContext = singleContextMap.get(scopeType); + if (singleContext == null) + { + // first put them into the singleContextMap + singleContextMap.put(scopeType, context); + } + else + { + // from the 2nd Context for this scopetype on, we need to maintain a List for them + contextList = new ArrayList(); + contextList.add(singleContext); + contextList.add(context); + + contextMap.put(scopeType, contextList); + } } else { @@ -1171,6 +1210,7 @@ public class BeanManagerImpl implements this.additionalQualifiers.clear(); this.additionalScopes.clear(); this.cacheProxies.clear(); + this.singleContextMap.clear(); this.contextMap.clear(); this.deploymentBeans.clear(); this.errorStack.clear(); Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1080727&r1=1080726&r2=1080727&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java Fri Mar 11 19:03:36 2011 @@ -74,7 +74,7 @@ public final class WebBeansInterceptorCo /** * Configures WebBeans specific interceptor class. * - * @param interceptorClazz interceptor class + * @param interceptorBindingTypes interceptor class */ public static void configureInterceptorClass(AbstractInjectionTargetBean delegate, Annotation[] interceptorBindingTypes) { @@ -612,8 +612,8 @@ public final class WebBeansInterceptorCo { Set> set = new HashSet>(); - Iterator> it = Collections.unmodifiableSet(webBeansContext.getBeanManagerImpl().getInterceptors()).iterator(); - WebBeansInterceptor interceptor = null; + Iterator> it = webBeansContext.getBeanManagerImpl().getInterceptors().iterator(); + WebBeansInterceptor interceptor; List> bindingTypes = new ArrayList>(); List listAnnot = new ArrayList();