Author: pete.muir(a)jboss.org
Date: 2009-03-31 19:29:11 -0400 (Tue, 31 Mar 2009)
New Revision: 2289
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java
Log:
convert MetaDataCache to a manager service
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-31 23:28:02
UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-31 23:29:11
UTC (rev 2289)
@@ -116,7 +116,7 @@
throw new AmbiguousDependencyException("The injection point " +
injectionPoint + " with binding types " +
Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + "
has ambiguous dependencies");
}
Bean<?> resolvedBean = (Bean<?>)
resolvedBeans.iterator().next();
- if
(MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() &&
!Proxies.isTypeProxyable(injectionPoint.getType()))
+ if
(manager.getServices().get(MetaDataCache.class).getScopeModel(resolvedBean.getScopeType()).isNormal()
&& !Proxies.isTypeProxyable(injectionPoint.getType()))
{
throw new UnproxyableDependencyException("The injection point "
+ injectionPoint + " has non-proxyable dependencies");
}
@@ -124,7 +124,7 @@
{
throw new NullableDependencyException("The injection point " +
injectionPoint + " has nullable dependencies");
}
- if (Beans.isPassivatingBean(bean) && !resolvedBean.isSerializable()
&& resolvedBean.getScopeType().equals(Dependent.class))
+ if (Beans.isPassivatingBean(bean, manager) &&
!resolvedBean.isSerializable() &&
resolvedBean.getScopeType().equals(Dependent.class))
{
throw new UnserializableDependencyException("The bean " + bean +
" declares a passivating scopes but has non-serializable dependencies");
}
@@ -145,7 +145,7 @@
specializedBeans.add(abstractBean.getSpecializedBean());
}
}
- boolean normalScoped =
MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal();
+ boolean normalScoped =
manager.getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
if (normalScoped && !Beans.isBeanProxyable(bean))
{
throw new UnproxyableDependencyException("Normal scoped bean " +
bean + " is not proxyable");
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-03-31 23:28:02 UTC
(rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-03-31 23:29:11 UTC
(rev 2289)
@@ -41,7 +41,7 @@
// The binding types the helper operates on
protected final Set<? extends Annotation> bindings;
// The Web Beans manager
- protected final Manager manager;
+ protected final RootManager manager;
// The type of the operation
protected final Class<T> type;
@@ -52,7 +52,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- protected FacadeImpl(Class<T> type, Manager manager, Set<? extends
Annotation> bindings)
+ protected FacadeImpl(Class<T> type, RootManager manager, Set<? extends
Annotation> bindings)
{
this.manager = manager;
this.type = type;
@@ -76,7 +76,7 @@
result.addAll(bindings);
for (Annotation newAnnotation : newBindings)
{
- if
(!MetaDataCache.instance().getBindingTypeModel(newAnnotation.annotationType()).isValid())
+ if
(!manager.getServices().get(MetaDataCache.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
{
throw new IllegalArgumentException(newAnnotation + " is not a binding
for " + this);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-03-31 23:28:02
UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-03-31 23:29:11
UTC (rev 2289)
@@ -47,7 +47,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- private InstanceImpl(Class<T> type, Manager manager, Set<Annotation>
bindings)
+ private InstanceImpl(Class<T> type, RootManager manager, Set<Annotation>
bindings)
{
super(type, manager, bindings);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-03-31 23:28:02
UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-03-31 23:29:11
UTC (rev 2289)
@@ -133,7 +133,7 @@
private transient final Set<Interceptor> interceptors;
// The EJB resolver provided by the container
- private transient final ServiceRegistry simpleServiceRegistry;
+ private transient final ServiceRegistry services;
private transient final EjbDescriptorCache ejbDescriptorCache;
@@ -148,7 +148,7 @@
*/
public RootManager(ServiceRegistry simpleServiceRegistry)
{
- this.simpleServiceRegistry = simpleServiceRegistry;
+ this.services = simpleServiceRegistry;
this.beans = new CopyOnWriteArrayList<Bean<?>>();
this.newEnterpriseBeanMap = new ConcurrentHashMap<Class<?>,
EnterpriseBean<?>>();
this.riBeans = new ConcurrentHashMap<String, RIBean<?>>();
@@ -157,7 +157,7 @@
this.decorators = new HashSet<Decorator>();
this.interceptors = new HashSet<Interceptor>();
this.contextMap = new ContextMap();
- this.eventManager = new EventManager();
+ this.eventManager = new EventManager(this);
this.ejbDescriptorCache = new EjbDescriptorCache();
this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
{
@@ -252,7 +252,7 @@
Class<?> clazz = event.getClass();
for (Annotation annotation : bindings)
{
- if
(!MetaDataCache.instance().getBindingTypeModel(annotation.annotationType()).isValid())
+ if
(!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
{
throw new IllegalArgumentException("Not a binding type " +
annotation);
}
@@ -361,7 +361,7 @@
{
for (Annotation annotation : element.getAnnotationsAsSet())
{
- if
(!MetaDataCache.instance().getBindingTypeModel(annotation.annotationType()).isValid())
+ if
(!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
{
throw new IllegalArgumentException("Not a binding type " +
annotation);
}
@@ -632,7 +632,7 @@
{
return getInstance((Bean<T>) specializedBeans.get(bean),
creationalContext);
}
- else if (MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal())
+ else if
(getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal())
{
if (creationalContext != null || (creationalContext == null &&
getContext(bean.getScopeType()).get(bean) != null))
{
@@ -778,7 +778,7 @@
throw new AmbiguousDependencyException(element + "Resolved multiple Web
Beans");
}
Bean<T> bean = beans.iterator().next();
- boolean normalScoped =
MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal();
+ boolean normalScoped =
getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
if (normalScoped && !Beans.isBeanProxyable(bean))
{
throw new UnproxyableDependencyException("Normal scoped bean " + bean
+ " is not proxyable");
@@ -915,7 +915,7 @@
public ServiceRegistry getServices()
{
- return simpleServiceRegistry;
+ return services;
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-03-31
23:28:02 UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -141,7 +141,7 @@
*/
public void initialize(BeanDeployerEnvironment environment)
{
- mergedStereotypes = new MergedStereotypes<T,
E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class));
+ mergedStereotypes = new MergedStereotypes<T,
E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
if (isSpecializing())
{
preSpecialize();
@@ -261,7 +261,7 @@
private boolean checkInjectionPointsAreSerializable()
{
- boolean passivating =
MetaDataCache.instance().getScopeModel(this.getScopeType()).isPassivating();
+ boolean passivating =
manager.getServices().get(MetaDataCache.class).getScopeModel(this.getScopeType()).isPassivating();
for (AnnotatedInjectionPoint<?, ?> injectionPoint : getInjectionPoints())
{
Annotation[] bindings =
injectionPoint.getMetaAnnotationsAsArray(BindingType.class);
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-03-31
23:28:02 UTC (rev 2288)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -197,7 +197,7 @@
{
throw new IllegalProductException("Cannot return null from a non-dependent
producer method");
}
- boolean passivating =
MetaDataCache.instance().getScopeModel(getScopeType()).isPassivating();
+ boolean passivating =
manager.getServices().get(MetaDataCache.class).getScopeModel(getScopeType()).isPassivating();
if (passivating && !Reflections.isSerializable(instance.getClass()))
{
throw new IllegalProductException("Producers cannot declare passivating
scope and return a non-serializable class");
@@ -207,7 +207,7 @@
{
return;
}
- if (isDependent() && Beans.isPassivatingBean(injectionPoint.getBean()))
+ if (isDependent() && Beans.isPassivatingBean(injectionPoint.getBean(),
manager))
{
if (injectionPoint.getMember() instanceof Field)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-31
23:28:02 UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -331,7 +331,7 @@
{
throw new DefinitionException("Simple bean " + type + " cannot be
a parameterized type");
}
- boolean passivating =
MetaDataCache.instance().getScopeModel(scopeType).isPassivating();
+ boolean passivating =
manager.getServices().get(MetaDataCache.class).getScopeModel(scopeType).isPassivating();
if (passivating && !_serializable)
{
throw new DefinitionException("Simple bean declaring a passivating scope
must have a serializable implementation class " + toString());
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-31
23:28:02 UTC (rev 2288)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -54,6 +54,7 @@
import org.jboss.webbeans.literal.InitializedLiteral;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.resources.DefaultNamingContext;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.NamingContext;
@@ -119,6 +120,7 @@
getServices().add(EJBApiAbstraction.class, new EJBApiAbstraction(resourceLoader));
getServices().add(JSFApiAbstraction.class, new JSFApiAbstraction(resourceLoader));
getServices().add(ServletApiAbstraction.class, new
ServletApiAbstraction(resourceLoader));
+ getServices().add(MetaDataCache.class, new MetaDataCache());
}
public RootManager getManager()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-03-31
23:28:02 UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -19,16 +19,13 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.Set;
import javax.event.Event;
-import javax.event.Fires;
import javax.event.Observer;
-import javax.inject.manager.Manager;
import org.jboss.webbeans.FacadeImpl;
+import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.util.Strings;
/**
@@ -44,10 +41,7 @@
private static final long serialVersionUID = 8130060821283091287L;
- @SuppressWarnings("unchecked")
- private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATIONS
= new HashSet<Class<? extends Annotation>>(Arrays.asList(Fires.class));
-
- public static <E> Event<E> of(Class<E> eventType, Manager manager,
Set<Annotation> bindings)
+ public static <E> Event<E> of(Class<E> eventType, RootManager
manager, Set<Annotation> bindings)
{
return new EventImpl<E>(eventType, manager, bindings);
}
@@ -60,7 +54,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- public EventImpl(Class<T> eventType, Manager manager, Set<Annotation>
bindings)
+ public EventImpl(Class<T> eventType, RootManager manager, Set<Annotation>
bindings)
{
super(eventType, manager, bindings);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-03-31
23:28:02 UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -28,6 +28,7 @@
import javax.event.Observer;
+import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
@@ -125,14 +126,16 @@
// The map of registered observers for a give
private final RegisteredObserversMap registeredObservers;
+ private final RootManager manager;
/**
* Initializes a new instance of the EventManager.
*/
- public EventManager()
+ public EventManager(RootManager manager)
{
registeredObservers = new RegisteredObserversMap();
+ this.manager = manager;
}
/**
@@ -144,7 +147,7 @@
*/
public <T> void addObserver(Observer<T> observer, Type eventType,
Annotation... bindings)
{
- EventObserver<T> eventObserver = new EventObserver<T>(observer,
eventType, bindings);
+ EventObserver<T> eventObserver = new EventObserver<T>(observer,
eventType, manager, bindings);
registeredObservers.put(eventType, eventObserver);
log.debug("Added observer " + observer + " observing event type
" + eventType);
}
@@ -213,7 +216,7 @@
public <T> void removeObserver(Observer<T> observer, Class<T>
eventType, Annotation... bindings)
{
List<EventObserver<?>> observers = registeredObservers.get(eventType);
- EventObserver<T> eventObserver = new EventObserver<T>(observer,
eventType, bindings);
+ EventObserver<T> eventObserver = new EventObserver<T>(observer,
eventType, manager, bindings);
observers.remove(eventObserver);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java 2009-03-31
23:28:02 UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -26,6 +26,7 @@
import javax.inject.Current;
import javax.inject.DuplicateBindingTypeException;
+import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
@@ -49,6 +50,7 @@
private final Type eventType;
private final List<Annotation> eventBindings;
private final Observer<T> observer;
+ private final RootManager manager;
/**
* Constructs a new wrapper for an observer.
@@ -57,11 +59,12 @@
* @param eventType The class of event being observed
* @param eventBindings The array of annotation event bindings, if any
*/
- public EventObserver(final Observer<T> observer, final Type eventType, final
Annotation... eventBindings)
+ public EventObserver(final Observer<T> observer, final Type eventType,
RootManager manager, final Annotation... eventBindings)
{
this.observer = observer;
this.eventType = eventType;
this.eventBindings = new ArrayList<Annotation>();
+ this.manager = manager;
checkEventBindings(eventBindings);
}
@@ -139,7 +142,7 @@
boolean found = false;
for (Annotation y : bindings)
{
- if
(MetaDataCache.instance().getBindingTypeModel(x.annotationType()).isEqual(x, y))
+ if
(manager.getServices().get(MetaDataCache.class).getBindingTypeModel(x.annotationType()).isEqual(x,
y))
{
found = true;
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java 2009-03-31
23:28:02 UTC (rev 2288)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -284,7 +284,7 @@
{
for (Annotation binding : element.getBindings())
{
- BindingTypeModel<?> bindingType =
MetaDataCache.instance().getBindingTypeModel(binding.annotationType());
+ BindingTypeModel<?> bindingType =
manager.getServices().get(MetaDataCache.class).getBindingTypeModel(binding.annotationType());
if (bindingType.getNonBindingTypes().size() > 0)
{
boolean matchFound = false;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-03-31
23:28:02 UTC (rev 2288)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -21,6 +21,7 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
/**
@@ -31,27 +32,30 @@
public class MergedStereotypes<T, E>
{
// The possible deployment types
- private AnnotationMap possibleDeploymentTypes;
+ private final AnnotationMap possibleDeploymentTypes;
// The possible scope types
- private Set<Annotation> possibleScopeTypes;
+ private final Set<Annotation> possibleScopeTypes;
// Is the bean name defaulted?
private boolean beanNameDefaulted;
// The required types
- private Set<Class<?>> requiredTypes;
+ private final Set<Class<?>> requiredTypes;
// The supported scopes
- private Set<Class<? extends Annotation>> supportedScopes;
+ private final Set<Class<? extends Annotation>> supportedScopes;
+ private final RootManager manager;
+
/**
* Constructor
*
* @param stereotypeAnnotations The stereotypes to merge
*/
- public MergedStereotypes(Set<Annotation> stereotypeAnnotations)
+ public MergedStereotypes(Set<Annotation> stereotypeAnnotations, RootManager
manager)
{
- possibleDeploymentTypes = new AnnotationMap();
- possibleScopeTypes = new HashSet<Annotation>();
- requiredTypes = new HashSet<Class<?>>();
- supportedScopes = new HashSet<Class<? extends Annotation>>();
+ this.possibleDeploymentTypes = new AnnotationMap();
+ this.possibleScopeTypes = new HashSet<Annotation>();
+ this.requiredTypes = new HashSet<Class<?>>();
+ this.supportedScopes = new HashSet<Class<? extends Annotation>>();
+ this.manager = manager;
merge(stereotypeAnnotations);
}
@@ -65,7 +69,7 @@
for (Annotation stereotypeAnnotation : stereotypeAnnotations)
{
// Retrieve and merge all metadata from stereotypes
- StereotypeModel<?> stereotype =
MetaDataCache.instance().getStereotype(stereotypeAnnotation.annotationType());
+ StereotypeModel<?> stereotype =
manager.getServices().get(MetaDataCache.class).getStereotype(stereotypeAnnotation.annotationType());
if (stereotype == null)
{
throw new IllegalStateException("Stereotype " +
stereotypeAnnotation + " not registered with container");
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-03-31
23:28:02 UTC (rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -20,6 +20,7 @@
import java.lang.annotation.Annotation;
import java.util.concurrent.Callable;
+import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.util.collections.ConcurrentCache;
/**
@@ -28,26 +29,9 @@
* @author Pete Muir
*
*/
-public class MetaDataCache
+public class MetaDataCache implements Service
{
- // The singleton instance
- private static MetaDataCache instance;
- /**
- * Gets the singleton
- *
- * @return The instance
- */
- public static MetaDataCache instance()
- {
- return instance;
- }
-
- static
- {
- instance = new MetaDataCache();
- }
-
// The stereotype models
private ConcurrentCache<Class<? extends Annotation>,
StereotypeModel<?>> stereotypes = new ConcurrentCache<Class<? extends
Annotation>, StereotypeModel<?>>();
// The scope models
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-03-31 23:28:02 UTC
(rev 2288)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-03-31 23:29:11 UTC
(rev 2289)
@@ -24,6 +24,7 @@
import javax.inject.Produces;
import javax.inject.manager.Bean;
+import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.injection.FieldInjectionPoint;
@@ -46,7 +47,7 @@
* @param bean The bean to inspect
* @return True if passivating, false otherwise
*/
- public static boolean isPassivatingBean(Bean<?> bean)
+ public static boolean isPassivatingBean(Bean<?> bean, RootManager manager)
{
if (bean instanceof EnterpriseBean)
{
@@ -54,7 +55,7 @@
}
else
{
- return
MetaDataCache.instance().getScopeModel(bean.getScopeType()).isPassivating();
+ return
manager.getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isPassivating();
}
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java 2009-03-31
23:28:02 UTC (rev 2288)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/context/PassivatingContextTest.java 2009-03-31
23:29:11 UTC (rev 2289)
@@ -20,7 +20,7 @@
@Test(groups = { "contexts", "passivation" })
public void testIsSessionScopePassivating()
{
- assert
MetaDataCache.instance().getScopeModel(SessionScoped.class).isPassivating();
+ assert
manager.getServices().get(MetaDataCache.class).getScopeModel(SessionScoped.class).isPassivating();
}
/**
@@ -30,7 +30,7 @@
@Test(groups = { "contexts", "passivation" })
public void testIsConversationScopePassivating()
{
- assert
MetaDataCache.instance().getScopeModel(ConversationScoped.class).isPassivating();
+ assert
manager.getServices().get(MetaDataCache.class).getScopeModel(ConversationScoped.class).isPassivating();
}
/**
@@ -40,7 +40,7 @@
@Test(groups = { "contexts", "passivation" })
public void testIsApplicationScopeNonPassivating()
{
- assert
!MetaDataCache.instance().getScopeModel(ApplicationScoped.class).isPassivating();
+ assert
!manager.getServices().get(MetaDataCache.class).getScopeModel(ApplicationScoped.class).isPassivating();
}
/**
@@ -50,7 +50,7 @@
@Test(groups = { "contexts", "passivation" })
public void testIsRequestScopeNonPassivating()
{
- assert
!MetaDataCache.instance().getScopeModel(RequestScoped.class).isPassivating();
+ assert
!manager.getServices().get(MetaDataCache.class).getScopeModel(RequestScoped.class).isPassivating();
}
}