[webbeans-commits] Webbeans SVN: r3518 - ri/trunk/impl/src/main/java/org/jboss/webbeans/event and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Sun Aug 16 06:20:09 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-16 06:20:09 -0400 (Sun, 16 Aug 2009)
New Revision: 3518
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/dependentIsConditionalObserver/DependentIsConditionalObserverTest.java
Log:
WBRI-315
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-08-16 09:59:51 UTC (rev 3517)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-08-16 10:20:09 UTC (rev 3518)
@@ -24,7 +24,6 @@
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.ObserverMethod;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
@@ -86,9 +85,10 @@
manager.addBean(bean);
log.debug("Bean: " + bean);
}
- for (ObserverMethod<?, ?> observer : getEnvironment().getObservers())
+ for (ObserverMethodImpl<?, ?> observer : getEnvironment().getObservers())
{
log.debug("Observer : " + observer);
+ observer.initialize();
manager.addObserver(observer);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-08-16 09:59:51 UTC (rev 3517)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-08-16 10:20:09 UTC (rev 3518)
@@ -26,8 +26,6 @@
import java.util.Map;
import java.util.Set;
-import javax.enterprise.inject.spi.ObserverMethod;
-
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.DecoratorBean;
@@ -39,6 +37,7 @@
import org.jboss.webbeans.bean.standard.AbstractStandardBean;
import org.jboss.webbeans.bean.standard.ExtensionBean;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
+import org.jboss.webbeans.event.ObserverMethodImpl;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.resolution.ResolvableFactory;
@@ -50,7 +49,7 @@
private final Map<WBClass<?>, AbstractClassBean<?>> classBeanMap;
private final Map<WBMethod<?, ?>, ProducerMethodBean<?>> producerMethodBeanMap;
private final Set<RIBean<?>> beans;
- private final Set<ObserverMethod<?, ?>> observers;
+ private final Set<ObserverMethodImpl<?, ?>> observers;
private final List<DisposalMethodBean<?>> allDisposalBeans;
private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
private final Set<DecoratorBean<?>> decorators;
@@ -65,7 +64,7 @@
this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
this.beans = new HashSet<RIBean<?>>();
this.decorators = new HashSet<DecoratorBean<?>>();
- this.observers = new HashSet<ObserverMethod<?, ?>>();
+ this.observers = new HashSet<ObserverMethodImpl<?, ?>>();
this.ejbDescriptors = ejbDescriptors;
this.disposalMethodResolver = new TypeSafeDisposerResolver(manager, allDisposalBeans);
}
@@ -138,7 +137,7 @@
allDisposalBeans.add(bean);
}
- public void addObserver(ObserverMethod<?, ?> observer)
+ public void addObserver(ObserverMethodImpl<?, ?> observer)
{
this.observers.add(observer);
}
@@ -153,7 +152,7 @@
return Collections.unmodifiableSet(decorators);
}
- public Set<ObserverMethod<?, ?>> getObservers()
+ public Set<ObserverMethodImpl<?, ?>> getObservers()
{
return Collections.unmodifiableSet(observers);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java 2009-08-16 09:59:51 UTC (rev 3517)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java 2009-08-16 10:20:09 UTC (rev 3518)
@@ -53,7 +53,6 @@
{
result = new ObserverMethodImpl<X, T>(method, declaringBean, manager);
}
- result.initialize();
return result;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java 2009-08-16 09:59:51 UTC (rev 3517)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java 2009-08-16 10:20:09 UTC (rev 3518)
@@ -61,7 +61,7 @@
private final Type eventType;
protected BeanManagerImpl manager;
private final Notify notifyType;
- protected final RIBean<?> observerBean;
+ protected final RIBean<?> declaringBean;
protected final MethodInjectionPoint<?, ?> observerMethod;
protected TransactionPhase transactionPhase;
@@ -70,14 +70,14 @@
* (8.5).
*
* @param observer The observer
- * @param observerBean The observer bean
+ * @param declaringBean The observer bean
* @param manager The Web Beans manager
*/
- protected ObserverMethodImpl(final WBMethod<?, ?> observer, final RIBean<?> observerBean, final BeanManagerImpl manager)
+ protected ObserverMethodImpl(final WBMethod<?, ?> observer, final RIBean<?> declaringBean, final BeanManagerImpl manager)
{
this.manager = manager;
- this.observerBean = observerBean;
- this.observerMethod = MethodInjectionPoint.of(observerBean, observer);
+ this.declaringBean = declaringBean;
+ this.observerMethod = MethodInjectionPoint.of(declaringBean, observer);
this.eventType = observerMethod.getAnnotatedParameters(Observes.class).get(0).getBaseType();
this.bindings = new HashSet<Annotation>(Arrays.asList(observerMethod.getAnnotatedParameters(Observes.class).get(0).getBindingsAsArray()));
@@ -94,6 +94,10 @@
{
// Make sure exactly one and only one parameter is annotated with Observes
List<WBParameter<?, ?>> eventObjects = this.observerMethod.getAnnotatedParameters(Observes.class);
+ if (this.notifyType.equals(Notify.IF_EXISTS) && declaringBean.getScopeType().equals(Dependent.class))
+ {
+ throw new DefinitionException(this + " is invalid because it is a conditional observer method, and is declared by a @Dependent scoped bean");
+ }
if (eventObjects.size() > 1)
{
throw new DefinitionException(this + " is invalid because it contains more than event parameter annotated @Observes");
@@ -140,7 +144,7 @@
@SuppressWarnings("unchecked")
public Bean<X> getBean()
{
- return (Bean<X>) observerBean;
+ return (Bean<X>) declaringBean;
}
public Annotation[] getBindingsAsArray()
@@ -201,9 +205,9 @@
// Get the most specialized instance of the component
if (notifyType.equals(Notify.ALWAYS))
{
- creationalContext = manager.createCreationalContext(observerBean);
+ creationalContext = manager.createCreationalContext(declaringBean);
}
- instance = manager.getReference(observerBean, creationalContext);
+ instance = manager.getReference(declaringBean, creationalContext);
if (instance == null)
{
return;
@@ -213,7 +217,7 @@
}
finally
{
- if (creationalContext != null && Dependent.class.equals(observerBean.getScopeType()))
+ if (creationalContext != null && Dependent.class.equals(declaringBean.getScopeType()))
{
creationalContext.release();
}
@@ -235,7 +239,7 @@
{
StringBuilder builder = new StringBuilder();
builder.append("Observer Implementation: \n");
- builder.append(" Observer (Declaring) class: " + observerBean.getBeanClass());
+ builder.append(" Observer (Declaring) class: " + declaringBean.getBeanClass());
builder.append(" Observer method: " + observerMethod);
return builder.toString();
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/dependentIsConditionalObserver/DependentIsConditionalObserverTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/dependentIsConditionalObserver/DependentIsConditionalObserverTest.java 2009-08-16 09:59:51 UTC (rev 3517)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/dependentIsConditionalObserver/DependentIsConditionalObserverTest.java 2009-08-16 10:20:09 UTC (rev 3518)
@@ -14,7 +14,7 @@
public class DependentIsConditionalObserverTest extends AbstractJSR299Test
{
// WBRI-315
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "10.4.4", id = "b")
public void testDependentBeanWithConditionalObserverMethodIsDefinitionError()
{
More information about the weld-commits
mailing list