[webbeans-commits] Webbeans SVN: r433 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/bindings and 7 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-12-07 09:32:47 -0500 (Sun, 07 Dec 2008)
New Revision: 433
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/InitializedBinding.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/beans/InitializedObserver.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesApplicationContext.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesRequestContext.java
Removed:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InitializationTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.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/BoostrapTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/LadybirdSpider.java
Log:
Use all api types when looking for observers, support for discovering observer methods at bootstrap, initialized event
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -118,6 +118,11 @@
{
return getAnnotatedItem().getAnnotatedFields(Observable.class);
}
+
+ public Set<AnnotatedMethod<Object>> getObserverMethods()
+ {
+ return getAnnotatedItem().getMethodsWithAnnotatedParameters(Observes.class);
+ }
/**
* Initializes the injection points
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/InitializedBinding.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/InitializedBinding.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/InitializedBinding.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.AnnotationLiteral;
+import javax.webbeans.manager.Initialized;
+
+public class InitializedBinding extends AnnotationLiteral<Initialized> implements Initialized
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/InitializedBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -19,13 +19,19 @@
import static org.jboss.webbeans.util.BeanFactory.createEnterpriseBean;
import static org.jboss.webbeans.util.BeanFactory.createEventBean;
+import static org.jboss.webbeans.util.BeanFactory.createObserver;
import static org.jboss.webbeans.util.BeanFactory.createProducerMethodBean;
import static org.jboss.webbeans.util.BeanFactory.createSimpleBean;
+import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import javax.webbeans.DefinitionException;
+import javax.webbeans.Observer;
+import javax.webbeans.Observes;
+
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.MetaDataCache;
@@ -33,7 +39,9 @@
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EventBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bindings.InitializedBinding;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.log.LogProvider;
@@ -131,13 +139,28 @@
ProducerMethodBean<?> producerMethodBean = createProducerMethodBean(producerMethod, bean);
beans.add(producerMethodBean);
CurrentManager.rootManager().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
+ log.info("Web Bean: " + producerMethodBean);
}
for (AnnotatedField<Object> eventField : bean.getEventFields())
{
EventBean<?> eventBean = createEventBean(eventField);
beans.add(eventBean);
CurrentManager.rootManager().getResolver().addInjectionPoints(eventBean.getInjectionPoints());
+ log.info("Web Bean: " + eventBean);
}
+ for (AnnotatedMethod<Object> observerMethod : bean.getObserverMethods())
+ {
+ ObserverImpl<?> observer = createObserver(observerMethod, bean);
+ if (observerMethod.getAnnotatedParameters(Observes.class).size() == 1)
+ {
+ registerObserver(observer, observerMethod.getAnnotatedParameters(Observes.class).get(0).getType(), observerMethod.getAnnotatedParameters(Observes.class).get(0).getBindingTypesAsArray());
+ }
+ else
+ {
+ throw new DefinitionException("Observer method can only have one parameter annotated @Observes " + observer);
+ }
+
+ }
log.info("Web Bean: " + bean);
}
return beans;
@@ -162,6 +185,8 @@
registerBeans(webBeanDiscovery.discoverWebBeanClasses());
log.info("Validing Web Bean injection points");
CurrentManager.rootManager().getResolver().resolveInjectionPoints();
+ CurrentManager.rootManager().fireEvent(CurrentManager.rootManager(), new InitializedBinding());
+ log.info("Web Beans RI initialized");
}
/**
@@ -205,5 +230,11 @@
}
return webBeanDiscoveryClasses;
}
+
+ @SuppressWarnings("unchecked")
+ private static <T> void registerObserver(Observer<T> observer, Class<?> eventType, Annotation[] bindings)
+ {
+ CurrentManager.rootManager().addObserver(observer, (Class<T>) eventType, bindings);
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -33,6 +33,7 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.transaction.TransactionListener;
import org.jboss.webbeans.util.JNDI;
+import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -176,11 +177,14 @@
public <T> Set<Observer<T>> getObservers(T event, Annotation... bindings)
{
Set<Observer<T>> interestedObservers = new HashSet<Observer<T>>();
- for (EventObserver<?> observer : registeredObservers.get(event.getClass()))
+ for (Class<?> clazz : Reflections.getTypeHierachy(event.getClass()))
{
- if (observer.isObserverInterested(bindings))
+ for (EventObserver<?> observer : registeredObservers.get(clazz))
{
- interestedObservers.add((Observer<T>) observer.getObserver());
+ if (observer.isObserverInterested(bindings))
+ {
+ interestedObservers.add((Observer<T>) observer.getObserver());
+ }
}
}
return interestedObservers;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -24,6 +24,7 @@
import javax.webbeans.Observer;
import org.jboss.webbeans.MetaDataCache;
+import org.jboss.webbeans.util.Strings;
/**
* <p>
@@ -183,5 +184,16 @@
}
return true;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Event Observer:\n");
+ buffer.append(" Event Type: " + eventType.getName() +"\n");
+ buffer.append(Strings.collectionToString(" Event Bindings: ", eventBindings));
+ buffer.append(" Observer: " + observer);
+ return buffer.toString();
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -55,11 +55,11 @@
{
private Bean<?> observerBean;
private final AnnotatedMethod<Object> observerMethod;
- private final Class<T> eventType;
private TransactionObservationPhase transactionObservationPhase;
private boolean conditional;
private ManagerImpl manager;
+
/**
* Creates an Observer which describes and encapsulates an observer method
* (7.5).
@@ -72,12 +72,11 @@
* @param observer The observer method to notify
* @param eventType The type of event being observed
*/
- public ObserverImpl(final ManagerImpl manager, final Bean<?> observerBean, final AnnotatedMethod<Object> observer, final Class<T> eventType)
+ public ObserverImpl(final AnnotatedMethod<Object> observer, final Bean<?> observerBean, final ManagerImpl manager)
{
this.manager = manager;
this.observerBean = observerBean;
this.observerMethod = observer;
- this.eventType = eventType;
initTransactionObservationPhase();
conditional = !observerMethod.getAnnotatedParameters(IfExists.class).isEmpty();
}
@@ -115,11 +114,6 @@
}
}
- public Class<T> getEventType()
- {
- return eventType;
- }
-
public void notify(final T event)
{
// Get the most specialized instance of the component
@@ -176,5 +170,15 @@
{
return transactionObservationPhase.equals(currentPhase);
}
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Observer Implentation: \n");
+ builder.append(" Observer (Declaring) bean: " + observerBean);
+ builder.append(" Observer method: " + observerMethod);
+ return builder.toString();
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -81,13 +81,22 @@
public AnnotatedConstructor<T> getConstructor(List<Class<?>> arguments);
/**
- * Gets all members annotated with annotationType
+ * Gets all methods annotated with annotationType
*
* @param annotationType The annotation to match
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
public Set<AnnotatedMethod<Object>> getAnnotatedMethods(Class<? extends Annotation> annotationType);
+
+ /**
+ * Gets all with parameters annotated with annotationType
+ *
+ * @param annotationType The annotation to match
+ * @return A set of abstracted methods with the given annotation. Returns an
+ * empty set if there are no matches
+ */
+ public Set<AnnotatedMethod<Object>> getMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType);
/**
* Gets the superclass
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -19,8 +19,15 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Set;
+import javax.webbeans.BindingType;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
/**
* AnnotatedItem provides a uniform access to the annotations on an annotated
* item defined either in Java or XML
@@ -30,6 +37,11 @@
*/
public interface AnnotatedItem<T, S>
{
+
+// The set of meta-annotations to map
+ @SuppressWarnings("unchecked")
+ public static final Set<Class<? extends Annotation>> MAPPED_METAANNOTATIONS = new HashSet<Class<? extends Annotation>>(Arrays.asList(BindingType.class, DeploymentType.class, Stereotype.class, ScopeType.class));
+
/**
* Gets all annotations on the item
*
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -19,8 +19,18 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import javax.webbeans.AfterTransactionCompletion;
+import javax.webbeans.AfterTransactionFailure;
+import javax.webbeans.AfterTransactionSuccess;
+import javax.webbeans.BeforeTransactionCompletion;
+import javax.webbeans.Disposes;
+import javax.webbeans.IfExists;
+import javax.webbeans.Observes;
import javax.webbeans.manager.Manager;
/**
@@ -32,6 +42,8 @@
*/
public interface AnnotatedMethod<T> extends AnnotatedItem<T, Method>
{
+
+ public static final Set<Class<? extends Annotation>> MAPPED_PARAMETER_ANNOTATIONS = new HashSet<Class<? extends Annotation>>(Arrays.asList(Disposes.class, Observes.class, IfExists.class, BeforeTransactionCompletion.class, AfterTransactionCompletion.class, AfterTransactionFailure.class, AfterTransactionSuccess.class));
/**
* Gets the abstracted parameters of the method
@@ -42,9 +54,9 @@
public List<AnnotatedParameter<Object>> getParameters();
/**
- * Gets the list of annotated parameters for a given meta annotation
+ * Gets the list of annotated parameters for a given annotation
*
- * @param metaAnnotationType The meta annotation to match
+ * @param metaAnnotationType The annotation to match
* @return A set of matching parameter abstractions. Returns an empty list if
* there are no matches.
*/
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -30,9 +30,6 @@
import java.util.Set;
import javax.webbeans.BindingType;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.ScopeType;
-import javax.webbeans.Stereotype;
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
@@ -162,10 +159,6 @@
// The set of default binding types
private static final Set<Annotation> DEFAULT_BINDING = new HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
- // The set of meta-annotations to map
- @SuppressWarnings("unchecked")
- private static final Set<Class<? extends Annotation>> MAPPED_METAANNOTATIONS = new HashSet<Class<? extends Annotation>>(Arrays.asList(BindingType.class, DeploymentType.class, Stereotype.class, ScopeType.class));
-
// Cached string representation
private String toString;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -137,6 +137,7 @@
}
methods.add(value);
}
+
}
/**
@@ -224,6 +225,8 @@
private final Set<AnnotatedMethod<Object>> methods;
// The map from annotation type to abstracted method with annotation
private final AnnotatedMethodMap annotatedMethods;
+ // The map from annotation type to method with a parameter with annotation
+ private final AnnotatedMethodMap methodsByAnnotatedParameters;
// The set of abstracted constructors
private final Set<AnnotatedConstructor<T>> constructors;
@@ -234,6 +237,7 @@
// Cached string representation
private String toString;
+
/**
* Constructor
@@ -309,6 +313,7 @@
this.methods = new HashSet<AnnotatedMethod<Object>>();
this.annotatedMethods = new AnnotatedMethodMap();
+ this.methodsByAnnotatedParameters = new AnnotatedMethodMap();
for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass())
{
for (Method method : clazz.getDeclaredMethods())
@@ -328,6 +333,13 @@
}
annotatedMethods.get(annotation.annotationType()).add(annotatedMethod);
}
+ for (Class<? extends Annotation> annotationType : AnnotatedMethod.MAPPED_PARAMETER_ANNOTATIONS)
+ {
+ if (annotatedMethod.getAnnotatedParameters(annotationType).size() > 0)
+ {
+ methodsByAnnotatedParameters.put(annotationType, annotatedMethod);
+ }
+ }
}
}
}
@@ -485,6 +497,11 @@
{
return constructorsByArgumentMap.get(arguments);
}
+
+ public Set<AnnotatedMethod<Object>> getMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
+ {
+ return methodsByAnnotatedParameters.get(annotationType);
+ }
/**
* Gets a string representation of the constructor
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -46,6 +46,7 @@
*/
public class AnnotatedMethodImpl<T> extends AbstractAnnotatedMember<T, Method> implements AnnotatedMethod<T>
{
+
// The actual type arguments
private final Type[] actualTypeArguments;
// The underlying method
@@ -101,7 +102,10 @@
this.parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotations())
{
- annotatedParameters.put(annotation.annotationType(), parameter);
+ if (MAPPED_PARAMETER_ANNOTATIONS.contains(annotation.annotationType()))
+ {
+ annotatedParameters.put(annotation.annotationType(), parameter);
+ }
}
}
else
@@ -109,10 +113,6 @@
Class<? extends Object> clazz = method.getParameterTypes()[i];
AnnotatedParameter<Object> parameter = new AnnotatedParameterImpl<Object>(new Annotation[0], (Class<Object>) clazz);
this.parameters.add(parameter);
- for (Annotation annotation : parameter.getAnnotations())
- {
- annotatedParameters.put(annotation.annotationType(), parameter);
- }
}
}
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-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -27,6 +27,7 @@
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.bean.XmlEnterpriseBean;
import org.jboss.webbeans.bean.XmlSimpleBean;
+import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -122,5 +123,10 @@
{
return new EventBean<T>(field, CurrentManager.rootManager());
}
+
+ public static <T> ObserverImpl<T> createObserver(AnnotatedMethod<Object> method, AbstractClassBean<?> declaringBean)
+ {
+ return new ObserverImpl<T>(method, declaringBean, CurrentManager.rootManager());
+ }
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BoostrapTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BoostrapTest.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BoostrapTest.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -14,6 +14,10 @@
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.ejb.DefaultEnterpriseBeanLookup;
import org.jboss.webbeans.test.beans.Elephant;
+import org.jboss.webbeans.test.beans.InitializedObserver;
+import org.jboss.webbeans.test.beans.InitializedObserverWhichUsesApplicationContext;
+import org.jboss.webbeans.test.beans.InitializedObserverWhichUsesRequestContext;
+import org.jboss.webbeans.test.beans.LadybirdSpider;
import org.jboss.webbeans.test.beans.Panther;
import org.jboss.webbeans.test.beans.Salmon;
import org.jboss.webbeans.test.beans.SeaBass;
@@ -218,4 +222,27 @@
assert classes.get(SeaBass.class) instanceof SimpleBean;
assert classes.get(Sole.class) instanceof SimpleBean;
}
+
+ @Test(groups="bootstrap")
+ public void testInitializedEvent()
+ {
+ assert !InitializedObserver.observered;
+
+ bootstrap.boot(new MockWebBeanDiscovery(new HashSet<Class<?>>(Arrays.asList(InitializedObserver.class)), null, null));
+
+ assert InitializedObserver.observered;
+ }
+
+ @Test(groups="bootstrap")
+ public void testRequestContextActiveDuringInitializtionEvent()
+ {
+ bootstrap.boot(new MockWebBeanDiscovery(new HashSet<Class<?>>(Arrays.asList(InitializedObserverWhichUsesRequestContext.class, Tuna.class)), null, null));
+ }
+
+ @Test(groups="bootstrap")
+ public void testApplicationContextActiveDuringInitializtionEvent()
+ {
+ bootstrap.boot(new MockWebBeanDiscovery(new HashSet<Class<?>>(Arrays.asList(InitializedObserverWhichUsesApplicationContext.class, LadybirdSpider.class)), null, null));
+ }
+
}
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InitializationTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InitializationTest.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InitializationTest.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -1,14 +0,0 @@
-package org.jboss.webbeans.test;
-
-import org.testng.annotations.Test;
-
-public class InitializationTest
-{
-
- @Test
- public void test()
- {
-
- }
-
-}
Deleted: 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-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -1,102 +0,0 @@
-package org.jboss.webbeans.test;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-import javax.webbeans.AnnotationLiteral;
-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;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
-import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
-import org.jboss.webbeans.test.annotations.Asynchronous;
-import org.jboss.webbeans.test.mock.MockManagerImpl;
-import org.jboss.webbeans.util.BeanFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the implementation of Observer.
- *
- * @author David Allen
- *
- */
-@SpecVersion("20081024-PDR")
-public class ObserverTest
-{
- private MockManagerImpl manager;
- //private SimpleBean<Tuna> tuna;
- private SimpleBean<SampleObserver> ob;
- private AnnotatedMethod<Object> om;
- Observer<SampleEvent> observer;
-
- private static boolean notified = false;
-
- public static class SampleEvent
- {
- // Simple class used for testing
- }
-
- public static class SampleObserver
- {
-
- public void observe(@Observes @Asynchronous SampleEvent e)
- {
- // An observer method
- notified = true;
- }
-
- }
-
- public static @interface Foo {}
-
- @BeforeMethod
- 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);
- om = new AnnotatedMethodImpl<Object>(method, new AnnotatedClassImpl<SampleObserver>(SampleObserver.class));
- observer = new ObserverImpl<SampleEvent>(manager, ob, om, SampleEvent.class);
- Annotation annotation = method.getParameterAnnotations()[0][1];
- manager.addObserver(observer, SampleEvent.class, annotation);
- notified = false;
- }
-
- /**
- * Test method for
- * {@link org.jboss.webbeans.event.ObserverImpl#notify(javax.webbeans.Container, java.lang.Object)}
- * .
- */
- @Test(groups = "observerMethod") @SpecAssertion(section={"7.5.7"})
- public final void testNotify() throws Exception
- {
- SampleEvent event = new SampleEvent();
- notified = false;
- observer.notify(event);
- assert notified == true;
- }
-
- @Test(groups = "observerMethod") @SpecAssertion(section={"7.5.7"})
- public final void testNotifyViaManager() throws Exception
- {
- notified = false;
- manager.fireEvent(new SampleEvent());
- assert notified == false;
- manager.fireEvent(new Object(), new AnnotationLiteral<Asynchronous>() {});
- assert notified == false;
- manager.fireEvent(new SampleEvent(), new AnnotationLiteral<Foo>() {});
- assert notified == false;
- manager.fireEvent(new SampleEvent(), new AnnotationLiteral<Asynchronous>() {});
- assert notified == true;
- notified = false;
- manager.fireEvent(new SampleEvent(), new AnnotationLiteral<Asynchronous>() {}, new AnnotationLiteral<Foo>() {});
- assert notified == true;
- }
-
-}
Added: 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 (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -0,0 +1,101 @@
+package org.jboss.webbeans.test;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import javax.webbeans.AnnotationLiteral;
+import javax.webbeans.Observer;
+import javax.webbeans.Observes;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
+import org.jboss.webbeans.test.annotations.Asynchronous;
+import org.jboss.webbeans.test.mock.MockManagerImpl;
+import org.jboss.webbeans.util.BeanFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for the implementation of Observer.
+ *
+ * @author David Allen
+ *
+ */
+@SpecVersion("20081024-PDR")
+public class ObserverTest
+{
+ private MockManagerImpl manager;
+ //private SimpleBean<Tuna> tuna;
+ private SimpleBean<SampleObserver> ob;
+ private AnnotatedMethod<Object> om;
+ Observer<SampleEvent> observer;
+
+ private static boolean notified = false;
+
+ public static class SampleEvent
+ {
+ // Simple class used for testing
+ }
+
+ public static class SampleObserver
+ {
+
+ public void observe(@Observes @Asynchronous SampleEvent e)
+ {
+ // An observer method
+ notified = true;
+ }
+
+ }
+
+ public static @interface Foo {}
+
+ @BeforeMethod
+ 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);
+ om = new AnnotatedMethodImpl<Object>(method, new AnnotatedClassImpl<SampleObserver>(SampleObserver.class));
+ observer = BeanFactory.createObserver( om, ob);
+ Annotation annotation = method.getParameterAnnotations()[0][1];
+ manager.addObserver(observer, SampleEvent.class, annotation);
+ notified = false;
+ }
+
+ /**
+ * Test method for
+ * {@link org.jboss.webbeans.event.ObserverImpl#notify(javax.webbeans.Container, java.lang.Object)}
+ * .
+ */
+ @Test(groups = "observerMethod") @SpecAssertion(section={"7.5.7"})
+ public final void testNotify() throws Exception
+ {
+ SampleEvent event = new SampleEvent();
+ notified = false;
+ observer.notify(event);
+ assert notified == true;
+ }
+
+ @Test(groups = "observerMethod") @SpecAssertion(section={"7.5.7"})
+ public final void testNotifyViaManager() throws Exception
+ {
+ notified = false;
+ manager.fireEvent(new SampleEvent());
+ assert notified == false;
+ manager.fireEvent(new Object(), new AnnotationLiteral<Asynchronous>() {});
+ assert notified == false;
+ manager.fireEvent(new SampleEvent(), new AnnotationLiteral<Foo>() {});
+ assert notified == false;
+ manager.fireEvent(new SampleEvent(), new AnnotationLiteral<Asynchronous>() {});
+ assert notified == true;
+ notified = false;
+ manager.fireEvent(new SampleEvent(), new AnnotationLiteral<Asynchronous>() {}, new AnnotationLiteral<Foo>() {});
+ assert notified == true;
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserver.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserver.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Observes;
+import javax.webbeans.manager.Initialized;
+import javax.webbeans.manager.Manager;
+
+public class InitializedObserver
+{
+
+ public static boolean observered;
+
+ public void observeInitialized(@Observes @Initialized Manager manager)
+ {
+ observered = true;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesApplicationContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesApplicationContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesApplicationContext.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+import javax.webbeans.Observes;
+import javax.webbeans.manager.Initialized;
+import javax.webbeans.manager.Manager;
+
+public class InitializedObserverWhichUsesApplicationContext
+{
+
+ @Current LadybirdSpider spider;
+
+ public void observeInitialized(@Observes @Initialized Manager manager)
+ {
+ spider.spinWeb();
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesApplicationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesRequestContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesRequestContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesRequestContext.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+import javax.webbeans.Observes;
+import javax.webbeans.manager.Initialized;
+import javax.webbeans.manager.Manager;
+
+public class InitializedObserverWhichUsesRequestContext
+{
+
+ @Current Tuna tuna;
+
+ public void observeInitialized(@Observes @Initialized Manager manager)
+ {
+ tuna.getName();
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/InitializedObserverWhichUsesRequestContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/LadybirdSpider.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/LadybirdSpider.java 2008-12-07 12:16:02 UTC (rev 432)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/LadybirdSpider.java 2008-12-07 14:32:47 UTC (rev 433)
@@ -6,4 +6,9 @@
public class LadybirdSpider extends Spider
{
+ public void spinWeb()
+ {
+
+ }
+
}
16 years
[webbeans-commits] Webbeans SVN: r432 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-12-07 07:16:02 -0500 (Sun, 07 Dec 2008)
New Revision: 432
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
Log:
ws
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-07 12:13:21 UTC (rev 431)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-07 12:16:02 UTC (rev 432)
@@ -102,15 +102,20 @@
{
//List<Annotation> bindingsArray = Arrays.asList(bindings);
//return bindingsArray.containsAll(this.eventBindings);
- for (Annotation x: eventBindings) {
+ for (Annotation x: eventBindings)
+ {
boolean found = false;
for (Annotation y: bindings)
{
- if ( MetaDataCache.instance().getBindingTypeModel(x.annotationType()).isEqual(x, y) ) {
- found = true;
+ if ( MetaDataCache.instance().getBindingTypeModel(x.annotationType()).isEqual(x, y) )
+ {
+ found = true;
+ }
}
+ if (!found)
+ {
+ return false;
}
- if (!found) return false;
}
return true;
}
16 years
[webbeans-commits] Webbeans SVN: r431 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/bean and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-12-07 07:13:21 -0500 (Sun, 07 Dec 2008)
New Revision: 431
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
Log:
Make metadatacache a static singleton
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-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -73,7 +73,6 @@
public static final String JNDI_KEY = "java:comp/Manager";
private List<Class<? extends Annotation>> enabledDeploymentTypes;
- private MetaDataCache metaDataCache;
private EventManager eventManager;
private Resolver resolver;
private ContextMap contextMap;
@@ -85,7 +84,6 @@
@SuppressWarnings("unchecked")
public ManagerImpl()
{
- this.metaDataCache = new MetaDataCache();
this.beans = new CopyOnWriteArrayList<Bean<?>>();
this.eventManager = new EventManager(this);
this.resolver = new Resolver(this);
@@ -191,18 +189,6 @@
}
/**
- * Returns the metadata cache
- *
- * @return The cache
- *
- * @see org.jboss.webbeans.MetaDataCache
- */
- public MetaDataCache getMetaDataCache()
- {
- return this.metaDataCache;
- }
-
- /**
* Resolves beans by API type and binding types
*
* @param type The API type to match
@@ -244,7 +230,7 @@
{
for (Annotation annotation : element.getAnnotations())
{
- if (!metaDataCache.getBindingTypeModel(annotation.annotationType()).isValid())
+ if (!MetaDataCache.instance().getBindingTypeModel(annotation.annotationType()).isValid())
{
throw new IllegalArgumentException("Not a binding type " + annotation);
}
@@ -446,7 +432,7 @@
try
{
contextMap.getBuiltInContext(Dependent.class).setActive(true);
- if (getMetaDataCache().getScopeModel(bean.getScopeType()).isNormal())
+ if (MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal())
{
return (T) proxyPool.getClientProxy(bean);
}
@@ -545,7 +531,7 @@
else
{
Bean<T> bean = beans.iterator().next();
- if (getMetaDataCache().getScopeModel(bean.getScopeType()).isNormal() && !element.isProxyable())
+ if (MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal() && !element.isProxyable())
{
throw new UnproxyableDependencyException(element + "Unable to proxy");
}
@@ -651,7 +637,7 @@
StringBuilder buffer = new StringBuilder();
buffer.append(Strings.collectionToString("Enabled deployment types: ", getEnabledDeploymentTypes()));
buffer.append(eventManager.toString() + "\n");
- buffer.append(metaDataCache.toString() + "\n");
+ buffer.append(MetaDataCache.instance().toString() + "\n");
buffer.append(resolver.toString() + "\n");
buffer.append(contextMap.toString() + "\n");
buffer.append(proxyPool.toString() + "\n");
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -30,6 +30,18 @@
public class MetaDataCache
{
+ private static MetaDataCache instance;
+
+ public static MetaDataCache instance()
+ {
+ return instance;
+ }
+
+ static
+ {
+ instance = new MetaDataCache();
+ }
+
private ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>> stereotypes = new ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>>();
private ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>> scopes = new ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>>();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -270,10 +270,9 @@
private boolean containsAllBindingBindingTypes(AnnotatedItem<?, ?> element, Set<Annotation> bindingTypes)
{
- MetaDataCache metaDataCache = manager.getMetaDataCache();
for (Annotation bindingType : element.getBindingTypes())
{
- BindingTypeModel<?> bindingTypeModel = metaDataCache.getBindingTypeModel(bindingType.annotationType());
+ BindingTypeModel<?> bindingTypeModel = MetaDataCache.instance().getBindingTypeModel(bindingType.annotationType());
if (bindingTypeModel.getNonBindingTypes().size() > 0)
{
boolean matchFound = false;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -121,7 +121,7 @@
*/
protected void init()
{
- mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager.getMetaDataCache());
+ mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class));
initType();
initPrimitive();
log.debug("Building Web Bean bean metadata for " + getType());
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -32,6 +32,7 @@
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.ejb.EJB;
import org.jboss.webbeans.ejb.EjbMetaData;
import org.jboss.webbeans.introspector.AnnotatedField;
@@ -71,7 +72,7 @@
protected void init()
{
super.init();
- ejbMetaData = manager.getMetaDataCache().getEjbMetaData(getType());
+ ejbMetaData = MetaDataCache.instance().getEjbMetaData(getType());
initRemoveMethod();
initInjectionPoints();
checkEnterpriseBeanTypeAllowed();
@@ -139,14 +140,14 @@
}
if (!isDefinedInXml())
{
- if (!manager.getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
+ if (!MetaDataCache.instance().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
{
throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
}
}
else
{
- if (manager.getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
+ if (MetaDataCache.instance().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
{
throw new DefinitionException("XML defined specializing EJB must have annotation defined EJB implementation");
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -49,13 +49,13 @@
*
* @param stereotypeAnnotations The stereotypes to merge
*/
- public MergedStereotypes(Set<Annotation> stereotypeAnnotations, MetaDataCache metaDataCache)
+ public MergedStereotypes(Set<Annotation> stereotypeAnnotations)
{
possibleDeploymentTypes = new AnnotationMap();
possibleScopeTypes = new HashSet<Annotation>();
requiredTypes = new HashSet<Class<?>>();
supportedScopes = new HashSet<Class<? extends Annotation>>();
- merge(stereotypeAnnotations, metaDataCache);
+ merge(stereotypeAnnotations);
}
/**
@@ -63,12 +63,12 @@
*
* @param stereotypeAnnotations The stereotype annotations
*/
- protected void merge(Set<Annotation> stereotypeAnnotations, MetaDataCache metaDataCache)
+ protected void merge(Set<Annotation> stereotypeAnnotations)
{
for (Annotation stereotypeAnnotation : stereotypeAnnotations)
{
// Retrieve and merge all metadata from stereotypes
- StereotypeModel<?> stereotype = metaDataCache.getStereotype(stereotypeAnnotation.annotationType());
+ StereotypeModel<?> stereotype = MetaDataCache.instance().getStereotype(stereotypeAnnotation.annotationType());
if (stereotype == null)
{
throw new IllegalStateException("Stereotype " + stereotypeAnnotation + " not registered with container");
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-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -28,6 +28,7 @@
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EventBean;
@@ -115,7 +116,7 @@
for (Class<?> clazz : classes)
{
AbstractClassBean<?> bean;
- if (CurrentManager.rootManager().getMetaDataCache().getEjbMetaData(clazz).isEjb())
+ if (MetaDataCache.instance().getEjbMetaData(clazz).isEjb())
{
bean = createEnterpriseBean(clazz);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -159,7 +159,7 @@
*/
public <T> void addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
{
- EventObserver<T> eventObserver = new EventObserver<T>(manager.getMetaDataCache(), observer, eventType, bindings);
+ EventObserver<T> eventObserver = new EventObserver<T>(observer, eventType, bindings);
registeredObservers.put(eventType, eventObserver);
}
@@ -252,7 +252,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>(manager.getMetaDataCache(), observer, eventType, bindings);
+ EventObserver<T> eventObserver = new EventObserver<T>(observer, eventType, bindings);
observers.remove(eventObserver);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -44,7 +44,6 @@
private final Class<T> eventType;
private final List<Annotation> eventBindings;
private final Observer<T> observer;
- private final MetaDataCache metaDataCache;
/**
* Constructs a new wrapper for an observer.
@@ -53,12 +52,11 @@
* @param eventType The class of event being observed
* @param eventBindings The array of annotation event bindings, if any
*/
- public EventObserver(MetaDataCache metaDataCache, final Observer<T> observer, final Class<T> eventType, final Annotation... eventBindings)
+ public EventObserver(final Observer<T> observer, final Class<T> eventType, final Annotation... eventBindings)
{
this.observer = observer;
this.eventType = eventType;
this.eventBindings = Arrays.asList(eventBindings);
- this.metaDataCache = metaDataCache;
}
/**
@@ -108,7 +106,7 @@
boolean found = false;
for (Annotation y: bindings)
{
- if ( metaDataCache.getBindingTypeModel(x.annotationType()).isEqual(x, y) ) {
+ if ( MetaDataCache.instance().getBindingTypeModel(x.annotationType()).isEqual(x, y) ) {
found = true;
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java 2008-12-07 12:07:38 UTC (rev 430)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java 2008-12-07 12:13:21 UTC (rev 431)
@@ -2,7 +2,6 @@
import javax.webbeans.Observer;
-import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.event.EventObserver;
import org.jboss.webbeans.test.beans.DangerCall;
import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
@@ -38,7 +37,7 @@
public void testIsObserverInterested()
{
Observer<DangerCall> observer = new AnObserver<DangerCall>();
- EventObserver<DangerCall> wrappedObserver = new EventObserver<DangerCall>(new MetaDataCache(), observer, DangerCall.class, new TameAnnotationLiteral());
+ EventObserver<DangerCall> wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new TameAnnotationLiteral());
assert wrappedObserver.getEventBindings().size() == 1;
assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral());
assert !wrappedObserver.isObserverInterested(new AnimalStereotypeAnnotationLiteral());
@@ -46,7 +45,7 @@
assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral(), new RoleBinding("Admin"));
// Perform some tests with binding values (7.7.1)
- wrappedObserver = new EventObserver<DangerCall>(new MetaDataCache(), observer, DangerCall.class, new RoleBinding("Admin"));
+ wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new RoleBinding("Admin"));
assert wrappedObserver.getEventBindings().size() == 1;
assert wrappedObserver.isObserverInterested(new RoleBinding("Admin"));
assert !wrappedObserver.isObserverInterested(new RoleBinding("User"));
16 years
[webbeans-commits] Webbeans SVN: r430 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-12-07 07:07:38 -0500 (Sun, 07 Dec 2008)
New Revision: 430
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java
Log:
WS
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java 2008-12-06 22:41:16 UTC (rev 429)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java 2008-12-07 12:07:38 UTC (rev 430)
@@ -4,7 +4,8 @@
import org.jboss.webbeans.contexts.RequestContext;
import org.jboss.webbeans.contexts.SessionContext;
-public class CurrentManager {
+public class CurrentManager
+{
protected static ManagerImpl rootManager;
@@ -13,7 +14,8 @@
return rootManager;
}
- public static void setRootManager(ManagerImpl rootManager) {
+ public static void setRootManager(ManagerImpl rootManager)
+ {
CurrentManager.rootManager = rootManager;
}
@@ -21,7 +23,8 @@
* Set up the root manager.
* TODO: move this to Bootstrap
*/
- static {
+ static
+ {
rootManager = new ManagerImpl();
rootManager.addContext(RequestContext.INSTANCE);
rootManager.addContext(SessionContext.INSTANCE);
16 years
[webbeans-commits] Webbeans SVN: r429 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-12-06 17:41:16 -0500 (Sat, 06 Dec 2008)
New Revision: 429
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java
Log:
oops
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java 2008-12-06 22:40:50 UTC (rev 428)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java 2008-12-06 22:41:16 UTC (rev 429)
@@ -6,7 +6,7 @@
public class CurrentManager {
- protected static ManagerImpl rootManager = new ManagerImpl();
+ protected static ManagerImpl rootManager;
public static ManagerImpl rootManager()
{
16 years
[webbeans-commits] Webbeans SVN: r428 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-12-06 17:40:50 -0500 (Sat, 06 Dec 2008)
New Revision: 428
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java
Log:
move the statics somewhere else
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/CurrentManager.java 2008-12-06 22:40:50 UTC (rev 428)
@@ -0,0 +1,31 @@
+package org.jboss.webbeans;
+
+import org.jboss.webbeans.contexts.ApplicationContext;
+import org.jboss.webbeans.contexts.RequestContext;
+import org.jboss.webbeans.contexts.SessionContext;
+
+public class CurrentManager {
+
+ protected static ManagerImpl rootManager = new ManagerImpl();
+
+ public static ManagerImpl rootManager()
+ {
+ return rootManager;
+ }
+
+ public static void setRootManager(ManagerImpl rootManager) {
+ CurrentManager.rootManager = rootManager;
+ }
+
+ /**
+ * Set up the root manager.
+ * TODO: move this to Bootstrap
+ */
+ static {
+ rootManager = new ManagerImpl();
+ rootManager.addContext(RequestContext.INSTANCE);
+ rootManager.addContext(SessionContext.INSTANCE);
+ rootManager.addContext(ApplicationContext.INSTANCE);
+ }
+
+}
16 years
[webbeans-commits] Webbeans SVN: r427 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/bean/proxy and 7 other directories.
by webbeans-commits@lists.jboss.org
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;
- }
-
}
16 years
[webbeans-commits] Webbeans SVN: r426 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/contexts and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-12-06 17:24:18 -0500 (Sat, 06 Dec 2008)
New Revision: 426
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.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/ManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
Log:
let the client set up contexts for a manager (very ugly use of inheritance there)
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 21:52:42 UTC (rev 425)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-06 22:24:18 UTC (rev 426)
@@ -76,6 +76,11 @@
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()
{
@@ -102,9 +107,10 @@
this.proxyPool = new ProxyPool();
this.decorators = new HashSet<Decorator>();
this.interceptors = new HashSet<Interceptor>();
+ this.contextMap = new ContextMap();
initEnabledDeploymentTypes();
- initContexts();
initStandardBeans();
+ addContext(new DependentContext());
}
/**
@@ -144,32 +150,6 @@
}
/**
- * Set up the contexts. By default, the built in contexts are set up, but a
- * mock ManagerImpl may override this method to allow tests to set up other
- * contexts
- *
- * @param contexts Non-built-in contexts to add
- */
- protected void initContexts(Context... contexts)
- {
- this.contextMap = new ContextMap();
- if (contexts.length == 0)
- {
- addContext(new DependentContext());
- addContext(RequestContext.INSTANCE);
- addContext(SessionContext.INSTANCE);
- addContext(ApplicationContext.INSTANCE);
- }
- else
- {
- for (Context context : contexts)
- {
- addContext(context);
- }
- }
- }
-
- /**
* Registers a bean with the manager
*
* @param bean The bean to register
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-12-06 21:52:42 UTC (rev 425)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-12-06 22:24:18 UTC (rev 426)
@@ -22,6 +22,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
import javax.webbeans.manager.Context;
@@ -53,7 +54,9 @@
{
try
{
- return (AbstractContext) getFuture(scopeType).get().iterator().next();
+ Future<List<Context>> future = getFuture(scopeType);
+ if (future==null) return null;
+ return (AbstractContext) future.get().iterator().next();
}
catch (InterruptedException e)
{
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 21:52:42 UTC (rev 425)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-12-06 22:24:18 UTC (rev 426)
@@ -5,6 +5,9 @@
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;
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
@@ -22,6 +25,9 @@
public final void before()
{
manager = new MockManagerImpl();
+ manager.addContext(RequestContext.INSTANCE);
+ manager.addContext(SessionContext.INSTANCE);
+ manager.addContext(ApplicationContext.INSTANCE);
MockManagerImpl.setInstance(manager);
// Mock the ApplicationContext as a simple map
ApplicationContext.INSTANCE.setBeanMap(new SimpleBeanMap());
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-12-06 21:52:42 UTC (rev 425)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-12-06 22:24:18 UTC (rev 426)
@@ -23,7 +23,7 @@
{
Context requestContext = new RequestContext() {};
((AbstractContext)requestContext).setActive(false);
- manager.setContexts(requestContext);
+ manager.addContext(requestContext);
manager.getContext(RequestScoped.class);
}
@@ -32,7 +32,8 @@
{
Context firstContext = new RequestContext() {};
Context secondContext = new RequestContext() {};
- manager.setContexts(firstContext, secondContext);
+ manager.addContext(firstContext);
+ manager.addContext(secondContext);
manager.getContext(RequestScoped.class);
assert true;
}
@@ -40,7 +41,6 @@
@Test(expectedExceptions={ContextNotActiveException.class}, groups={"stub", "manager"}) @SpecAssertion(section="8.6")
public void testGetContextWithNoRegisteredContextsFails()
{
- manager.setContexts();
manager.getContext(RequestScoped.class);
assert false;
}
@@ -49,7 +49,7 @@
public void testGetContextReturnsActiveContext()
{
Context requestContext = new RequestContext() {};
- manager.setContexts(requestContext);
+ manager.addContext(requestContext);
Context testContext = manager.getContext(RequestScoped.class);
assert testContext == requestContext;
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 21:52:42 UTC (rev 425)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-12-06 22:24:18 UTC (rev 426)
@@ -66,11 +66,6 @@
initEnabledDeploymentTypes(enabledDeploymentTypes);
}
- public void setContexts(Context ... contexts)
- {
- initContexts(contexts);
- }
-
public static void setInstance(ManagerImpl manager)
{
ManagerImpl.rootManager = manager;
16 years
[webbeans-commits] Webbeans SVN: r425 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/contexts and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-12-06 16:52:42 -0500 (Sat, 06 Dec 2008)
New Revision: 425
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.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/ManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NormalContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/PassivatingContextTest.java
Log:
make the contexts which are singletons really be singletons, instead of pretending they are not and then using singleton-ness of root manager to access them :)
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 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -156,9 +156,9 @@
if (contexts.length == 0)
{
addContext(new DependentContext());
- addContext(new RequestContext());
- addContext(new SessionContext());
- addContext(new ApplicationContext());
+ addContext(RequestContext.INSTANCE);
+ addContext(SessionContext.INSTANCE);
+ addContext(ApplicationContext.INSTANCE);
}
else
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -21,8 +21,6 @@
import javax.webbeans.ApplicationScoped;
-import org.jboss.webbeans.ManagerImpl;
-
/**
* The Application context
*
@@ -32,6 +30,9 @@
*/
public class ApplicationContext extends AbstractContext
{
+
+ public static ApplicationContext INSTANCE = new ApplicationContext();
+
// The beans
private BeanMap beanMap;
// Is the context active?
@@ -40,7 +41,7 @@
/**
* Constructor
*/
- public ApplicationContext()
+ protected ApplicationContext()
{
super(ApplicationScoped.class);
this.active = new AtomicBoolean(true);
@@ -68,16 +69,6 @@
}
/**
- * Helper method for accessing context
- *
- * @return The application context
- */
- public static ApplicationContext instance()
- {
- return (ApplicationContext) ManagerImpl.rootManager().getBuiltInContext(ApplicationScoped.class);
- }
-
- /**
* Indicates if the context is active
*
* @return True if active, false otherwise
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -19,8 +19,6 @@
import javax.webbeans.RequestScoped;
-import org.jboss.webbeans.ManagerImpl;
-
/**
* The request context
*
@@ -28,24 +26,15 @@
*/
public class RequestContext extends BasicContext
{
+
+ public static RequestContext INSTANCE = new RequestContext();
/**
* Constructor
*/
- public RequestContext()
+ protected RequestContext()
{
super(RequestScoped.class);
- }
-
- /**
- * Helper method for accessing context
- *
- * @return The request context
- */
- public static RequestContext instance()
- {
- return (RequestContext) ManagerImpl.rootManager().getBuiltInContext(RequestScoped.class);
- }
-
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -19,7 +19,6 @@
import javax.webbeans.SessionScoped;
-import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -31,13 +30,16 @@
public class SessionContext extends AbstractContext
{
private static LogProvider log = Logging.getLogProvider(SessionContext.class);
+
+ public static SessionContext INSTANCE = new SessionContext();
+
// The beans
private ThreadLocal<BeanMap> beanMap;
/**
* Constructor
*/
- public SessionContext()
+ protected SessionContext()
{
super(SessionScoped.class);
log.trace("Created session context");
@@ -65,14 +67,4 @@
this.beanMap.set(beanMap);
}
- /**
- * Helper method for accessing context
- *
- * @return The session context
- */
- public static SessionContext instance()
- {
- return (SessionContext) ManagerImpl.rootManager().getBuiltInContext(SessionScoped.class);
- }
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -57,7 +57,7 @@
servletContext = context;
Bootstrap bootstrap = new Bootstrap();
bootstrap.boot(getWebBeanDiscovery());
- ApplicationContext.instance().setBeanMap(new ApplicationBeanMap(servletContext));
+ ApplicationContext.INSTANCE.setBeanMap(new ApplicationBeanMap(servletContext));
}
/**
@@ -65,8 +65,8 @@
*/
public static void endApplication()
{
- ApplicationContext.instance().destroy();
- ApplicationContext.instance().setBeanMap(null);
+ ApplicationContext.INSTANCE.destroy();
+ ApplicationContext.INSTANCE.setBeanMap(null);
servletContext = null;
}
@@ -86,8 +86,8 @@
*/
public static void endSession(HttpSession session)
{
- SessionContext.instance().destroy();
- SessionContext.instance().setBeanMap(null);
+ SessionContext.INSTANCE.destroy();
+ SessionContext.INSTANCE.setBeanMap(null);
}
/**
@@ -99,7 +99,7 @@
*/
public static void beginRequest(HttpServletRequest request)
{
- SessionContext.instance().setBeanMap(new SessionBeanMap(request.getSession()));
+ SessionContext.INSTANCE.setBeanMap(new SessionBeanMap(request.getSession()));
}
/**
@@ -109,8 +109,8 @@
*/
public static void endRequest(HttpServletRequest request)
{
- RequestContext.instance().destroy();
- SessionContext.instance().setBeanMap(null);
+ RequestContext.INSTANCE.destroy();
+ SessionContext.INSTANCE.setBeanMap(null);
}
/**
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 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -17,7 +17,6 @@
protected MockManagerImpl manager;
protected Bootstrap bootstrap;
-
@BeforeMethod
public final void before()
@@ -25,7 +24,7 @@
manager = new MockManagerImpl();
MockManagerImpl.setInstance(manager);
// Mock the ApplicationContext as a simple map
- ApplicationContext.instance().setBeanMap(new SimpleBeanMap());
+ ApplicationContext.INSTANCE.setBeanMap(new SimpleBeanMap());
bootstrap = new MockBootstrap();
init();
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -21,7 +21,7 @@
@Test(expectedExceptions={ContextNotActiveException.class}, groups={"manager"}) @SpecAssertion(section="8.6")
public void testGetContextWithNoActiveContextsFails()
{
- Context requestContext = new RequestContext();
+ Context requestContext = new RequestContext() {};
((AbstractContext)requestContext).setActive(false);
manager.setContexts(requestContext);
manager.getContext(RequestScoped.class);
@@ -30,8 +30,8 @@
@Test(expectedExceptions={IllegalArgumentException.class}, groups={"manager"}) @SpecAssertion(section="8.6")
public void testGetContextWithTooManyActiveContextsFails()
{
- Context firstContext = new RequestContext();
- Context secondContext = new RequestContext();
+ Context firstContext = new RequestContext() {};
+ Context secondContext = new RequestContext() {};
manager.setContexts(firstContext, secondContext);
manager.getContext(RequestScoped.class);
assert true;
@@ -48,7 +48,7 @@
@Test(groups={"manager"}) @SpecAssertion(section="8.6")
public void testGetContextReturnsActiveContext()
{
- Context requestContext = new RequestContext();
+ Context requestContext = new RequestContext() {};
manager.setContexts(requestContext);
Context testContext = manager.getContext(RequestScoped.class);
assert testContext == requestContext;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NormalContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NormalContextTest.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NormalContextTest.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -35,7 +35,7 @@
@BeforeMethod
public void initContext() {
- context = new RequestContext();
+ context = new RequestContext() {};
}
@Test(groups="contexts") @SpecAssertion(section="8.1")
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/PassivatingContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/PassivatingContextTest.java 2008-12-06 21:28:44 UTC (rev 424)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/PassivatingContextTest.java 2008-12-06 21:52:42 UTC (rev 425)
@@ -19,7 +19,7 @@
@BeforeMethod
public void initContext()
{
- context = new RequestContext();
+ context = new RequestContext() {};
}
@Test(groups = {"stub", "contexts", "passivation" }) @SpecAssertion(section = "8.4")
16 years
[webbeans-commits] Webbeans SVN: r424 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/bean and 11 other directories.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-12-06 16:28:44 -0500 (Sat, 06 Dec 2008)
New Revision: 424
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.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/ApplicationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.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/BindingTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.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:
get rid of some usages of the static
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -75,11 +75,11 @@
{
public static final String JNDI_KEY = "java:comp/Manager";
- protected static ManagerImpl instance = new ManagerImpl();
+ protected static ManagerImpl rootManager = new ManagerImpl();
- public static ManagerImpl instance()
+ public static ManagerImpl rootManager()
{
- return instance;
+ return rootManager;
}
private List<Class<? extends Annotation>> enabledDeploymentTypes;
@@ -97,8 +97,8 @@
{
this.metaDataCache = new MetaDataCache();
this.beans = new CopyOnWriteArrayList<Bean<?>>();
- this.eventManager = new EventManager();
- this.resolver = new Resolver();
+ this.eventManager = new EventManager(this);
+ this.resolver = new Resolver(this);
this.proxyPool = new ProxyPool();
this.decorators = new HashSet<Decorator>();
this.interceptors = new HashSet<Interceptor>();
@@ -112,7 +112,7 @@
*/
protected void initStandardBeans()
{
- addBean(new SimpleBean<DefaultEnterpriseBeanLookup>(DefaultEnterpriseBeanLookup.class));
+ addBean(new SimpleBean<DefaultEnterpriseBeanLookup>(DefaultEnterpriseBeanLookup.class, this));
}
/**
@@ -212,7 +212,7 @@
*/
public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
{
- return eventManager.getObservers(metaDataCache, event, bindings);
+ return eventManager.getObservers(event, bindings);
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -91,12 +91,15 @@
private Set<AnnotatedItem<?, ?>> injectionPoints;
private ConcurrentCache<String, Set<Bean<?>>> resolvedNames;
+
+ private ManagerImpl manager;
- public Resolver()
+ public Resolver(ManagerImpl manager)
{
this.injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?,?>, Set<Bean<?>>>();
this.resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
+ this.manager = manager;
}
/**
@@ -115,7 +118,7 @@
public Set<Bean<T>> call() throws Exception
{
- Set<Bean<T>> beans = retainHighestPrecedenceBeans(getMatchingBeans(element, ManagerImpl.instance().getBeans(), ManagerImpl.instance().getMetaDataCache()), ManagerImpl.instance().getEnabledDeploymentTypes());
+ Set<Bean<T>> beans = retainHighestPrecedenceBeans(getMatchingBeans(element, manager.getBeans()), manager.getEnabledDeploymentTypes());
if (element.getType().isPrimitive())
{
for (Bean<?> bean : beans)
@@ -186,7 +189,7 @@
if (element.getType().equals(Object.class))
{
// TODO Fix this cast
- beans = new HashSet<Bean<T>>((List) ManagerImpl.instance().getBeans());
+ beans = new HashSet<Bean<T>>((List) manager.getBeans());
}
else
{
@@ -207,14 +210,14 @@
public Set<Bean<?>> call() throws Exception
{
Set<Bean<?>> beans = new HashSet<Bean<?>>();
- for (Bean<?> bean : ManagerImpl.instance().getBeans())
+ for (Bean<?> bean : manager.getBeans())
{
if ((bean.getName() == null && name == null) || (bean.getName() != null && bean.getName().equals(name)))
{
beans.add(bean);
}
}
- return retainHighestPrecedenceBeans((Set) beans, ManagerImpl.instance().getEnabledDeploymentTypes());
+ return retainHighestPrecedenceBeans((Set) beans, manager.getEnabledDeploymentTypes());
}
});
@@ -252,12 +255,12 @@
}
@SuppressWarnings("unchecked")
- private static <T> Set<Bean<T>> getMatchingBeans(AnnotatedItem<T, ?> element, List<Bean<?>> beans, MetaDataCache metaDataCache)
+ private <T> Set<Bean<T>> getMatchingBeans(AnnotatedItem<T, ?> element, List<Bean<?>> beans)
{
Set<Bean<T>> resolvedBeans = new HashSet<Bean<T>>();
for (Bean<?> bean : beans)
{
- if (element.isAssignableFrom(bean.getTypes()) && containsAllBindingBindingTypes(element, bean.getBindingTypes(), metaDataCache))
+ if (element.isAssignableFrom(bean.getTypes()) && containsAllBindingBindingTypes(element, bean.getBindingTypes()))
{
resolvedBeans.add((Bean<T>) bean);
}
@@ -265,11 +268,12 @@
return resolvedBeans;
}
- private static boolean containsAllBindingBindingTypes(AnnotatedItem<?, ?> element, Set<Annotation> bindingTypes, MetaDataCache metaDataCache)
+ private boolean containsAllBindingBindingTypes(AnnotatedItem<?, ?> element, Set<Annotation> bindingTypes)
{
+ MetaDataCache metaDataCache = manager.getMetaDataCache();
for (Annotation bindingType : element.getBindingTypes())
{
- BindingTypeModel<?> bindingTypeModel = metaDataCache.getBindingTypeModel(bindingType.annotationType());
+ BindingTypeModel<?> bindingTypeModel = metaDataCache.getBindingTypeModel(bindingType.annotationType());
if (bindingTypeModel.getNonBindingTypes().size() > 0)
{
boolean matchFound = false;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -101,6 +101,8 @@
protected Set<AnnotatedItem<?, ?>> injectionPoints;
private boolean primitive;
+
+ protected ManagerImpl manager;
// Cached values
private Type declaredBeanType;
@@ -108,9 +110,10 @@
/**
* Constructor
*/
- public AbstractBean()
+ public AbstractBean(ManagerImpl manager)
{
- super(ManagerImpl.instance());
+ super(manager);
+ this.manager = manager;
}
/**
@@ -118,7 +121,7 @@
*/
protected void init()
{
- mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class));
+ mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager.getMetaDataCache());
initType();
initPrimitive();
log.debug("Building Web Bean bean metadata for " + getType());
@@ -221,7 +224,7 @@
if (getMergedStereotypes().getPossibleDeploymentTypes().size() > 0)
{
- this.deploymentType = getDeploymentType(ManagerImpl.instance().getEnabledDeploymentTypes(), getMergedStereotypes().getPossibleDeploymentTypes());
+ this.deploymentType = getDeploymentType(manager.getEnabledDeploymentTypes(), getMergedStereotypes().getPossibleDeploymentTypes());
log.trace("Deployment type " + deploymentType + " specified by stereotype");
return;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -29,6 +29,7 @@
import javax.webbeans.Observes;
import javax.webbeans.Produces;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -60,9 +61,9 @@
* @param annotatedItem Annotations read from java classes
* @param xmlAnnotatedItem Annotations read from XML
*/
- public AbstractClassBean(Class<T> type)
+ public AbstractClassBean(Class<T> type, ManagerImpl manager)
{
- super();
+ super(manager);
this.annotatedItem = new AnnotatedClassImpl<T>(type);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -29,6 +29,7 @@
import javax.webbeans.Produces;
import javax.webbeans.Specializes;
import javax.webbeans.manager.EnterpriseBeanLookup;
+import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.ejb.EJB;
@@ -57,9 +58,9 @@
*
* @param type The type of the bean
*/
- public EnterpriseBean(Class<T> type)
+ public EnterpriseBean(Class<T> type, ManagerImpl manager)
{
- super(type);
+ super(type, manager);
init();
}
@@ -70,7 +71,7 @@
protected void init()
{
super.init();
- ejbMetaData = ManagerImpl.instance().getMetaDataCache().getEjbMetaData(getType());
+ ejbMetaData = manager.getMetaDataCache().getEjbMetaData(getType());
initRemoveMethod();
initInjectionPoints();
checkEnterpriseBeanTypeAllowed();
@@ -138,14 +139,14 @@
}
if (!isDefinedInXml())
{
- if (!ManagerImpl.instance().getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
+ if (!manager.getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
{
throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
}
}
else
{
- if (ManagerImpl.instance().getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
+ if (manager.getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
{
throw new DefinitionException("XML defined specializing EJB must have annotation defined EJB implementation");
}
@@ -224,11 +225,11 @@
@Override
public T create()
{
- T instance = (T) ManagerImpl.instance().getInstanceByType(EnterpriseBeanLookup.class).lookup(ejbMetaData.getEjbName());
+ T instance = (T) manager.getInstanceByType(EnterpriseBeanLookup.class).lookup(ejbMetaData.getEjbName());
bindDecorators();
bindInterceptors();
injectEjbAndCommonFields();
- injectBoundFields(instance);
+ injectBoundFields(manager, instance);
callInitializers(instance);
return instance;
}
@@ -253,7 +254,7 @@
{
for (AnnotatedMethod<Object> initializer : getInitializerMethods())
{
- initializer.invoke(instance);
+ initializer.invoke(manager, instance);
}
}
@@ -270,11 +271,11 @@
*
* @param instance The bean instance
*/
- protected void injectBoundFields(T instance)
+ protected void injectBoundFields(Manager manager, T instance)
{
for (AnnotatedField<?> field : getInjectableFields())
{
- field.inject(instance);
+ field.inject(manager, instance);
}
}
@@ -306,7 +307,7 @@
if (superclass != null)
{
// TODO look up this bean and do this via init
- return new EnterpriseBean(superclass);
+ return new EnterpriseBean(superclass, manager);
}
else
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -25,11 +25,10 @@
import javax.webbeans.Event;
import javax.webbeans.Standard;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.event.EventImpl;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
/**
* An event bean representation
@@ -41,10 +40,6 @@
public class EventBean<T> extends AbstractBean<Event<T>, Field>
{
- private static LogProvider log = Logging.getLogProvider(EventBean.class);
-
- // The debug location
- private String location;
// The underlying annotated item
private AnnotatedField<Event<T>> annotatedItem;
@@ -54,9 +49,9 @@
* @param field The underlying field abstraction
*/
@SuppressWarnings("unchecked")
- public EventBean(AnnotatedField<T> field)
+ public EventBean(AnnotatedField<T> field, ManagerImpl manager)
{
- super();
+ super(manager);
this.annotatedItem = (AnnotatedField<Event<T>>) field;
init();
}
@@ -88,45 +83,30 @@
}
}
- /**
- * @see org.jboss.webbeans.bean.AbstractBean#initScopeType()
- */
@Override
protected void initScopeType()
{
this.scopeType = Dependent.class;
}
- /**
- * @see org.jboss.webbeans.bean.AbstractBean#initDeploymentType()
- */
@Override
protected void initDeploymentType()
{
this.deploymentType = Standard.class;
}
- /**
- * @see org.jboss.webbeans.bean.AbstractBean#getAnnotatedItem()
- */
@Override
protected AnnotatedItem<Event<T>, Field> getAnnotatedItem()
{
return annotatedItem;
}
- /**
- * @see org.jboss.webbeans.bean.AbstractBean#getDefaultName()
- */
@Override
protected String getDefaultName()
{
return null;
}
- /**
- * @see org.jboss.webbeans.bean.AbstractBean#initType()
- */
@Override
protected void initType()
{
@@ -144,29 +124,12 @@
}
}
- /**
- * Gets the debug location
- *
- * @return A string describing the location
- */
- private String getLocation()
- {
- if (location == null)
- {
- location = "type: Event Bean;";
- }
- return location;
- }
-
- /**
- * @see javax.webbeans.manager.Bean#create()
- */
@SuppressWarnings("unchecked")
@Override
public Event<T> create()
{
Class<T> eventType = (Class<T>) annotatedItem.getType().getTypeParameters()[0].getClass();
- return new EventImpl<T>(eventType, annotatedItem.getBindingTypesAsArray());
+ return new EventImpl<T>(manager, eventType, annotatedItem.getBindingTypesAsArray());
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -21,7 +21,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem.AnnotationMap;
import org.jboss.webbeans.model.StereotypeModel;
import org.jboss.webbeans.util.Strings;
@@ -49,13 +49,13 @@
*
* @param stereotypeAnnotations The stereotypes to merge
*/
- public MergedStereotypes(Set<Annotation> stereotypeAnnotations)
+ public MergedStereotypes(Set<Annotation> stereotypeAnnotations, MetaDataCache metaDataCache)
{
possibleDeploymentTypes = new AnnotationMap();
possibleScopeTypes = new HashSet<Annotation>();
requiredTypes = new HashSet<Class<?>>();
supportedScopes = new HashSet<Class<? extends Annotation>>();
- merge(stereotypeAnnotations);
+ merge(stereotypeAnnotations, metaDataCache);
}
/**
@@ -63,12 +63,12 @@
*
* @param stereotypeAnnotations The stereotype annotations
*/
- protected void merge(Set<Annotation> stereotypeAnnotations)
+ protected void merge(Set<Annotation> stereotypeAnnotations, MetaDataCache metaDataCache)
{
for (Annotation stereotypeAnnotation : stereotypeAnnotations)
{
// Retrieve and merge all metadata from stereotypes
- StereotypeModel<?> stereotype = ManagerImpl.instance().getMetaDataCache().getStereotype(stereotypeAnnotation.annotationType());
+ StereotypeModel<?> stereotype = metaDataCache.getStereotype(stereotypeAnnotation.annotationType());
if (stereotype == null)
{
throw new IllegalStateException("Stereotype " + stereotypeAnnotation + " not registered with container");
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -57,9 +57,9 @@
* @param method The producer method
* @param declaringBean The declaring bean instance
*/
- public ProducerMethodBean(Method method, AbstractClassBean<?> declaringBean)
+ public ProducerMethodBean(Method method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
- this(new AnnotatedMethodImpl<T>(method, declaringBean.getAnnotatedItem()), declaringBean);
+ this(new AnnotatedMethodImpl<T>(method, declaringBean.getAnnotatedItem()), declaringBean, manager);
}
/**
@@ -68,9 +68,9 @@
* @param method The producer method abstraction
* @param declaringBean The declaring bean
*/
- public ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean)
+ public ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
- super();
+ super(manager);
this.method = method;
this.declaringBean = declaringBean;
init();
@@ -84,7 +84,7 @@
@Override
public T create()
{
- T instance = method.invoke(ManagerImpl.instance().getInstance(getDeclaringBean()));
+ T instance = method.invoke(manager, manager.getInstance(getDeclaringBean()));
if (instance == null && !getScopeType().equals(Dependent.class))
{
throw new IllegalProductException("Cannot return null from a non-dependent method");
@@ -175,7 +175,7 @@
*/
protected void initRemoveMethod()
{
- Set<AnnotatedMethod<Object>> disposalMethods = ManagerImpl.instance().resolveDisposalMethods(getType(), getBindingTypes().toArray(new Annotation[0]));
+ Set<AnnotatedMethod<Object>> disposalMethods = manager.resolveDisposalMethods(getType(), getBindingTypes().toArray(new Annotation[0]));
if (disposalMethods.size() == 1)
{
removeMethod = disposalMethods.iterator().next();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -25,7 +25,9 @@
import javax.annotation.PreDestroy;
import javax.webbeans.DefinitionException;
import javax.webbeans.Initializer;
+import javax.webbeans.manager.Manager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -59,9 +61,9 @@
*
* @param type The type of the bean
*/
- public SimpleBean(Class<T> type)
+ public SimpleBean(Class<T> type, ManagerImpl manager)
{
- super(type);
+ super(type, manager);
init();
}
@@ -73,11 +75,11 @@
@Override
public T create()
{
- T instance = constructor.newInstance();
+ T instance = constructor.newInstance(manager);
bindDecorators();
bindInterceptors();
injectEjbAndCommonFields();
- injectBoundFields(instance);
+ injectBoundFields(manager, instance);
callInitializers(instance);
callPostConstruct(instance);
return instance;
@@ -106,7 +108,8 @@
{
try
{
- preDestroy.invoke(instance);
+ //note: RI supports injection into @PreDestroy
+ preDestroy.invoke(manager, instance);
}
catch (Exception e)
{
@@ -127,7 +130,8 @@
{
try
{
- postConstruct.invoke(instance);
+ //note: RI supports injection into @PostConstruct
+ postConstruct.invoke(manager, instance);
}
catch (Exception e)
{
@@ -145,7 +149,7 @@
{
for (AnnotatedMethod<Object> initializer : getInitializerMethods())
{
- initializer.invoke(instance);
+ initializer.invoke(manager, instance);
}
}
@@ -162,11 +166,11 @@
*
* @param instance The instance to inject into
*/
- protected void injectBoundFields(T instance)
+ protected void injectBoundFields(Manager manager, T instance)
{
for (AnnotatedField<?> injectableField : getInjectableFields())
{
- injectableField.inject(instance);
+ injectableField.inject(manager, instance);
}
}
@@ -328,7 +332,7 @@
if (superclass != null)
{
// TODO look up this bean and do this via init
- return new SimpleBean(superclass);
+ return new SimpleBean(superclass, manager);
}
else
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -17,7 +17,9 @@
package org.jboss.webbeans.bean;
+import org.jboss.webbeans.ManagerImpl;
+
/**
* Represents an XML defined enterprise bean
*
@@ -33,9 +35,9 @@
*
* @param type The type of the bean
*/
- public XmlEnterpriseBean(Class<T> type)
+ public XmlEnterpriseBean(Class<T> type, ManagerImpl manager)
{
- super(type);
+ super(type, manager);
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -17,7 +17,9 @@
package org.jboss.webbeans.bean;
+import org.jboss.webbeans.ManagerImpl;
+
/**
* Represents a simple, XML defined bean
*
@@ -33,9 +35,9 @@
*
* @param type The type of the bean
*/
- public XmlSimpleBean(Class<T> type)
+ public XmlSimpleBean(Class<T> type, ManagerImpl manager)
{
- super(type);
+ super(type, manager);
}
/**
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -69,11 +69,12 @@
*/
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
{
+ //TODO: account for child managers
if (bean == null)
{
- bean = ManagerImpl.instance().getBeans().get(beanIndex);
+ bean = ManagerImpl.rootManager().getBeans().get(beanIndex);
}
- Context context = ManagerImpl.instance().getContext(bean.getScopeType());
+ Context context = ManagerImpl.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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -151,7 +151,7 @@
public T call() throws Exception
{
- int beanIndex = ManagerImpl.instance().getBeans().indexOf(bean);
+ int beanIndex = ManagerImpl.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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -58,7 +58,7 @@
*/
public Bootstrap()
{
- JNDI.set(ManagerImpl.JNDI_KEY, ManagerImpl.instance());
+ JNDI.set(ManagerImpl.JNDI_KEY, ManagerImpl.rootManager());
}
/**
@@ -81,7 +81,7 @@
public void registerBeans(Iterable<Class<?>> classes)
{
Set<AbstractBean<?, ?>> beans = createBeans(classes);
- ManagerImpl.instance().setBeans(beans);
+ ManagerImpl.rootManager().setBeans(beans);
}
/**
@@ -114,7 +114,7 @@
for (Class<?> clazz : classes)
{
AbstractClassBean<?> bean;
- if (ManagerImpl.instance().getMetaDataCache().getEjbMetaData(clazz).isEjb())
+ if (ManagerImpl.rootManager().getMetaDataCache().getEjbMetaData(clazz).isEjb())
{
bean = createEnterpriseBean(clazz);
}
@@ -123,18 +123,18 @@
bean = createSimpleBean(clazz);
}
beans.add(bean);
- ManagerImpl.instance().getResolver().addInjectionPoints(bean.getInjectionPoints());
+ ManagerImpl.rootManager().getResolver().addInjectionPoints(bean.getInjectionPoints());
for (AnnotatedMethod<Object> producerMethod : bean.getProducerMethods())
{
ProducerMethodBean<?> producerMethodBean = createProducerMethodBean(producerMethod, bean);
beans.add(producerMethodBean);
- ManagerImpl.instance().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
+ ManagerImpl.rootManager().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
}
for (AnnotatedField<Object> eventField : bean.getEventFields())
{
EventBean<?> eventBean = createEventBean(eventField);
beans.add(eventBean);
- ManagerImpl.instance().getResolver().addInjectionPoints(eventBean.getInjectionPoints());
+ ManagerImpl.rootManager().getResolver().addInjectionPoints(eventBean.getInjectionPoints());
}
log.info("Web Bean: " + bean);
}
@@ -159,7 +159,7 @@
}
registerBeans(webBeanDiscovery.discoverWebBeanClasses());
log.info("Validing Web Bean injection points");
- ManagerImpl.instance().getResolver().resolveInjectionPoints();
+ ManagerImpl.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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -40,7 +40,7 @@
*/
protected String getBeanKey(Contextual<?> bean)
{
- return getKeyPrefix() + "#" + ManagerImpl.instance().getBeans().indexOf(bean);
+ return getKeyPrefix() + "#" + ManagerImpl.rootManager().getBeans().indexOf(bean);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -74,7 +74,7 @@
*/
public static ApplicationContext instance()
{
- return (ApplicationContext) ManagerImpl.instance().getBuiltInContext(ApplicationScoped.class);
+ return (ApplicationContext) ManagerImpl.rootManager().getBuiltInContext(ApplicationScoped.class);
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -44,7 +44,7 @@
*/
public static RequestContext instance()
{
- return (RequestContext) ManagerImpl.instance().getBuiltInContext(RequestScoped.class);
+ return (RequestContext) ManagerImpl.rootManager().getBuiltInContext(RequestScoped.class);
}
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -90,7 +90,7 @@
*/
private String getBeanKey(Contextual<?> bean)
{
- return keyPrefix + ManagerImpl.instance().getBeans().indexOf(bean);
+ return keyPrefix + ManagerImpl.rootManager().getBeans().indexOf(bean);
}
/**
@@ -185,7 +185,7 @@
if (name.startsWith(keyPrefix))
{
String id = name.substring(keyPrefix.length());
- Contextual<?> bean = ManagerImpl.instance().getBeans().get(Integer.parseInt(id));
+ Contextual<?> bean = ManagerImpl.rootManager().getBeans().get(Integer.parseInt(id));
beans.add(bean);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -72,7 +72,7 @@
*/
public static SessionContext instance()
{
- return (SessionContext) ManagerImpl.instance().getBuiltInContext(SessionScoped.class);
+ return (SessionContext) ManagerImpl.rootManager().getBuiltInContext(SessionScoped.class);
}
}
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -63,7 +63,7 @@
{
if (base == null && property != null)
{
- return ManagerImpl.instance().getInstanceByName(property.toString());
+ return ManagerImpl.rootManager().getInstanceByName(property.toString());
}
else
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -22,12 +22,10 @@
import java.util.Set;
import javax.webbeans.BindingType;
-import javax.webbeans.Dependent;
import javax.webbeans.DuplicateBindingTypeException;
import javax.webbeans.Event;
import javax.webbeans.Observable;
import javax.webbeans.Observer;
-import javax.webbeans.Standard;
import org.jboss.webbeans.ManagerImpl;
@@ -45,14 +43,16 @@
private final Set<? extends Annotation> bindingTypes;
// The event type
private final Class<T> eventType;
+ private final ManagerImpl manager;
/**
* Constructor
*
* @param bindingTypes The binding types
*/
- public EventImpl(Class<T> eventType, Annotation... bindingTypes)
+ public EventImpl(ManagerImpl manager, Class<T> eventType, Annotation... bindingTypes)
{
+ this.manager = manager;
this.bindingTypes = getBindingTypes(bindingTypes);
this.eventType = eventType;
}
@@ -120,7 +120,7 @@
{
Set<Annotation> bindingParameters = checkBindingTypes(bindingTypes);
bindingParameters.addAll(this.bindingTypes);
- ManagerImpl.instance().fireEvent(event, bindingParameters.toArray(new Annotation[0]));
+ manager.fireEvent(event, bindingParameters.toArray(new Annotation[0]));
}
/**
@@ -133,7 +133,7 @@
{
Set<Annotation> bindingParameters = checkBindingTypes(bindingTypes);
bindingParameters.addAll(this.bindingTypes);
- ManagerImpl.instance().addObserver(observer, eventType, bindingParameters.toArray(new Annotation[0]));
+ manager.addObserver(observer, eventType, bindingParameters.toArray(new Annotation[0]));
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -31,7 +31,6 @@
import javax.webbeans.Observer;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.transaction.TransactionListener;
import org.jboss.webbeans.util.JNDI;
import org.jboss.webbeans.util.Strings;
@@ -46,6 +45,8 @@
*/
public class EventManager
{
+ private ManagerImpl manager;
+
/**
* The known transactional phases a transactional event observer can be
* interested in
@@ -141,8 +142,9 @@
/**
* Initializes a new instance of the EventManager.
*/
- public EventManager()
+ public EventManager(ManagerImpl manager)
{
+ this.manager = manager;
registeredObservers = new RegisteredObserversMap();
// TODO. Check where to *really* get this from
userTransaction = (UserTransaction) JNDI.lookup("java:/UserTransaction");
@@ -157,7 +159,7 @@
*/
public <T> void addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
{
- EventObserver<T> eventObserver = new EventObserver<T>(observer, eventType, bindings);
+ EventObserver<T> eventObserver = new EventObserver<T>(manager.getMetaDataCache(), observer, eventType, bindings);
registeredObservers.put(eventType, eventObserver);
}
@@ -171,12 +173,12 @@
* matches.
*/
@SuppressWarnings("unchecked")
- public <T> Set<Observer<T>> getObservers(MetaDataCache mdc, T event, Annotation... bindings)
+ public <T> Set<Observer<T>> getObservers(T event, Annotation... bindings)
{
Set<Observer<T>> interestedObservers = new HashSet<Observer<T>>();
for (EventObserver<?> observer : registeredObservers.get(event.getClass()))
{
- if (observer.isObserverInterested(mdc, bindings))
+ if (observer.isObserverInterested(bindings))
{
interestedObservers.add((Observer<T>) observer.getObserver());
}
@@ -235,7 +237,7 @@
*/
private <T> void deferEvent(T event, Observer<T> observer)
{
- TransactionListener transactionListener = ManagerImpl.instance().getInstanceByType(TransactionListener.class);
+ TransactionListener transactionListener = manager.getInstanceByType(TransactionListener.class);
DeferredEventNotification<T> deferredEvent = new DeferredEventNotification<T>(event, observer);
transactionListener.registerSynhronization(deferredEvent);
}
@@ -250,7 +252,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>(manager.getMetaDataCache(), observer, eventType, bindings);
observers.remove(eventObserver);
}
@@ -262,4 +264,5 @@
buffer.append(registeredObservers.toString());
return buffer.toString();
}
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -44,6 +44,7 @@
private final Class<T> eventType;
private final List<Annotation> eventBindings;
private final Observer<T> observer;
+ private final MetaDataCache metaDataCache;
/**
* Constructs a new wrapper for an observer.
@@ -52,11 +53,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 Class<T> eventType, final Annotation... eventBindings)
+ public EventObserver(MetaDataCache metaDataCache, final Observer<T> observer, final Class<T> eventType, final Annotation... eventBindings)
{
this.observer = observer;
this.eventType = eventType;
this.eventBindings = Arrays.asList(eventBindings);
+ this.metaDataCache = metaDataCache;
}
/**
@@ -90,7 +92,7 @@
* @param bindings The event bindings
* @return true only if all required bindings match
*/
- public boolean isObserverInterested(MetaDataCache mdc, Annotation... bindings)
+ public boolean isObserverInterested(Annotation... bindings)
{
// Simply check that all event bindings specified by the observer are
// in the list provided.
@@ -106,7 +108,7 @@
boolean found = false;
for (Annotation y: bindings)
{
- if ( mdc.getBindingTypeModel(x.annotationType()).isEqual(x, y) ) {
+ if ( metaDataCache.getBindingTypeModel(x.annotationType()).isEqual(x, y) ) {
found = true;
}
}
@@ -116,11 +118,7 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
+
@Override
public int hashCode()
{
@@ -132,11 +130,6 @@
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -58,6 +58,7 @@
private final Class<T> eventType;
private TransactionObservationPhase transactionObservationPhase;
private boolean conditional;
+ private ManagerImpl manager;
/**
* Creates an Observer which describes and encapsulates an observer method
@@ -71,8 +72,9 @@
* @param observer The observer method to notify
* @param eventType The type of event being observed
*/
- public ObserverImpl(final Bean<?> observerBean, final AnnotatedMethod<Object> observer, final Class<T> eventType)
+ public ObserverImpl(final ManagerImpl manager, final Bean<?> observerBean, final AnnotatedMethod<Object> observer, final Class<T> eventType)
{
+ this.manager = manager;
this.observerBean = observerBean;
this.observerMethod = observer;
this.eventType = eventType;
@@ -125,7 +127,7 @@
if (instance != null)
{
// TODO replace event parameter
- observerMethod.invokeWithSpecialValue(instance, Observes.class, event);
+ observerMethod.invokeWithSpecialValue(manager, instance, Observes.class, event);
}
}
@@ -141,7 +143,7 @@
protected Object getInstance(boolean conditional)
{
// Return the most specialized instance of the component
- return ManagerImpl.instance().getMostSpecializedInstance(observerBean, conditional);
+ return manager.getMostSpecializedInstance(observerBean, conditional);
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -21,6 +21,8 @@
import java.lang.reflect.Constructor;
import java.util.List;
+import javax.webbeans.manager.Manager;
+
/**
* Represents a Class Constructor
*
@@ -53,7 +55,7 @@
*
* @return The created instance
*/
- public T newInstance();
+ public T newInstance(Manager manager);
/**
* Gets the declaring class of the annotation
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -19,6 +19,8 @@
import java.lang.reflect.Field;
+import javax.webbeans.manager.Manager;
+
/**
* AnnotatedField provides a uniform access to the annotations on an annotated
* field
@@ -41,7 +43,7 @@
*
* @param instance The instance to inject
*/
- public void inject(Object instance);
+ public void inject(Manager manager, Object instance);
/**
* Gets an abstraction of the declaring class
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -21,6 +21,8 @@
import java.lang.reflect.Method;
import java.util.List;
+import javax.webbeans.manager.Manager;
+
/**
* AnnotatedType provides a uniform access to the annotations on an annotated
* class defined either in Java or XML
@@ -54,7 +56,7 @@
* @param instance The instance to invoke
* @return A reference to the instance
*/
- public T invoke(Object instance);
+ public T invoke(Manager manager, Object instance);
/**
* Invokes the observer method
@@ -63,7 +65,7 @@
* @param event the event object
* @return A reference to the instance
*/
- public T invokeWithSpecialValue(Object instance, Class<? extends Annotation> specialParam, Object specialVal);
+ public T invokeWithSpecialValue(Manager manager, Object instance, Class<? extends Annotation> specialParam, Object specialVal);
/**
* Invokes the method
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -17,7 +17,9 @@
package org.jboss.webbeans.introspector;
+import javax.webbeans.manager.Manager;
+
/**
* AnnotatedParameter provides a uniform access to a method parameter defined
* either in Java or XML
@@ -33,6 +35,6 @@
*
* @return The value
*/
- public T getValue();
+ public T getValue(Manager manager);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -33,6 +33,7 @@
import javax.webbeans.DeploymentType;
import javax.webbeans.ScopeType;
import javax.webbeans.Stereotype;
+import javax.webbeans.manager.Manager;
import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
import org.jboss.webbeans.introspector.AnnotatedItem;
@@ -203,9 +204,9 @@
* @return The object array of looked up values
*
*/
- protected static Object[] getParameterValues(List<AnnotatedParameter<Object>> parameters)
+ protected static Object[] getParameterValues(Manager manager, List<AnnotatedParameter<Object>> parameters)
{
- return getParameterValues(parameters, null, null);
+ return getParameterValues(manager, parameters, null, null);
}
/**
@@ -216,7 +217,7 @@
* @return The object array of looked up values
*
*/
- protected static Object[] getParameterValues(List<AnnotatedParameter<Object>> parameters, Object specialVal, Class<? extends Annotation> specialParam)
+ protected static Object[] getParameterValues(Manager manager, List<AnnotatedParameter<Object>> parameters, Object specialVal, Class<? extends Annotation> specialParam)
{
Object[] parameterValues = new Object[parameters.size()];
Iterator<AnnotatedParameter<Object>> iterator = parameters.iterator();
@@ -229,7 +230,7 @@
}
else
{
- parameterValues[i] = param.getValue();
+ parameterValues[i] = param.getValue(manager);
}
}
return parameterValues;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -25,6 +25,7 @@
import java.util.Map;
import javax.webbeans.BindingType;
+import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -134,9 +135,9 @@
*
* @return The current value
*/
- public T getValue()
+ public T getValue(Manager manager)
{
- return ManagerImpl.instance().getInstanceByType(getType(), getMetaAnnotationsAsArray(BindingType.class));
+ return manager.getInstanceByType(getType(), getMetaAnnotationsAsArray(BindingType.class));
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -27,6 +27,7 @@
import java.util.List;
import javax.webbeans.ExecutionException;
+import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
@@ -198,12 +199,12 @@
*
* @see org.jboss.webbeans.introspector.AnnotatedConstructor#newInstance(ManagerImpl)
*/
- public T newInstance()
+ public T newInstance(Manager manager)
{
try
{
// TODO: more details in the exceptions
- return getDelegate().newInstance(getParameterValues(parameters));
+ return getDelegate().newInstance(getParameterValues(manager, parameters));
}
catch (IllegalArgumentException e)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -22,6 +22,8 @@
import java.lang.reflect.Type;
import java.util.Arrays;
+import javax.webbeans.manager.Manager;
+
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -120,9 +122,9 @@
* @see org.jboss.webbeans.introspector.AnnotatedField#inject(Object,
* ManagerImpl)
*/
- public void inject(Object instance)
+ public void inject(Manager manager, Object instance)
{
- Reflections.setAndWrap(getDelegate(), instance, getValue());
+ Reflections.setAndWrap(getDelegate(), instance, getValue(manager));
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -26,6 +26,8 @@
import java.util.Collections;
import java.util.List;
+import javax.webbeans.manager.Manager;
+
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -236,15 +238,15 @@
* Object)
*/
@SuppressWarnings("unchecked")
- public T invoke(Object instance)
+ public T invoke(Manager manager, Object instance)
{
- return (T) Reflections.invokeAndWrap(getDelegate(), instance, getParameterValues(parameters));
+ return (T) Reflections.invokeAndWrap(getDelegate(), instance, getParameterValues(manager, parameters));
}
@SuppressWarnings("unchecked")
- public T invokeWithSpecialValue(Object instance, Class<? extends Annotation> specialParam, Object specialVal)
+ public T invokeWithSpecialValue(Manager manager, Object instance, Class<? extends Annotation> specialParam, Object specialVal)
{
- return (T) Reflections.invokeAndWrap(getDelegate(), instance, getParameterValues(parameters, specialVal, specialParam));
+ return (T) Reflections.invokeAndWrap(getDelegate(), instance, getParameterValues(manager, parameters, specialVal, specialParam));
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -22,6 +22,7 @@
import java.util.Arrays;
import javax.webbeans.BindingType;
+import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -129,9 +130,9 @@
*
* @see org.jboss.webbeans.introspector.AnnotatedParameter
*/
- public T getValue()
+ public T getValue(Manager manager)
{
- return ManagerImpl.instance().getInstanceByType(getType(), getMetaAnnotationsAsArray(BindingType.class));
+ return manager.getInstanceByType(getType(), getMetaAnnotationsAsArray(BindingType.class));
}
/**
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -85,7 +85,7 @@
if (name.startsWith(getKeyPrefix()))
{
String id = name.substring(getKeyPrefix().length());
- Contextual<?> bean = ManagerImpl.instance().getBeans().get(Integer.parseInt(id));
+ Contextual<?> bean = ManagerImpl.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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -145,7 +145,7 @@
if (name.startsWith(getKeyPrefix()))
{
String id = name.substring(getKeyPrefix().length());
- Contextual<?> bean = ManagerImpl.instance().getBeans().get(Integer.parseInt(id));
+ Contextual<?> bean = ManagerImpl.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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -19,6 +19,7 @@
import java.lang.reflect.Method;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.EventBean;
@@ -45,7 +46,7 @@
*/
public static <T> SimpleBean<T> createSimpleBean(Class<T> clazz)
{
- return new SimpleBean<T>(clazz);
+ return new SimpleBean<T>(clazz, ManagerImpl.rootManager());
}
/**
@@ -57,7 +58,7 @@
*/
public static <T> XmlSimpleBean<T> createXmlSimpleBean(Class<T> clazz)
{
- return new XmlSimpleBean<T>(clazz);
+ return new XmlSimpleBean<T>(clazz, ManagerImpl.rootManager());
}
/**
@@ -69,7 +70,7 @@
*/
public static <T> EnterpriseBean<T> createEnterpriseBean(Class<T> clazz)
{
- return new EnterpriseBean<T>(clazz);
+ return new EnterpriseBean<T>(clazz, ManagerImpl.rootManager());
}
/**
@@ -81,7 +82,7 @@
*/
public static <T> XmlEnterpriseBean<T> createXmlEnterpriseBean(Class<T> clazz)
{
- return new XmlEnterpriseBean<T>(clazz);
+ return new XmlEnterpriseBean<T>(clazz, ManagerImpl.rootManager());
}
/**
@@ -95,7 +96,7 @@
*/
public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, Method method, AbstractClassBean<?> declaringBean)
{
- return new ProducerMethodBean<T>(method, declaringBean);
+ return new ProducerMethodBean<T>(method, declaringBean, ManagerImpl.rootManager());
}
/**
@@ -107,7 +108,7 @@
*/
public static <T> ProducerMethodBean<T> createProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean)
{
- return new ProducerMethodBean<T>(method, declaringBean);
+ return new ProducerMethodBean<T>(method, declaringBean, ManagerImpl.rootManager());
}
/**
@@ -119,7 +120,7 @@
*/
public static <T> EventBean<T> createEventBean(AnnotatedField<T> field)
{
- return new EventBean<T>(field);
+ return new EventBean<T>(field, ManagerImpl.rootManager());
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -146,7 +146,7 @@
@Test(groups={"injection", "producerMethod"})
public void testMethodWithBindingAnnotationsOnParametersAreInjected() throws Exception
{
- SimpleBean<SpiderProducer> spiderProducer = createSimpleBean(SpiderProducer.class);
+ SimpleBean<SpiderProducer> spiderProducer = createSimpleBean(SpiderProducer.class);
manager.addBean(spiderProducer);
Method method = SpiderProducer.class.getMethod("produceTameTarantula");
manager.addBean(createProducerMethodBean(Tarantula.class, method, spiderProducer));
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -37,21 +37,21 @@
@Test(groups = "observerMethod")
public void testAddObserver()
{
- EventManager eventManager = new EventManager();
+ EventManager eventManager = new EventManager(manager);
Observer<DangerCall> observer = new AnObserver<DangerCall>();
eventManager.addObserver(observer, DangerCall.class);
DangerCall event = new DangerCall();
- Set<Observer<DangerCall>> observerSet = eventManager.getObservers(new MetaDataCache(), event);
+ Set<Observer<DangerCall>> observerSet = eventManager.getObservers(event);
assert observerSet.size() == 1;
assert observerSet.iterator().next().equals(observer);
// Add another observer for the same event, but with an event binding
observer = new AnObserver<DangerCall>();
eventManager.addObserver(observer, DangerCall.class, new TameAnnotationLiteral());
- observerSet = eventManager.getObservers(new MetaDataCache(), event);
+ observerSet = eventManager.getObservers(event);
assert observerSet.size() == 1;
- observerSet = eventManager.getObservers(new MetaDataCache(), event, new TameAnnotationLiteral());
+ observerSet = eventManager.getObservers(event, new TameAnnotationLiteral());
assert observerSet.size() == 2;
}
@@ -62,12 +62,12 @@
@Test(groups = { "observerMethod" })
public void testRemoveObserver()
{
- EventManager eventManager = new EventManager();
+ EventManager eventManager = new EventManager(manager);
Observer<DangerCall> observer = new AnObserver<DangerCall>();
eventManager.addObserver(observer, DangerCall.class);
eventManager.removeObserver(observer, DangerCall.class);
// FIXME CopyOnWrite broke remove, have to check later
- assert eventManager.getObservers(new MetaDataCache(), new DangerCall()).isEmpty();
+ assert eventManager.getObservers(new DangerCall()).isEmpty();
}
/**
@@ -167,7 +167,7 @@
// }
//
// };
- EventManager eventManager = new EventManager();
+ EventManager eventManager = new EventManager(manager);
Observer<DangerCall> observer = new AnObserver<DangerCall>();
try
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java 2008-12-06 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -38,17 +38,17 @@
public void testIsObserverInterested()
{
Observer<DangerCall> observer = new AnObserver<DangerCall>();
- EventObserver<DangerCall> wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new TameAnnotationLiteral());
+ EventObserver<DangerCall> wrappedObserver = new EventObserver<DangerCall>(new MetaDataCache(), observer, DangerCall.class, new TameAnnotationLiteral());
assert wrappedObserver.getEventBindings().size() == 1;
- assert wrappedObserver.isObserverInterested(new MetaDataCache(), new TameAnnotationLiteral());
- assert !wrappedObserver.isObserverInterested(new MetaDataCache(), new AnimalStereotypeAnnotationLiteral());
- assert !wrappedObserver.isObserverInterested(new MetaDataCache());
- assert wrappedObserver.isObserverInterested(new MetaDataCache(), new TameAnnotationLiteral(), new RoleBinding("Admin"));
+ assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral());
+ assert !wrappedObserver.isObserverInterested(new AnimalStereotypeAnnotationLiteral());
+ assert !wrappedObserver.isObserverInterested();
+ assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral(), new RoleBinding("Admin"));
// Perform some tests with binding values (7.7.1)
- wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new RoleBinding("Admin"));
+ wrappedObserver = new EventObserver<DangerCall>(new MetaDataCache(), observer, DangerCall.class, new RoleBinding("Admin"));
assert wrappedObserver.getEventBindings().size() == 1;
- assert wrappedObserver.isObserverInterested(new MetaDataCache(), new RoleBinding("Admin"));
- assert !wrappedObserver.isObserverInterested(new MetaDataCache(), new RoleBinding("User"));
+ assert wrappedObserver.isObserverInterested(new RoleBinding("Admin"));
+ assert !wrappedObserver.isObserverInterested(new RoleBinding("User"));
}
}
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -73,7 +73,7 @@
//Create a test annotation for the event and use it to construct the
//event object
Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
- EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>(DangerCall.class, annotations);
+ EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>(manager, DangerCall.class, annotations);
eventComponent.fire(anEvent, new SynchronousAnnotationLiteral());
assert anEvent.equals(manager.getEvent());
assert Reflections.annotationSetMatches(manager.getEventBindings(),
@@ -114,7 +114,7 @@
//Create a test annotation for the event and use it to construct the
//event object
Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
- EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>(DangerCall.class, annotations);
+ EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>(manager, DangerCall.class, annotations);
Observer<DangerCall> observer = new AnObserver<DangerCall>();
eventComponent.observe(observer, new SynchronousAnnotationLiteral());
assert manager.getObservedEventType().equals(DangerCall.class);
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -60,7 +60,7 @@
manager.addBean(ob);
Method method = SampleObserver.class.getMethod("observe", SampleEvent.class);
om = new AnnotatedMethodImpl<Object>(method, new AnnotatedClassImpl<SampleObserver>(SampleObserver.class));
- observer = new ObserverImpl<SampleEvent>(ob, om, SampleEvent.class);
+ observer = new ObserverImpl<SampleEvent>(manager, ob, om, SampleEvent.class);
Annotation annotation = method.getParameterAnnotations()[0][1];
manager.addObserver(observer, SampleEvent.class, annotation);
notified = false;
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 18:47:41 UTC (rev 423)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-12-06 21:28:44 UTC (rev 424)
@@ -73,7 +73,7 @@
public static void setInstance(ManagerImpl manager)
{
- ManagerImpl.instance = manager;
+ ManagerImpl.rootManager = manager;
}
}
16 years