[jboss-cvs] jboss-seam/src/main/org/jboss/seam/interceptors ...
Gavin King
gavin.king at jboss.com
Mon Oct 9 04:30:28 EDT 2006
User: gavin
Date: 06/10/09 04:30:28
Added: src/main/org/jboss/seam/interceptors
AsynchronousInterceptor.java
Log:
JBSEAM-377, @Asynchronous and friends
Revision Changes Path
1.1 date: 2006/10/09 08:30:28; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/interceptors/AsynchronousInterceptor.java
Index: AsynchronousInterceptor.java
===================================================================
package org.jboss.seam.interceptors;
import javax.ejb.Timer;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
import org.jboss.seam.annotations.Asynchronous;
import org.jboss.seam.annotations.Interceptor;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Dispatcher;
@Interceptor(around={BijectionInterceptor.class, RemoveInterceptor.class,
ConversationInterceptor.class, EventInterceptor.class,
RollbackInterceptor.class, TransactionInterceptor.class,
ExceptionInterceptor.class, BusinessProcessInterceptor.class,
ManagedEntityIdentityInterceptor.class})
public class AsynchronousInterceptor extends AbstractInterceptor
{
@AroundInvoke
public Object invokeAsynchronouslyIfNecessary(InvocationContext invocation) throws Exception
{
boolean scheduleAsync = invocation.getMethod().isAnnotationPresent(Asynchronous.class) &&
!Contexts.getEventContext().isSet(Dispatcher.EXECUTING_ASYNCHRONOUS_CALL);
if ( scheduleAsync )
{
Timer timer = Dispatcher.instance().schedule(invocation, component);
//if the method returns a Timer, return it to the client
return invocation.getMethod().getReturnType().equals(Timer.class) ? timer : null;
}
else
{
return invocation.proceed();
}
}
}
More information about the jboss-cvs-commits
mailing list