[jboss-cvs] jboss-seam/src/main/org/jboss/seam/async ...
Gavin King
gavin.king at jboss.com
Wed Jun 20 11:53:32 EDT 2007
User: gavin
Date: 07/06/20 11:53:32
Modified: src/main/org/jboss/seam/async AbstractDispatcher.java
QuartzDispatcher.java ThreadPoolDispatcher.java
Added: src/main/org/jboss/seam/async Asynchronous.java
AsynchronousEvent.java AsynchronousInvocation.java
Log:
nested->toplevel
get rid of client-side conversation support
Revision Changes Path
1.3 +0 -120 jboss-seam/src/main/org/jboss/seam/async/AbstractDispatcher.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractDispatcher.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/async/AbstractDispatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- AbstractDispatcher.java 20 Jun 2007 03:25:08 -0000 1.2
+++ AbstractDispatcher.java 20 Jun 2007 15:53:32 -0000 1.3
@@ -1,8 +1,6 @@
package org.jboss.seam.async;
-import java.io.Serializable;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
import java.util.Date;
import org.jboss.seam.Component;
@@ -11,13 +9,8 @@
import org.jboss.seam.annotations.timer.Expiration;
import org.jboss.seam.annotations.timer.FinalExpiration;
import org.jboss.seam.annotations.timer.IntervalDuration;
-import org.jboss.seam.bpm.BusinessProcess;
import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.contexts.Lifecycle;
-import org.jboss.seam.core.Events;
-import org.jboss.seam.core.Init;
import org.jboss.seam.intercept.InvocationContext;
-import org.jboss.seam.util.Reflections;
/**
* Abstract Dispatcher implementation
@@ -39,119 +32,6 @@
return (Dispatcher) Component.getInstance("org.jboss.seam.async.dispatcher");
}
- public static abstract class Asynchronous implements Serializable
- {
- static final long serialVersionUID = -551286304424595765L;
-
- private Long processId;
- private Long taskId;
-
- protected Asynchronous()
- {
- if ( Init.instance().isJbpmInstalled() )
- {
- BusinessProcess businessProcess = BusinessProcess.instance();
- processId = businessProcess.getProcessId();
- taskId = BusinessProcess.instance().getTaskId();
- }
- }
-
- public void execute(Object timer)
- {
-
- //TODO: shouldn't this take place in a Seam context anyway??!? (bug in EJB3?)
-
- Lifecycle.beginCall();
- Contexts.getEventContext().set(EXECUTING_ASYNCHRONOUS_CALL, true);
- try
- {
- if (taskId!=null)
- {
- BusinessProcess.instance().resumeTask(taskId);
- }
- else if (processId!=null)
- {
- BusinessProcess.instance().resumeProcess(processId);
- }
-
- Contexts.getEventContext().set("timer", timer);
-
- call();
-
- }
- finally
- {
- Contexts.getEventContext().remove(EXECUTING_ASYNCHRONOUS_CALL);
- Lifecycle.endCall();
- }
-
- }
-
- protected abstract void call();
- }
-
- protected static class AsynchronousInvocation extends Asynchronous
- {
- static final long serialVersionUID = 7426196491669891310L;
-
- private String methodName;
- private Class[] argTypes;
- private Object[] args;
- private String componentName;
-
- public AsynchronousInvocation(Method method, String componentName, Object[] args)
- {
- this.methodName = method.getName();
- this.argTypes = method.getParameterTypes();
- this.args = args==null ? new Object[0] : args;
- this.componentName = componentName;
- }
-
- public AsynchronousInvocation(InvocationContext invocation, Component component)
- {
- this( invocation.getMethod(), component.getName(), invocation.getParameters() );
- }
-
- @Override
- protected void call()
- {
- Object target = Component.getInstance(componentName);
-
- Method method;
- try
- {
- method = target.getClass().getMethod(methodName, argTypes);
- }
- catch (NoSuchMethodException nsme)
- {
- throw new IllegalStateException(nsme);
- }
-
- Reflections.invokeAndWrap(method, target, args);
- }
- }
-
- protected static class AsynchronousEvent extends Asynchronous
- {
- static final long serialVersionUID = 2074586442931427819L;
-
- private String type;
- private Object[] parameters;
-
- public AsynchronousEvent(String type, Object[] parameters)
- {
- this.type = type;
- this.parameters = parameters;
- }
-
- @Override
- public void call()
- {
- Events.instance().raiseEvent(type, parameters);
- }
-
- }
-
// TODO: Throw exception when there are multiple interval params
// Make use of finalExpiration
// Make use of NthBusinessDay
1.3 +2 -2 jboss-seam/src/main/org/jboss/seam/async/QuartzDispatcher.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: QuartzDispatcher.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/async/QuartzDispatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- QuartzDispatcher.java 19 Jun 2007 20:08:12 -0000 1.2
+++ QuartzDispatcher.java 20 Jun 2007 15:53:32 -0000 1.3
@@ -227,7 +227,7 @@
public static class QuartzJob implements Job
{
- private AbstractDispatcher.Asynchronous async;
+ private Asynchronous async;
public QuartzJob() { }
@@ -236,7 +236,7 @@
{
log.info("Start executing Quartz job");
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
- async = (AbstractDispatcher.Asynchronous)dataMap.get("async");
+ async = (Asynchronous)dataMap.get("async");
async.execute(null);
log.info("End executing Quartz job");
}
1.3 +1 -1 jboss-seam/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ThreadPoolDispatcher.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ThreadPoolDispatcher.java 19 Jun 2007 20:08:12 -0000 1.2
+++ ThreadPoolDispatcher.java 20 Jun 2007 15:53:32 -0000 1.3
@@ -102,7 +102,7 @@
static class RunnableAsynchronous implements Runnable
{
- private AbstractDispatcher.Asynchronous async;
+ private Asynchronous async;
RunnableAsynchronous(Asynchronous async)
{
1.1 date: 2007/06/20 15:53:32; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/async/Asynchronous.java
Index: Asynchronous.java
===================================================================
package org.jboss.seam.async;
import java.io.Serializable;
import org.jboss.seam.bpm.BusinessProcess;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
import org.jboss.seam.core.Init;
public abstract class Asynchronous implements Serializable
{
static final long serialVersionUID = -551286304424595765L;
private Long processId;
private Long taskId;
protected Asynchronous()
{
if ( Init.instance().isJbpmInstalled() )
{
BusinessProcess businessProcess = BusinessProcess.instance();
processId = businessProcess.getProcessId();
taskId = BusinessProcess.instance().getTaskId();
}
}
public void execute(Object timer)
{
//TODO: shouldn't this take place in a Seam context anyway??!? (bug in EJB3?)
Lifecycle.beginCall();
Contexts.getEventContext().set(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL, true);
try
{
if (taskId!=null)
{
BusinessProcess.instance().resumeTask(taskId);
}
else if (processId!=null)
{
BusinessProcess.instance().resumeProcess(processId);
}
Contexts.getEventContext().set("timer", timer);
call();
}
finally
{
Contexts.getEventContext().remove(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);
Lifecycle.endCall();
}
}
protected abstract void call();
}
1.1 date: 2007/06/20 15:53:32; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/async/AsynchronousEvent.java
Index: AsynchronousEvent.java
===================================================================
package org.jboss.seam.async;
import org.jboss.seam.core.Events;
public class AsynchronousEvent extends Asynchronous
{
static final long serialVersionUID = 2074586442931427819L;
private String type;
private Object[] parameters;
public AsynchronousEvent(String type, Object[] parameters)
{
this.type = type;
this.parameters = parameters;
}
@Override
public void call()
{
Events.instance().raiseEvent(type, parameters);
}
}
1.1 date: 2007/06/20 15:53:32; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/async/AsynchronousInvocation.java
Index: AsynchronousInvocation.java
===================================================================
package org.jboss.seam.async;
import java.lang.reflect.Method;
import org.jboss.seam.Component;
import org.jboss.seam.intercept.InvocationContext;
import org.jboss.seam.util.Reflections;
public class AsynchronousInvocation extends Asynchronous
{
static final long serialVersionUID = 7426196491669891310L;
private String methodName;
private Class[] argTypes;
private Object[] args;
private String componentName;
public AsynchronousInvocation(Method method, String componentName, Object[] args)
{
this.methodName = method.getName();
this.argTypes = method.getParameterTypes();
this.args = args==null ? new Object[0] : args;
this.componentName = componentName;
}
public AsynchronousInvocation(InvocationContext invocation, Component component)
{
this( invocation.getMethod(), component.getName(), invocation.getParameters() );
}
@Override
protected void call()
{
Object target = Component.getInstance(componentName);
Method method;
try
{
method = target.getClass().getMethod(methodName, argTypes);
}
catch (NoSuchMethodException nsme)
{
throw new IllegalStateException(nsme);
}
Reflections.invokeAndWrap(method, target, args);
}
}
More information about the jboss-cvs-commits
mailing list