Skip to content

Commit

Permalink
More tests and fix for detection of some definition errors in the RI.
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2335 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
drallen committed Apr 7, 2009
1 parent f3ca3b7 commit be390d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
Expand Up @@ -43,6 +43,7 @@
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.util.Names;

/**
* <p>
Expand Down Expand Up @@ -94,8 +95,6 @@ public void initialize()
checkObserverMethod();
}



/**
* Performs validation of the observer method for compliance with the
* specifications.
Expand Down Expand Up @@ -144,6 +143,12 @@ else if (type instanceof WildcardType)
{
throw new DefinitionException(this + " cannot be annotated with @Initializer");
}

// We cannot allow asynchronously invoked conditional observers either
if (this.asynchronous && this.conditional)
{
throw new DefinitionException(this + " cannot be annotated with both @Asynchronously and @IfExists");
}
}

public void notify(final T event)
Expand Down Expand Up @@ -222,7 +227,7 @@ public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("Observer Implementation: \n");
builder.append(" Observer (Declaring) bean: " + observerBean);
builder.append(" Observer (Declaring) class: " + Names.typesToString(observerBean.getTypes()));
builder.append(" Observer method: " + observerMethod);
return builder.toString();
}
Expand Down
Expand Up @@ -104,6 +104,10 @@ private void initTransactionObservationPhase()
if (!observerMethod.getAnnotatedParameters(BeforeTransactionCompletion.class).isEmpty())
{
observationPhases.add(TransactionObservationPhase.BEFORE_COMPLETION);
if (!observerMethod.getAnnotatedParameters(Asynchronously.class).isEmpty())
{
throw new DefinitionException("@BeforeTransactionCompletion cannot be used with @Asynchronously on " + observerMethod);
}
}
if (!observerMethod.getAnnotatedParameters(AfterTransactionCompletion.class).isEmpty())
{
Expand Down Expand Up @@ -148,6 +152,7 @@ private void deferEvent(T event)
{
deferredEvent = new AsynchronousTransactionalEventNotification<T>(event, this);
}

Synchronization synchronization = null;
if (transactionObservationPhase.equals(TransactionObservationPhase.BEFORE_COMPLETION))
{
Expand Down
4 changes: 4 additions & 0 deletions jboss-tck-runner/src/test/resources/log4j.xml
Expand Up @@ -12,6 +12,10 @@
<param name="AcceptOnMatch" value="false" />
<param name="StringToMatch" value="Failure while notifying an observer of event [a]" />
</filter>
<filter class="org.apache.log4j.varia.StringMatchFilter">
<param name="AcceptOnMatch" value="false" />
<param name="StringToMatch" value="Error destroying Request scoped unnamed simple bean org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.Cod" />
</filter>
</appender>

<!-- ############### Embedded EJB3 ################# -->
Expand Down

0 comments on commit be390d7

Please sign in to comment.