You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2010/07/28 10:51:02 UTC
svn commit: r979988 - in
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
container/BeanManagerImpl.java context/ContextFactory.java
Author: struberg
Date: Wed Jul 28 08:51:02 2010
New Revision: 979988
URL: http://svn.apache.org/viewvc?rev=979988&view=rev
Log:
OWB-425 tune getStandardContext to perform twice as well.
I removed the wrapping from scopeType -> enum -> scopeType
and the Array creation. This heavily used method now needs only
~35% of the time of the previous implementation
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
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=979988&r1=979987&r2=979988&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 Wed Jul 28 08:51:02 2010
@@ -273,45 +273,40 @@ public class BeanManagerImpl implements
{
Asserts.assertNotNull(scopeType, "scopeType paramter can not be null");
- List<Context> contexts = new ArrayList<Context>();
-
Context standardContext = null;
standardContext = ContextFactory.getStandardContext(scopeType);
- if(standardContext != null)
+ if(standardContext != null && standardContext.isActive())
{
- if(standardContext.isActive())
- {
- contexts.add(standardContext);
- }
+ return standardContext;
}
List<Context> others = contextMap.get(scopeType);
+ Context found = null;
+
if(others != null)
{
for(Context otherContext : others)
{
if(otherContext.isActive())
{
- contexts.add(otherContext);
+ if (found != null)
+ {
+ throw new IllegalStateException("More than one active context exists with scope type annotation @" + scopeType.getSimpleName());
+ }
+
+ found = otherContext;
}
}
}
-
- // Still null
- if (contexts.isEmpty())
+ if (found == null)
{
throw new ContextNotActiveException("WebBeans context with scope type annotation @" + scopeType.getSimpleName() + " does not exist within current thread");
}
- else if(contexts.size() > 1)
- {
- throw new IllegalStateException("More than one active context exists with scope type annotation @" + scopeType.getSimpleName());
- }
-
- return contexts.get(0);
+ return found;
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=979988&r1=979987&r2=979988&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java Wed Jul 28 08:51:02 2010
@@ -258,32 +258,9 @@ public final class ContextFactory
*/
public static Context getStandardContext(Class<? extends Annotation> scopeType)
{
- if (scopeType.equals(RequestScoped.class))
- {
- return getStandardContext(ContextTypes.REQUEST);
- }
- if (scopeType.equals(SessionScoped.class))
- {
- return getStandardContext(ContextTypes.SESSION);
- }
- if (scopeType.equals(ApplicationScoped.class))
- {
- return getStandardContext(ContextTypes.APPLICATION);
- }
- if (scopeType.equals(ConversationScoped.class))
- {
- return getStandardContext(ContextTypes.CONVERSATION);
- }
- if (scopeType.equals(Dependent.class))
- {
- return getStandardContext(ContextTypes.DEPENDENT);
- }
- if (scopeType.equals(Singleton.class))
- {
- return getStandardContext(ContextTypes.SINGLETON);
- }
-
- return null;
+ ContextsService contextService = getContextsService();
+
+ return contextService.getCurrentContext(scopeType);
}
/**