Author: dan.j.allen
Date: 2009-06-11 19:30:25 -0400 (Thu, 11 Jun 2009)
New Revision: 11132
Modified:
branches/community/Seam_2_2/src/main/org/jboss/seam/jms/ContextualMessageHandlerRequest.java
Log:
add business process support
Modified:
branches/community/Seam_2_2/src/main/org/jboss/seam/jms/ContextualMessageHandlerRequest.java
===================================================================
---
branches/community/Seam_2_2/src/main/org/jboss/seam/jms/ContextualMessageHandlerRequest.java 2009-06-11
23:30:12 UTC (rev 11131)
+++
branches/community/Seam_2_2/src/main/org/jboss/seam/jms/ContextualMessageHandlerRequest.java 2009-06-11
23:30:25 UTC (rev 11132)
@@ -2,13 +2,18 @@
import java.lang.reflect.ParameterizedType;
+import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;
import org.jboss.seam.Component;
import org.jboss.seam.async.AbstractDispatcher;
+import org.jboss.seam.bpm.BusinessProcess;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
/**
* <p>
@@ -26,6 +31,8 @@
*/
public abstract class ContextualMessageHandlerRequest<T>
{
+ private static transient final LogProvider log =
Logging.getLogProvider(ContextualMessageHandlerRequest.class);
+
private Message message;
private boolean setupRequired = false;
private Object result = null;
@@ -90,6 +97,11 @@
}
Contexts.getEventContext().set(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL,
true);
+ if (Init.instance().isJbpmInstalled())
+ {
+ setupProcessOrTask();
+ }
+
Class<T> delegateClass = getDelegateClass();
if (delegateClass != null)
{
@@ -97,6 +109,37 @@
}
}
+ private void setupProcessOrTask()
+ {
+ try
+ {
+ Long taskId = message.getLongProperty("taskId");
+ if (taskId != null)
+ {
+ BusinessProcess.instance().resumeTask(taskId);
+ return;
+ }
+ }
+ catch (JMSException e)
+ {
+ log.debug("Could not retrieve taskId from message object: " +
e.getMessage());
+ }
+
+ try
+ {
+ Long processId = message.getLongProperty("processId");
+ if (processId != null)
+ {
+ BusinessProcess.instance().resumeProcess(processId);
+ return;
+ }
+ }
+ catch (JMSException e)
+ {
+ log.debug("Could not retrieve processId from message object: " +
e.getMessage());
+ }
+ }
+
private void cleanup()
{
Contexts.getEventContext().remove(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);