Author: dblevins
Date: Wed Dec 8 01:30:48 2010
New Revision: 1043271
URL: http://svn.apache.org/viewvc?rev=1043271&view=rev
Log:
Created WebBeansContext field in some classes that used it frequently in
non-static methods
OWB-503 status: 519 code uses
Total of 191155 static synchronized accesses and 258649 hashed calls in 340
tests
Average of 562 static synchronized accesses and 760 hashed calls per test
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/webbeans/WebBeansInterceptor.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.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=1043271&r1=1043270&r2=1043271&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
Wed Dec 8 01:30:48 2010
@@ -100,7 +100,8 @@ public class BeansDeployer
/**Discover ejb or not*/
protected boolean discoverEjb = false;
-
+ private final WebBeansContext webBeansContext;
+
/**
* Creates a new deployer with given xml configurator.
*
@@ -109,7 +110,8 @@ public class BeansDeployer
public BeansDeployer(WebBeansXMLConfigurator xmlConfigurator)
{
this.xmlConfigurator = xmlConfigurator;
- String usage =
WebBeansContext.getInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_EJB_DISCOVERY);
+ this.webBeansContext = WebBeansContext.getInstance();
+ String usage =
webBeansContext.getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_EJB_DISCOVERY);
this.discoverEjb = Boolean.parseBoolean(usage);
}
@@ -129,7 +131,7 @@ public class BeansDeployer
if (!deployed)
{
//Load Extensions
-
WebBeansContext.getInstance().getExtensionLoader().loadExtensionServices();
+ webBeansContext.getExtensionLoader().loadExtensionServices();
// Bind manager
JNDIService service =
ServiceLoader.getService(JNDIService.class);
@@ -142,11 +144,11 @@ public class BeansDeployer
//Assume, actual JNDI implementation
else
{
-
service.bind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME,
WebBeansContext.getInstance().getBeanManagerImpl().getReference());
+
service.bind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME,
webBeansContext.getBeanManagerImpl().getReference());
}
// Register Manager built-in component
-
WebBeansContext.getInstance().getBeanManagerImpl().addBean(WebBeansUtil.getManagerBean());
+
webBeansContext.getBeanManagerImpl().addBean(WebBeansUtil.getManagerBean());
//Fire Event
fireBeforeBeanDiscoveryEvent();
@@ -196,7 +198,7 @@ public class BeansDeployer
*/
private void configureDefaultBeans()
{
- BeanManagerImpl beanManager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl beanManager = webBeansContext.getBeanManagerImpl();
// Register Conversation built-in component
beanManager.addBean(WebBeansUtil.getConversationBean());
@@ -211,8 +213,8 @@ public class BeansDeployer
beanManager.addBean(WebBeansUtil.getEventBean());
//REgister Provider Beans
- OpenWebBeansJavaEEPlugin beanEeProvider =
WebBeansContext.getInstance().getPluginLoader().getJavaEEPlugin();
- OpenWebBeansWebPlugin beanWebProvider =
WebBeansContext.getInstance().getPluginLoader().getWebPlugin();
+ OpenWebBeansJavaEEPlugin beanEeProvider =
webBeansContext.getPluginLoader().getJavaEEPlugin();
+ OpenWebBeansWebPlugin beanWebProvider =
webBeansContext.getPluginLoader().getWebPlugin();
if(beanEeProvider != null)
{
@@ -249,7 +251,7 @@ public class BeansDeployer
*/
private void fireBeforeBeanDiscoveryEvent()
{
- BeanManager manager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManager manager = webBeansContext.getBeanManagerImpl();
manager.fireEvent(new BeforeBeanDiscoveryImpl(),new Annotation[0]);
}
@@ -258,7 +260,7 @@ public class BeansDeployer
*/
private void fireAfterBeanDiscoveryEvent()
{
- BeanManagerImpl manager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
manager.fireEvent(new AfterBeanDiscoveryImpl(),new Annotation[0]);
WebBeansUtil.inspectErrorStack("There are errors that are added by
AfterBeanDiscovery event observers. Look at logs for further details");
@@ -269,7 +271,7 @@ public class BeansDeployer
*/
private void fireAfterDeploymentValidationEvent()
{
- BeanManagerImpl manager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
manager.fireEvent(new AfterDeploymentValidationImpl(),new
Annotation[0]);
WebBeansUtil.inspectErrorStack("There are errors that are added by
AfterDeploymentValidation event observers. Look at logs for further details");
@@ -282,10 +284,10 @@ public class BeansDeployer
{
logger.debug("Validation of injection points has started.");
-
WebBeansContext.getInstance().getDecoratorsManager().validateDecoratorClasses();
-
WebBeansContext.getInstance().getInterceptorsManager().validateInterceptorClasses();
+ webBeansContext.getDecoratorsManager().validateDecoratorClasses();
+ webBeansContext.getInterceptorsManager().validateInterceptorClasses();
- BeanManagerImpl manager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
Set<Bean<?>> beans = new HashSet<Bean<?>>();
//Adding decorators to validate
@@ -334,7 +336,7 @@ public class BeansDeployer
*/
private void validate(Set<Bean<?>> beans)
{
- BeanManagerImpl manager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
if (beans != null && beans.size() > 0)
{
@@ -383,7 +385,7 @@ public class BeansDeployer
else
{
if(!bean.getBeanClass().isAnnotationPresent(javax.decorator.Decorator.class)
- &&
!WebBeansContext.getInstance().getBeanManagerImpl().containsCustomDecoratorClass(bean.getBeanClass()))
+ &&
!webBeansContext.getBeanManagerImpl().containsCustomDecoratorClass(bean.getBeanClass()))
{
throw new WebBeansConfigurationException(
"Delegate injection points can not
defined by beans that are not decorator. Injection point : "
@@ -468,7 +470,7 @@ public class BeansDeployer
for(Class<?> implClass : classIndex)
{
//Define annotation type
- AnnotatedType<?> annotatedType =
WebBeansContext.getInstance().getAnnotatedElementFactory().newAnnotatedType(implClass);
+ AnnotatedType<?> annotatedType =
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(implClass);
if (null != annotatedType)
{
@@ -495,7 +497,7 @@ public class BeansDeployer
*/
private void deployAdditionalAnnotatedTypes()
{
- BeanManagerImpl beanManager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl beanManager = webBeansContext.getBeanManagerImpl();
List<AnnotatedType<?>> annotatedTypes =
beanManager.getAnnotatedTypes();
@@ -652,7 +654,7 @@ public class BeansDeployer
protected void checkXMLSpecializations()
{
// Check XML specializations
- Set<Class<?>> clazzes =
WebBeansContext.getInstance().getxMLSpecializesManager().getXMLSpecializationClasses();
+ Set<Class<?>> clazzes =
webBeansContext.getxMLSpecializesManager().getXMLSpecializationClasses();
Iterator<Class<?>> it = clazzes.iterator();
Class<?> superClass = null;
Class<?> specialClass = null;
@@ -694,7 +696,7 @@ public class BeansDeployer
validate = true;
}
}
- else
if(WebBeansContext.getInstance().getBeanManagerImpl().isPassivatingScope(beanObj.getScope()))
+ else
if(webBeansContext.getBeanManagerImpl().isPassivatingScope(beanObj.getScope()))
{
if(WebBeansUtil.isPassivationCapable(beanObj) == null)
{
@@ -738,11 +740,11 @@ public class BeansDeployer
Class<? extends Annotation> stereoClass = (Class<? extends
Annotation>) beanClass;
if (AnnotationUtil.isStereoTypeAnnotation(stereoClass))
{
- if
(!WebBeansContext.getInstance().getxMLAnnotationTypeManager().hasStereoType(stereoClass))
+ if
(!webBeansContext.getxMLAnnotationTypeManager().hasStereoType(stereoClass))
{
WebBeansUtil.checkStereoTypeClass(stereoClass);
StereoTypeModel model = new
StereoTypeModel(stereoClass);
-
WebBeansContext.getInstance().getStereoTypeManager().addStereoTypeModel(model);
+
webBeansContext.getStereoTypeManager().addStereoTypeModel(model);
}
}
}
@@ -758,13 +760,13 @@ public class BeansDeployer
protected void addDefaultStereoTypes()
{
StereoTypeModel model = new StereoTypeModel(Model.class);
-
WebBeansContext.getInstance().getStereoTypeManager().addStereoTypeModel(model);
+ webBeansContext.getStereoTypeManager().addStereoTypeModel(model);
model = new StereoTypeModel(javax.decorator.Decorator.class);
-
WebBeansContext.getInstance().getStereoTypeManager().addStereoTypeModel(model);
+ webBeansContext.getStereoTypeManager().addStereoTypeModel(model);
model = new StereoTypeModel(Interceptor.class);
-
WebBeansContext.getInstance().getStereoTypeManager().addStereoTypeModel(model);
+ webBeansContext.getStereoTypeManager().addStereoTypeModel(model);
}
/**
@@ -776,7 +778,7 @@ public class BeansDeployer
protected <T> boolean defineManagedBean(Class<T> clazz,
ProcessAnnotatedTypeImpl<T> processAnnotatedEvent)
{
//Bean manager
- BeanManagerImpl manager =
WebBeansContext.getInstance().getBeanManagerImpl();
+ BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
//Create an annotated type
AnnotatedType<T> annotatedType =
processAnnotatedEvent.getAnnotatedType();
@@ -861,8 +863,8 @@ public class BeansDeployer
}
else
{
-
if(WebBeansContext.getInstance().getBeanManagerImpl().containsCustomDecoratorClass(annotatedType.getJavaClass())
||
-
WebBeansContext.getInstance().getBeanManagerImpl().containsCustomInterceptorClass(annotatedType.getJavaClass()))
+
if(webBeansContext.getBeanManagerImpl().containsCustomDecoratorClass(annotatedType.getJavaClass())
||
+
webBeansContext.getBeanManagerImpl().containsCustomInterceptorClass(annotatedType.getJavaClass()))
{
return false;
}
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=1043271&r1=1043270&r2=1043271&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 Dec 8 01:30:48 2010
@@ -172,6 +172,7 @@ public class BeanManagerImpl implements
* Scanner Service ref
*/
private ScannerService scannerService;
+ private final WebBeansContext webBeansContext;
//private WebBeansLogger logger =
WebBeansLogger.getLogger(BeanManagerImpl.class);
@@ -187,6 +188,7 @@ public class BeanManagerImpl implements
*/
public BeanManagerImpl(WebBeansContext webBeansContext)
{
+ this.webBeansContext = webBeansContext;
injectionResolver = new InjectionResolver(this);
notificationManager = new NotificationManager();
annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
@@ -679,7 +681,7 @@ public class BeanManagerImpl implements
contextual = ((SerializableBean)contextual).getBean();
}
- return
WebBeansContext.getInstance().getCreationalContextFactory().getCreationalContext(contextual);
+ return
webBeansContext.getCreationalContextFactory().getCreationalContext(contextual);
}
/**
@@ -843,7 +845,7 @@ public class BeanManagerImpl implements
if(!(creationalContext instanceof CreationalContextImpl))
{
- creationalContext =
WebBeansContext.getInstance().getCreationalContextFactory().wrappedCreationalContext(creationalContext,
bean);
+ creationalContext =
webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext,
bean);
}
@@ -862,7 +864,7 @@ public class BeanManagerImpl implements
if (instance == null)
{
//Create Managed Bean Proxy
- instance =
WebBeansContext.getInstance().getJavassistProxyFactory().createNormalScopedBeanProxy((AbstractOwbBean<?>)bean,creationalContext);
+ instance =
webBeansContext.getJavassistProxyFactory().createNormalScopedBeanProxy((AbstractOwbBean<?>)bean,creationalContext);
//Cached instance
cacheProxies.put(bean, instance);
@@ -904,7 +906,7 @@ public class BeanManagerImpl implements
}
}
- OpenWebBeansEjbPlugin ejbPlugin =
WebBeansContext.getInstance().getPluginLoader().getEjbPlugin();
+ OpenWebBeansEjbPlugin ejbPlugin =
webBeansContext.getPluginLoader().getEjbPlugin();
if(ejbPlugin == null)
{
throw new IllegalStateException("There is no EJB plugin
provider. Injection is failed for bean : " + bean);
@@ -916,7 +918,7 @@ public class BeanManagerImpl implements
//Create JMS Proxy
else if(bean instanceof JmsBeanMarker)
{
- OpenWebBeansJmsPlugin jmsPlugin =
WebBeansContext.getInstance().getPluginLoader().getJmsPlugin();
+ OpenWebBeansJmsPlugin jmsPlugin =
webBeansContext.getPluginLoader().getJmsPlugin();
if(jmsPlugin == null)
{
throw new IllegalStateException("There is no JMS plugin
provider. Injection is failed for bean : " + bean);
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=1043271&r1=1043270&r2=1043271&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Wed Dec 8 01:30:48 2010
@@ -78,7 +78,8 @@ public class WebBeansInterceptor<T> exte
/**Delegate Bean*/
private AbstractInjectionTargetBean<T> delegateBean;
-
+ private final WebBeansContext webBeansContext;
+
public WebBeansInterceptor(AbstractInjectionTargetBean<T> delegateBean)
{
super(WebBeansType.INTERCEPTOR,delegateBean.getReturnType());
@@ -86,6 +87,7 @@ public class WebBeansInterceptor<T> exte
this.delegateBean = delegateBean;
this.clazz = getDelegate().getReturnType();
+ webBeansContext = WebBeansContext.getInstance();
}
public AbstractOwbBean<T> getDelegate()
@@ -191,9 +193,9 @@ public class WebBeansInterceptor<T> exte
Set<Annotation> declared = null;
Annotation[] anns = null;
- if
(WebBeansContext.getInstance().getxMLAnnotationTypeManager().hasInterceptorBindingType(clazzAnnot))
+ if
(webBeansContext.getxMLAnnotationTypeManager().hasInterceptorBindingType(clazzAnnot))
{
- declared =
WebBeansContext.getInstance().getxMLAnnotationTypeManager().getInterceptorBindingTypeInherites(clazzAnnot);
+ declared =
webBeansContext.getxMLAnnotationTypeManager().getInterceptorBindingTypeInherites(clazzAnnot);
anns = new Annotation[declared.size()];
anns = declared.toArray(anns);
}
@@ -283,9 +285,9 @@ public class WebBeansInterceptor<T> exte
@SuppressWarnings("unchecked")
protected T createInstance(CreationalContext<T> creationalContext)
{
- Context context =
WebBeansContext.getInstance().getBeanManagerImpl().getContext(getScope());
+ Context context =
webBeansContext.getBeanManagerImpl().getContext(getScope());
Object actualInstance = context.get((Bean<Object>)this.delegateBean,
(CreationalContext<Object>)creationalContext);
- T proxy = (T)
WebBeansContext.getInstance().getJavassistProxyFactory().createDependentScopedBeanProxy(this.delegateBean,
actualInstance, creationalContext);
+ T proxy = (T)
webBeansContext.getJavassistProxyFactory().createDependentScopedBeanProxy(this.delegateBean,
actualInstance, creationalContext);
return proxy;
}
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1043271&r1=1043270&r2=1043271&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
Wed Dec 8 01:30:48 2010
@@ -63,7 +63,8 @@ public abstract class AbstractLifeCycle
/**Root container.*/
private final BeanManagerImpl beanManager;
-
+ private final WebBeansContext webBeansContext;
+
protected AbstractLifeCycle()
{
this(null);
@@ -73,7 +74,8 @@ public abstract class AbstractLifeCycle
{
beforeInitApplication(properties);
- this.beanManager = WebBeansContext.getInstance().getBeanManagerImpl();
+ webBeansContext = WebBeansContext.getInstance();
+ this.beanManager = webBeansContext.getBeanManagerImpl();
this.xmlDeployer = new WebBeansXMLConfigurator();
this.deployer = new BeansDeployer(xmlDeployer);
this.jndiService = ServiceLoader.getService(JNDIService.class);
@@ -102,7 +104,7 @@ public abstract class AbstractLifeCycle
beforeStartApplication(startupObject);
//Load all plugins
- WebBeansContext.getInstance().getPluginLoader().startUp();
+ webBeansContext.getPluginLoader().startUp();
//Initialize contexts
this.contextsService.init(startupObject);
@@ -148,22 +150,22 @@ public abstract class AbstractLifeCycle
jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
//Free all plugin resources
- WebBeansContext.getInstance().getPluginLoader().shutDown();
+ webBeansContext.getPluginLoader().shutDown();
//Clear extensions
- WebBeansContext.getInstance().getExtensionLoader().clear();
+ webBeansContext.getExtensionLoader().clear();
//Delete Resolutions Cache
InjectionResolver.getInstance().clearCaches();
//Delte proxies
- WebBeansContext.getInstance().getJavassistProxyFactory().clear();
+ webBeansContext.getJavassistProxyFactory().clear();
//Delete AnnotateTypeCache
- WebBeansContext.getInstance().getAnnotatedElementFactory().clear();
+ webBeansContext.getAnnotatedElementFactory().clear();
//Delete JMS Model Cache
- WebBeansContext.getInstance().getjMSManager().clear();
+ webBeansContext.getjMSManager().clear();
//After Stop
afterStopApplication(endObject);