Author: gavin.king(a)jboss.com
Date: 2008-12-06 17:40:10 -0500 (Sat, 06 Dec 2008)
New Revision: 427
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
Log:
move the statics somewhere else
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-06
22:24:18 UTC (rev 426)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -48,11 +48,8 @@
import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.bean.proxy.ProxyPool;
-import org.jboss.webbeans.contexts.ApplicationContext;
import org.jboss.webbeans.contexts.ContextMap;
import org.jboss.webbeans.contexts.DependentContext;
-import org.jboss.webbeans.contexts.RequestContext;
-import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.ejb.DefaultEnterpriseBeanLookup;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.exceptions.NameResolutionLocation;
@@ -74,19 +71,7 @@
public class ManagerImpl implements Manager
{
public static final String JNDI_KEY = "java:comp/Manager";
-
- protected static ManagerImpl rootManager = new ManagerImpl();
- static {
- rootManager.addContext(RequestContext.INSTANCE);
- rootManager.addContext(SessionContext.INSTANCE);
- rootManager.addContext(ApplicationContext.INSTANCE);
- }
-
- public static ManagerImpl rootManager()
- {
- return rootManager;
- }
-
+
private List<Class<? extends Annotation>> enabledDeploymentTypes;
private MetaDataCache metaDataCache;
private EventManager eventManager;
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -25,7 +25,7 @@
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Context;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.util.Reflections;
/**
@@ -72,9 +72,9 @@
//TODO: account for child managers
if (bean == null)
{
- bean = ManagerImpl.rootManager().getBeans().get(beanIndex);
+ bean = CurrentManager.rootManager().getBeans().get(beanIndex);
}
- Context context = ManagerImpl.rootManager().getContext(bean.getScopeType());
+ Context context = CurrentManager.rootManager().getContext(bean.getScopeType());
Object proxiedInstance = context.get(bean, true);
Method proxiedMethod = Reflections.lookupMethod(method, proxiedInstance);
return proxiedMethod.invoke(proxiedInstance, args);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -29,7 +29,7 @@
import javax.webbeans.DefinitionException;
import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.util.ConcurrentCache;
/**
@@ -151,7 +151,7 @@
public T call() throws Exception
{
- int beanIndex = ManagerImpl.rootManager().getBeans().indexOf(bean);
+ int beanIndex = CurrentManager.rootManager().getBeans().indexOf(bean);
if (beanIndex < 0)
{
throw new DefinitionException(bean + " is not known to the
manager");
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -26,6 +26,7 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.AbstractClassBean;
@@ -58,7 +59,7 @@
*/
public Bootstrap()
{
- JNDI.set(ManagerImpl.JNDI_KEY, ManagerImpl.rootManager());
+ JNDI.set(ManagerImpl.JNDI_KEY, CurrentManager.rootManager());
}
/**
@@ -81,7 +82,7 @@
public void registerBeans(Iterable<Class<?>> classes)
{
Set<AbstractBean<?, ?>> beans = createBeans(classes);
- ManagerImpl.rootManager().setBeans(beans);
+ CurrentManager.rootManager().setBeans(beans);
}
/**
@@ -114,7 +115,7 @@
for (Class<?> clazz : classes)
{
AbstractClassBean<?> bean;
- if (ManagerImpl.rootManager().getMetaDataCache().getEjbMetaData(clazz).isEjb())
+ if
(CurrentManager.rootManager().getMetaDataCache().getEjbMetaData(clazz).isEjb())
{
bean = createEnterpriseBean(clazz);
}
@@ -123,18 +124,18 @@
bean = createSimpleBean(clazz);
}
beans.add(bean);
-
ManagerImpl.rootManager().getResolver().addInjectionPoints(bean.getInjectionPoints());
+
CurrentManager.rootManager().getResolver().addInjectionPoints(bean.getInjectionPoints());
for (AnnotatedMethod<Object> producerMethod : bean.getProducerMethods())
{
ProducerMethodBean<?> producerMethodBean =
createProducerMethodBean(producerMethod, bean);
beans.add(producerMethodBean);
-
ManagerImpl.rootManager().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
+
CurrentManager.rootManager().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
}
for (AnnotatedField<Object> eventField : bean.getEventFields())
{
EventBean<?> eventBean = createEventBean(eventField);
beans.add(eventBean);
-
ManagerImpl.rootManager().getResolver().addInjectionPoints(eventBean.getInjectionPoints());
+
CurrentManager.rootManager().getResolver().addInjectionPoints(eventBean.getInjectionPoints());
}
log.info("Web Bean: " + bean);
}
@@ -159,7 +160,7 @@
}
registerBeans(webBeanDiscovery.discoverWebBeanClasses());
log.info("Validing Web Bean injection points");
- ManagerImpl.rootManager().getResolver().resolveInjectionPoints();
+ CurrentManager.rootManager().getResolver().resolveInjectionPoints();
}
/**
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -19,7 +19,7 @@
import javax.webbeans.manager.Contextual;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
public abstract class AbstractBeanMapAdaptor implements BeanMap
{
@@ -40,7 +40,7 @@
*/
protected String getBeanKey(Contextual<?> bean)
{
- return getKeyPrefix() + "#" +
ManagerImpl.rootManager().getBeans().indexOf(bean);
+ return getKeyPrefix() + "#" +
CurrentManager.rootManager().getBeans().indexOf(bean);
}
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -25,7 +25,7 @@
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Contextual;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -90,7 +90,7 @@
*/
private String getBeanKey(Contextual<?> bean)
{
- return keyPrefix + ManagerImpl.rootManager().getBeans().indexOf(bean);
+ return keyPrefix + CurrentManager.rootManager().getBeans().indexOf(bean);
}
/**
@@ -185,7 +185,7 @@
if (name.startsWith(keyPrefix))
{
String id = name.substring(keyPrefix.length());
- Contextual<?> bean =
ManagerImpl.rootManager().getBeans().get(Integer.parseInt(id));
+ Contextual<?> bean =
CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
beans.add(bean);
}
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -23,7 +23,7 @@
import javax.el.ELContext;
import javax.el.ELResolver;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
public class WebBeansELResolver extends ELResolver
{
@@ -63,7 +63,7 @@
{
if (base == null && property != null)
{
- return ManagerImpl.rootManager().getInstanceByName(property.toString());
+ return CurrentManager.rootManager().getInstanceByName(property.toString());
}
else
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -13,7 +13,7 @@
import javax.servlet.ServletContext;
import javax.webbeans.manager.Contextual;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.contexts.AbstractBeanMapAdaptor;
import org.jboss.webbeans.contexts.ApplicationContext;
import org.jboss.webbeans.log.LogProvider;
@@ -85,7 +85,7 @@
if (name.startsWith(getKeyPrefix()))
{
String id = name.substring(getKeyPrefix().length());
- Contextual<?> bean =
ManagerImpl.rootManager().getBeans().get(Integer.parseInt(id));
+ Contextual<?> bean =
CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
beans.add(bean);
}
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -25,7 +25,7 @@
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Contextual;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.contexts.AbstractBeanMapAdaptor;
import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.log.LogProvider;
@@ -145,7 +145,7 @@
if (name.startsWith(getKeyPrefix()))
{
String id = name.substring(getKeyPrefix().length());
- Contextual<?> bean =
ManagerImpl.rootManager().getBeans().get(Integer.parseInt(id));
+ Contextual<?> bean =
CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
beans.add(bean);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-06
22:24:18 UTC (rev 426)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -19,7 +19,7 @@
import java.lang.reflect.Method;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.EventBean;
@@ -46,7 +46,7 @@
*/
public static <T> SimpleBean<T> createSimpleBean(Class<T> clazz)
{
- return new SimpleBean<T>(clazz, ManagerImpl.rootManager());
+ return new SimpleBean<T>(clazz, CurrentManager.rootManager());
}
/**
@@ -58,7 +58,7 @@
*/
public static <T> XmlSimpleBean<T> createXmlSimpleBean(Class<T>
clazz)
{
- return new XmlSimpleBean<T>(clazz, ManagerImpl.rootManager());
+ return new XmlSimpleBean<T>(clazz, CurrentManager.rootManager());
}
/**
@@ -70,7 +70,7 @@
*/
public static <T> EnterpriseBean<T> createEnterpriseBean(Class<T>
clazz)
{
- return new EnterpriseBean<T>(clazz, ManagerImpl.rootManager());
+ return new EnterpriseBean<T>(clazz, CurrentManager.rootManager());
}
/**
@@ -82,7 +82,7 @@
*/
public static <T> XmlEnterpriseBean<T>
createXmlEnterpriseBean(Class<T> clazz)
{
- return new XmlEnterpriseBean<T>(clazz, ManagerImpl.rootManager());
+ return new XmlEnterpriseBean<T>(clazz, CurrentManager.rootManager());
}
/**
@@ -96,7 +96,7 @@
*/
public static <T> ProducerMethodBean<T>
createProducerMethodBean(Class<T> type, Method method, AbstractClassBean<?>
declaringBean)
{
- return new ProducerMethodBean<T>(method, declaringBean,
ManagerImpl.rootManager());
+ return new ProducerMethodBean<T>(method, declaringBean,
CurrentManager.rootManager());
}
/**
@@ -108,7 +108,7 @@
*/
public static <T> ProducerMethodBean<T>
createProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?>
declaringBean)
{
- return new ProducerMethodBean<T>(method, declaringBean,
ManagerImpl.rootManager());
+ return new ProducerMethodBean<T>(method, declaringBean,
CurrentManager.rootManager());
}
/**
@@ -120,7 +120,7 @@
*/
public static <T> EventBean<T> createEventBean(AnnotatedField<T>
field)
{
- return new EventBean<T>(field, ManagerImpl.rootManager());
+ return new EventBean<T>(field, CurrentManager.rootManager());
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -3,9 +3,9 @@
import javax.webbeans.Production;
import javax.webbeans.Standard;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bootstrap.Bootstrap;
import org.jboss.webbeans.contexts.ApplicationContext;
-import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.contexts.RequestContext;
import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.contexts.SimpleBeanMap;
@@ -28,7 +28,7 @@
manager.addContext(RequestContext.INSTANCE);
manager.addContext(SessionContext.INSTANCE);
manager.addContext(ApplicationContext.INSTANCE);
- MockManagerImpl.setInstance(manager);
+ CurrentManager.setRootManager(manager);
// Mock the ApplicationContext as a simple map
ApplicationContext.INSTANCE.setBeanMap(new SimpleBeanMap());
bootstrap = new MockBootstrap();
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-12-06
22:24:18 UTC (rev 426)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -1,16 +1,13 @@
package org.jboss.webbeans.test;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
import javax.webbeans.DuplicateBindingTypeException;
import javax.webbeans.Event;
import javax.webbeans.Observer;
-import javax.webbeans.Standard;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.event.EventImpl;
-import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
import org.jboss.webbeans.test.annotations.Synchronous;
import org.jboss.webbeans.test.annotations.Tame;
import org.jboss.webbeans.test.beans.DangerCall;
@@ -52,12 +49,8 @@
@BeforeMethod
public void before() throws Exception
{
- List<Class<? extends Annotation>> enabledDeploymentTypes = new
ArrayList<Class<? extends Annotation>>();
- enabledDeploymentTypes.add(Standard.class);
- enabledDeploymentTypes.add(AnotherDeploymentType.class);
manager = new MockManagerImpl();
- MockManagerImpl.setInstance(manager);
- manager.setEnabledDeploymentTypes(Standard.class, AnotherDeploymentType.class);
+ CurrentManager.setRootManager(manager);
}
/**
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -6,6 +6,7 @@
import javax.webbeans.Observer;
import javax.webbeans.Observes;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -56,6 +57,7 @@
public void before() throws Exception
{
manager = new MockManagerImpl();
+ CurrentManager.setRootManager(manager);
ob = BeanFactory.createSimpleBean(SampleObserver.class);
manager.addBean(ob);
Method method = SampleObserver.class.getMethod("observe",
SampleEvent.class);
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-12-06
22:24:18 UTC (rev 426)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-12-06
22:40:10 UTC (rev 427)
@@ -6,7 +6,6 @@
import java.util.Set;
import javax.webbeans.Observer;
-import javax.webbeans.manager.Context;
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
@@ -66,9 +65,4 @@
initEnabledDeploymentTypes(enabledDeploymentTypes);
}
- public static void setInstance(ManagerImpl manager)
- {
- ManagerImpl.rootManager = manager;
- }
-
}