[webbeans-commits] Webbeans SVN: r361 - in ri/trunk/webbeans-ri/src: test/java/org/jboss/webbeans/test/mock and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Nov 24 05:54:23 EST 2008
Author: nickarls
Date: 2008-11-24 05:54:23 -0500 (Mon, 24 Nov 2008)
New Revision: 361
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java
Log:
stubs for conditional observer support
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-11-24 10:30:52 UTC (rev 360)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-11-24 10:54:23 UTC (rev 361)
@@ -6,6 +6,7 @@
import javax.webbeans.AfterTransactionFailure;
import javax.webbeans.AfterTransactionSuccess;
import javax.webbeans.BeforeTransactionCompletion;
+import javax.webbeans.IfExists;
import javax.webbeans.Observer;
import org.jboss.webbeans.ManagerImpl;
@@ -30,6 +31,7 @@
private final AnnotatedMethod<Object> observerMethod;
private final Class<T> eventType;
private boolean transactional;
+ private boolean conditional;
private ManagerImpl manager;
/**
@@ -50,11 +52,8 @@
this.eventBean = eventBean;
this.observerMethod = observer;
this.eventType = eventType;
- transactional =
- !observerMethod.getAnnotatedParameters(AfterTransactionCompletion.class).isEmpty() ||
- !observerMethod.getAnnotatedParameters(AfterTransactionFailure.class).isEmpty() ||
- !observerMethod.getAnnotatedParameters(AfterTransactionSuccess.class).isEmpty() ||
- !observerMethod.getAnnotatedParameters(BeforeTransactionCompletion.class).isEmpty();
+ transactional = !observerMethod.getAnnotatedParameters(AfterTransactionCompletion.class).isEmpty() || !observerMethod.getAnnotatedParameters(AfterTransactionFailure.class).isEmpty() || !observerMethod.getAnnotatedParameters(AfterTransactionSuccess.class).isEmpty() || !observerMethod.getAnnotatedParameters(BeforeTransactionCompletion.class).isEmpty();
+ conditional = !observerMethod.getAnnotatedParameters(IfExists.class).isEmpty();
}
/*
@@ -76,7 +75,7 @@
public void notify(final T event)
{
// Get the most specialized instance of the component
- Object instance = getInstance();
+ Object instance = getInstance(isConditional());
if (instance != null)
{
// TODO replace event parameter
@@ -88,10 +87,11 @@
/**
* Uses the container to retrieve the most specialized instance of this
* observer.
+ * @param conditional
*
* @return the most specialized instance
*/
- protected Object getInstance()
+ protected Object getInstance(boolean conditional)
{
// Return the most specialized instance of the component
return manager.getInstanceByType(eventBean.getType(), eventBean.getBindingTypes().toArray(new Annotation[0]));
@@ -99,6 +99,11 @@
public boolean isTransactional()
{
- return transactional;
+ return transactional;
}
+
+ public boolean isConditional()
+ {
+ return conditional;
+ }
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java 2008-11-24 10:30:52 UTC (rev 360)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java 2008-11-24 10:54:23 UTC (rev 361)
@@ -22,7 +22,7 @@
}
@Override
- protected final Object getInstance()
+ protected final Object getInstance(boolean conditional)
{
return specializedInstance;
}
More information about the weld-commits
mailing list