[jboss-cvs] jboss-seam/src/main/org/jboss/seam/async ...
Gavin King
gavin.king at jboss.com
Mon Jun 25 19:59:30 EDT 2007
User: gavin
Date: 07/06/25 19:59:30
Added: src/main/org/jboss/seam/async AsynchronousInterceptor.java
Log:
move builtin interceptors to the packages they relate to
Revision Changes Path
1.1 date: 2007/06/25 23:59:30; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/async/AsynchronousInterceptor.java
Index: AsynchronousInterceptor.java
===================================================================
package org.jboss.seam.async;
import org.jboss.seam.annotations.async.Asynchronous;
import org.jboss.seam.annotations.intercept.AroundInvoke;
import org.jboss.seam.annotations.intercept.Interceptor;
import org.jboss.seam.annotations.intercept.InterceptorType;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.intercept.AbstractInterceptor;
import org.jboss.seam.intercept.InvocationContext;
/**
* Dispatches method calls to @Asynchronous methods
* asynchronously, and returns the "timer" object
* if necessary.
*
* @author Gavin King
*
*/
@Interceptor(stateless=true, type=InterceptorType.CLIENT)
public class AsynchronousInterceptor extends AbstractInterceptor
{
private static final long serialVersionUID = 9194177339867853303L;
@AroundInvoke
public Object aroundInvoke(InvocationContext invocation) throws Exception
{
boolean scheduleAsync = invocation.getMethod().isAnnotationPresent(Asynchronous.class) &&
!Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);
if (scheduleAsync)
{
Dispatcher dispatcher = AbstractDispatcher.instance();
if (dispatcher==null)
{
throw new IllegalStateException("org.jboss.seam.async.dispatcher is not installed in components.xml");
}
Object timer = dispatcher.scheduleInvocation( invocation, getComponent() );
//if the method returns a Timer, return it to the client
return timer!=null && invocation.getMethod().getReturnType().isAssignableFrom( timer.getClass() ) ? timer : null;
}
else
{
return invocation.proceed();
}
}
}
More information about the jboss-cvs-commits
mailing list