[jbpm-commits] JBoss JBPM SVN: r1601 - in api/trunk: modules/api/src/main/java/org/jboss/bpm/client and 15 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Jul 13 09:29:03 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-07-13 09:29:02 -0400 (Sun, 13 Jul 2008)
New Revision: 1601
Added:
api/trunk/docs/VioletUML/APIExecution.png
api/trunk/docs/VioletUML/APIExecution.seq.violet
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Executable.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutionHandler.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowHandler.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Handler.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SignalHandler.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/MockEngineTestCase.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/
api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/
api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java
Removed:
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractToken.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/
api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java
Modified:
api/trunk/docs/VioletUML/APIModel.class.violet
api/trunk/docs/VioletUML/APIModel.png
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractEvent.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractGateway.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractSubProcess.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractTask.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ItermediateEvent.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java
api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java
api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/sequence/BasicSequenceTest.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/BasicTaskTest.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java
Log:
Provide an implementation of an ExecutionManager
Copied: api/trunk/docs/VioletUML/APIExecution.png (from rev 1599, api/branches/tdiesler/docs/VioletUML/APIExecution.png)
===================================================================
(Binary files differ)
Copied: api/trunk/docs/VioletUML/APIExecution.seq.violet (from rev 1599, api/branches/tdiesler/docs/VioletUML/APIExecution.seq.violet)
===================================================================
--- api/trunk/docs/VioletUML/APIExecution.seq.violet (rev 0)
+++ api/trunk/docs/VioletUML/APIExecution.seq.violet 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,507 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<java version="1.6.0_06" class="java.beans.XMLDecoder">
+ <object class="com.horstmann.violet.SequenceDiagramGraph">
+ <void method="addNode">
+ <object id="LifelineNode0" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>Process</string>
+ </void>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>37.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object id="ActivationBarNode0" class="com.horstmann.violet.CallNode">
+ <void method="addChild">
+ <object id="ActivationBarNode1" class="com.horstmann.violet.CallNode">
+ <void method="addChild">
+ <object id="ActivationBarNode2" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object id="LifelineNode1" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>Token</string>
+ </void>
+ </void>
+ </object>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode3" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object idref="LifelineNode1"/>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode4" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object idref="LifelineNode1"/>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode5" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object id="LifelineNode2" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>Flow
+</string>
+ </void>
+ </void>
+ </object>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode6" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object id="LifelineNode3" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>FlowObject</string>
+ </void>
+ </void>
+ </object>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode7" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object id="LifelineNode4" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>Execution
+Handler</string>
+ </void>
+ </void>
+ </object>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode8" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object idref="LifelineNode3"/>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode9" class="com.horstmann.violet.CallNode">
+ <void method="addChild">
+ <object id="ActivationBarNode10" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object idref="LifelineNode1"/>
+ </void>
+ </object>
+ </void>
+ <void property="implicitParameter">
+ <object id="LifelineNode5" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>FlowHandler</string>
+ </void>
+ </void>
+ </object>
+ </void>
+ </object>
+ </void>
+ <void method="addChild">
+ <object id="ActivationBarNode11" class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object idref="LifelineNode1"/>
+ </void>
+ <void property="openBottom">
+ <boolean>true</boolean>
+ </void>
+ </object>
+ </void>
+ <void property="implicitParameter">
+ <object id="LifelineNode6" class="com.horstmann.violet.ImplicitParameterNode">
+ <void property="name">
+ <void property="text">
+ <string>Execution
+Manager</string>
+ </void>
+ </void>
+ </object>
+ </void>
+ <void property="openBottom">
+ <boolean>true</boolean>
+ </void>
+ </object>
+ </void>
+ <void property="implicitParameter">
+ <object idref="LifelineNode0"/>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>69.0</double>
+ <double>80.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="LifelineNode6"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>230.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="LifelineNode3"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>561.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="LifelineNode5"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>782.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="LifelineNode1"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>343.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode1"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>262.0</double>
+ <double>103.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode4"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>375.0</double>
+ <double>232.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="LifelineNode2"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>455.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode5"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>487.0</double>
+ <double>285.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode8"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>593.0</double>
+ <double>444.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode9"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>814.0</double>
+ <double>497.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode10"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>375.0</double>
+ <double>520.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode11"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>375.0</double>
+ <double>593.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object id="NoteNode0" class="com.horstmann.violet.NoteNode">
+ <void property="text">
+ <void property="text">
+ <string>The FlowHandler adds all
+active outgoing Flows to the
+FlowQueue in the Token</string>
+ </void>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>831.0</double>
+ <double>352.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object id="PointNode0" class="com.horstmann.violet.PointNode">
+ <void id="Rectangle2D$Double0" property="bounds">
+ <void method="setRect">
+ <double>822.0</double>
+ <double>521.0</double>
+ <double>0.0</double>
+ <double>0.0</double>
+ </void>
+ </void>
+ <void property="bounds">
+ <object idref="Rectangle2D$Double0"/>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>822.0</double>
+ <double>521.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object id="PointNode1" class="com.horstmann.violet.PointNode">
+ <void id="Rectangle2D$Double1" property="bounds">
+ <void method="setRect">
+ <double>270.0</double>
+ <double>593.0</double>
+ <double>0.0</double>
+ <double>0.0</double>
+ </void>
+ </void>
+ <void property="bounds">
+ <object idref="Rectangle2D$Double1"/>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>270.0</double>
+ <double>593.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object id="NoteNode1" class="com.horstmann.violet.NoteNode">
+ <void property="text">
+ <void property="text">
+ <string>The ExecutionManager
+executes Flows while
+there are any in the
+FlowQueue.</string>
+ </void>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>96.0</double>
+ <double>429.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="LifelineNode4"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>670.0</double>
+ <double>0.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode6"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>593.0</double>
+ <double>338.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode7"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>702.0</double>
+ <double>391.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode2"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>375.0</double>
+ <double>126.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object class="com.horstmann.violet.CallNode">
+ <void property="implicitParameter">
+ <object idref="LifelineNode0"/>
+ </void>
+ </object>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>69.0</double>
+ <double>753.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="addNode">
+ <object idref="ActivationBarNode3"/>
+ <object class="java.awt.geom.Point2D$Double">
+ <void method="setLocation">
+ <double>375.0</double>
+ <double>179.0</double>
+ </void>
+ </object>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>startProcess</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode0"/>
+ <object idref="ActivationBarNode1"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>getHeadFlow</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode4"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>getTarget</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode5"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>getFlowHandler</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode8"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>transfer(tok)</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode9"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>addTailFlows</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode9"/>
+ <object idref="ActivationBarNode10"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>getHeadFlow</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode11"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.NoteEdge"/>
+ <object idref="NoteNode0"/>
+ <object idref="PointNode0"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.NoteEdge"/>
+ <object idref="NoteNode1"/>
+ <object idref="PointNode1"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>getExecutionHandler</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode6"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>execute(tok)</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode7"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>createToken</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode2"/>
+ </void>
+ <void method="connect">
+ <object class="com.horstmann.violet.CallEdge">
+ <void property="middleLabel">
+ <string>addTailFlow</string>
+ </void>
+ </object>
+ <object idref="ActivationBarNode1"/>
+ <object idref="ActivationBarNode3"/>
+ </void>
+ </object>
+</java>
Modified: api/trunk/docs/VioletUML/APIModel.class.violet
===================================================================
--- api/trunk/docs/VioletUML/APIModel.class.violet 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/docs/VioletUML/APIModel.class.violet 2008-07-13 13:29:02 UTC (rev 1601)
@@ -74,6 +74,11 @@
</void>
<void method="addNode">
<object id="ClassNode4" class="com.horstmann.violet.ClassNode">
+ <void property="methods">
+ <void property="text">
+ <string>execute</string>
+ </void>
+ </void>
<void property="name">
<void property="text">
<string>Event</string>
@@ -179,6 +184,11 @@
outFlows</string>
</void>
</void>
+ <void property="methods">
+ <void property="text">
+ <string>execute</string>
+ </void>
+ </void>
<void property="name">
<void property="text">
<string>Gateway
@@ -202,6 +212,11 @@
outFlow</string>
</void>
</void>
+ <void property="methods">
+ <void property="text">
+ <string>execute</string>
+ </void>
+ </void>
<void property="name">
<void property="text">
<string>SubProcess
@@ -224,6 +239,11 @@
outFlow</string>
</void>
</void>
+ <void property="methods">
+ <void property="text">
+ <string>execute</string>
+ </void>
+ </void>
<void property="name">
<void property="text">
<string>Task</string>
Modified: api/trunk/docs/VioletUML/APIModel.png
===================================================================
(Binary files differ)
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,35 +23,26 @@
// $Id$
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.NotImplementedException;
-import org.jboss.bpm.client.internal.InitialToken;
-import org.jboss.bpm.model.EndEvent;
-import org.jboss.bpm.model.ExecutableFlowObject;
+import org.jboss.bpm.model.Executable;
+import org.jboss.bpm.model.ExecutionHandler;
+import org.jboss.bpm.model.FlowHandler;
import org.jboss.bpm.model.FlowObject;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Result;
import org.jboss.bpm.model.Signal;
+import org.jboss.bpm.model.SignalHandler;
import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.Token;
/**
- * The process manager is the entry point to create, find and otherwise manage processes.
+ * The ExecutionManager executes processes
*
* @author thomas.diesler at jboss.com
* @since 18-Jun-2008
*/
public abstract class ExecutionManager
{
- // provide logging
- private static final Log log = LogFactory.getLog(ExecutionManager.class);
-
// Injected through the MC
protected ProcessEngine engine;
@@ -61,6 +52,14 @@
}
/**
+ * Start the Process and return a Future
+ * @param proc The Process to start
+ * @param att The Attachments in the ExecutionContext
+ * @return The Future from which to obtain the process result
+ */
+ public abstract Future<Result> startProcess(Process proc, Attachments att);
+
+ /**
* Locate the signal manager
*/
public static ExecutionManager locateExecutionManager()
@@ -68,101 +67,38 @@
ProcessEngine engine = ProcessEngineLocator.locateProcessEngine();
return engine.getExecutionManager();
}
-
- public Future<Result> startProcess(Process proc, Attachments att)
+
+ protected ExecutionHandler getExecutionHandler(FlowObject target)
{
- throwSignal(new Signal(proc, Signal.Type.ENTER_PROCESS));
- try
- {
- FlowObject fo = proc.getStartEvent();
- ExecutableFlowObject exfo = getExecutable(fo);
- Token token = new InitialToken(proc, att);
-
- boolean hasEnded = false;
- while(hasEnded == false)
- {
- try
- {
- throwSignal(exfo.getEnterSignal());
- exfo.execute(token);
- }
- finally
- {
- throwSignal(exfo.getExitSignal());
- }
- }
- }
- finally
- {
- throwSignal(new Signal(proc, Signal.Type.EXIT_PROCESS));
- }
- return new ResultFuture(proc);
+ Executable exfo = getExecutable(target);
+ ExecutionHandler handler = exfo.getExecutionHandler();
+ return handler != null ? handler : exfo.getDefaultExecutionHandler();
}
- protected ExecutableFlowObject getExecutable(FlowObject fo)
+ protected SignalHandler getSignalHandler(FlowObject target)
{
- if (fo instanceof ExecutableFlowObject == false)
- throw new IllegalStateException("Flow object is not executable: " + fo);
-
- return (ExecutableFlowObject)fo;
+ Executable exfo = getExecutable(target);
+ SignalHandler handler = exfo.getSignalHandler();
+ return handler != null ? handler : exfo.getDefaultSignalHandler();
}
+ protected FlowHandler getFlowHandler(FlowObject target)
+ {
+ Executable exfo = getExecutable(target);
+ FlowHandler handler = exfo.getFlowHandler();
+ return handler != null ? handler : exfo.getDefaultFlowHandler();
+ }
+
protected void throwSignal(Signal signal)
{
SignalManager sm = SignalManager.locateSignalManager();
sm.throwSignal(signal);
}
-
- public class ResultFuture implements Future<Result>
- {
- private Result result;
- private Process proc;
- public ResultFuture(Process proc)
- {
- this.proc = proc;
- }
-
- public boolean cancel(boolean mayInterruptIfRunning)
- {
- throw new NotImplementedException();
- }
-
- public Result get() throws InterruptedException, ExecutionException
- {
- return getResult();
- }
-
- public Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- {
- throw new NotImplementedException();
- }
-
- public boolean isCancelled()
- {
- return false;
- }
-
- public boolean isDone()
- {
- boolean isDone = getResult() != null;
- return isDone;
- }
-
- private Result getResult()
- {
- if (result == null)
- {
- for (EndEvent aux : proc.getEndEvents())
- {
- result = aux.getResult();
- if (result != null)
- {
- break;
- }
- }
- }
- return result;
- }
+ private Executable getExecutable(FlowObject fo)
+ {
+ if (fo instanceof Executable == false)
+ throw new IllegalStateException("Flow object is not executable: " + fo);
+ return (Executable)fo;
}
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -47,7 +47,7 @@
{
// provide logging
private static final Log log = LogFactory.getLog(ProcessManager.class);
-
+
// Injected through the MC
protected ProcessEngine engine;
// The set of process definitions
@@ -58,7 +58,9 @@
{
}
- /* Get the associated process engine */
+ /**
+ * Get the associated process engine
+ */
public ProcessEngine getProcessEngine()
{
if (engine == null)
@@ -67,15 +69,17 @@
return engine;
}
- /* Locate the process definition manager */
+ /**
+ * Locate the process definition manager
+ */
public static ProcessManager locateProcessManager()
{
ProcessEngine engine = ProcessEngineLocator.locateProcessEngine();
return engine.getProcessManager();
}
- /*
- * Create a process defintion from a XML string in one of the supported formats
+ /**
+ * Create a Process from a XML string in one of the supported formats
*/
public final Process createProcess(String procDescriptor)
{
@@ -84,15 +88,12 @@
throw new EngineShutdownException("Cannot create new Process while engine is shutting down");
Process proc = createProcessOverride(procDescriptor);
- proc.initialize();
-
- marshallProcess(proc);
-
+ registerProcess(proc);
return proc;
}
- /*
- * Create a process defintion from an URL to a XML descritor in one of the supported formats
+ /**
+ * Create a Process from an URL to a XML descritor in one of the supported formats
*/
public final Process createProcess(URL procURL) throws IOException
{
@@ -101,48 +102,30 @@
throw new EngineShutdownException("Cannot create new Process while engine is shutting down");
Process proc = createProcessOverride(procURL);
- proc.initialize();
-
- marshallProcess(proc);
-
+ registerProcess(proc);
return proc;
}
/**
- * Override to implement process definition creation
+ * Override to implement Process creation
*/
- protected abstract Process createProcessOverride(String procDescriptor);
+ protected abstract Process createProcessOverride(String pXML);
- private void marshallProcess(Process proc)
- {
- try
- {
- File file = new File("target/" + proc.getName() + ".xml").getCanonicalFile();
- ProcessMarshaller marshaller = new ProcessMarshaller();
- marshaller.marshallProcess(proc, new FileWriter(file));
- log.info("Generated: " + file);
- }
- catch (Exception ex)
- {
- log.error("Cannot marshall: " + proc);
- }
- }
-
- /*
- * Override to implement process definition creation
+ /**
+ * Override to implement Process creation
*/
- protected abstract Process createProcessOverride(URL pdURL) throws IOException;
+ protected abstract Process createProcessOverride(URL pURL) throws IOException;
- /*
- * Get the set of registered process definitions
+ /**
+ * Get the set of registered Processes
*/
public Set<Process> getProcesses()
{
return Collections.unmodifiableSet(procs);
}
- /*
- * Find a process definition for a given name
+ /**
+ * Find a Process for a given name
*
* @return null if the process definition is not defined
*/
@@ -160,18 +143,39 @@
return proc;
}
- /*
- * Remove a process definition and all its associated process instances
+ /**
+ * Register a Process
*/
+ public final boolean registerProcess(Process proc)
+ {
+ // Only initialize if this has not already been done
+ if (proc.getProcessState() == Process.ProcessState.CREATED)
+ proc.initialize();
+
+ marshallProcess(proc);
+ return procs.add(proc);
+ }
+
+ /**
+ * Remove a Process
+ */
public void removeProcess(Process proc)
{
- // Remove the preocess definition
procs.remove(proc.getName());
}
- // Add a process definition
- protected void addProcess(Process proc)
+ private void marshallProcess(Process proc)
{
- procs.add(proc);
+ try
+ {
+ File file = new File("target/" + proc.getName() + ".xml").getCanonicalFile();
+ ProcessMarshaller marshaller = new ProcessMarshaller();
+ marshaller.marshallProcess(proc, new FileWriter(file));
+ log.info("Generated: " + file);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot marshall: " + proc);
+ }
}
}
\ No newline at end of file
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.client.internal;
+
+// $Id$
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.client.ExecutionManager;
+import org.jboss.bpm.client.ProcessEngine;
+import org.jboss.bpm.model.EndEvent;
+import org.jboss.bpm.model.ExecutionHandler;
+import org.jboss.bpm.model.Flow;
+import org.jboss.bpm.model.FlowHandler;
+import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Result;
+import org.jboss.bpm.model.SequenceFlow;
+import org.jboss.bpm.model.Signal;
+import org.jboss.bpm.model.SignalHandler;
+import org.jboss.bpm.model.StartEvent;
+import org.jboss.bpm.runtime.Attachments;
+import org.jboss.bpm.runtime.Token;
+
+/**
+ * The process manager is the entry point to create, find and otherwise manage processes.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class ExecutionManagerImpl extends ExecutionManager
+{
+ // provide logging
+ private static final Log log = LogFactory.getLog(ExecutionManager.class);
+
+ public void setProcessEngine(ProcessEngine engine)
+ {
+ this.engine = engine;
+ }
+
+ @Override
+ public Future<Result> startProcess(Process proc, Attachments att)
+ {
+ throwSignal(new Signal(proc, Signal.Type.ENTER_PROCESS));
+ try
+ {
+ Token token = new Token(proc, att);
+ StartEvent start = proc.getStartEvent();
+ token.addTailFlow(new InitialFlow(start));
+
+ while (token.peekHeadFlow() != null)
+ {
+ // Peek the head flow
+ Flow flow = token.peekHeadFlow();
+
+ // Get the target and its handlers
+ FlowObject target = flow.getTarget();
+ ExecutionHandler exHandler = getExecutionHandler(target);
+ SignalHandler sigHandler = getSignalHandler(target);
+ FlowHandler flowHandler = getFlowHandler(target);
+
+ // Execute the FlowObject's ExecutionHandler
+ try
+ {
+ throwSignal(sigHandler.getEnterSignal());
+ exHandler.execute(token);
+ }
+ finally
+ {
+ throwSignal(sigHandler.getExitSignal());
+ }
+
+ // Remove the head flow
+ token.removeHeadFlow();
+
+ // Transfer the token to the FlowHandler
+ flowHandler.transfer(token);
+ }
+ }
+ finally
+ {
+ throwSignal(new Signal(proc, Signal.Type.EXIT_PROCESS));
+ }
+ return new ResultFuture(proc);
+ }
+
+ /**
+ * The initial flow 'to' the StartEvent
+ */
+ class InitialFlow extends SequenceFlow
+ {
+ InitialFlow(StartEvent start)
+ {
+ setTarget(start);
+ }
+ }
+
+ /**
+ * A basic implementation of a Future
+ */
+ class ResultFuture implements Future<Result>
+ {
+ private Result result;
+ private Process proc;
+
+ public ResultFuture(Process proc)
+ {
+ this.proc = proc;
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Result get() throws InterruptedException, ExecutionException
+ {
+ return getResult();
+ }
+
+ public Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+ {
+ throw new NotImplementedException();
+ }
+
+ public boolean isCancelled()
+ {
+ return false;
+ }
+
+ public boolean isDone()
+ {
+ boolean isDone = getResult() != null;
+ return isDone;
+ }
+
+ private Result getResult()
+ {
+ if (result == null)
+ {
+ for (EndEvent aux : proc.getEndEvents())
+ {
+ result = aux.getResult();
+ if (result != null)
+ {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
Deleted: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.client.internal;
-
-// $Id$
-
-import org.jboss.bpm.model.Process;
-import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.BasicAttachments;
-import org.jboss.bpm.runtime.ExecutionContext;
-import org.jboss.bpm.runtime.Token;
-
-/**
- * An initial token
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public class InitialToken implements Token
-{
- private Process proc;
- private ExecutionContext context;
-
- public InitialToken(Process proc, Attachments att)
- {
- this.proc = proc;
- this.context = new InitialContext(att);
- }
-
- public Process getProcess()
- {
- return proc;
- }
-
- public ExecutionContext getExecutionContext()
- {
- return context;
- }
-
- static class InitialContext extends BasicAttachments implements ExecutionContext
- {
- InitialContext(Attachments att)
- {
- super(att);
- }
- }
-}
\ No newline at end of file
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.client.internal;
+
+// $Id$
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.xml.bind.JAXBException;
+
+import org.jboss.bpm.InvalidProcessException;
+import org.jboss.bpm.client.ProcessEngine;
+import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.util.ProcessUnmarshaller;
+
+/**
+ * The process manager is the entry point to create, find and otherwise manage processes.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class ProcessManagerImpl extends ProcessManager
+{
+ public void setProcessEngine(ProcessEngine engine)
+ {
+ this.engine = engine;
+ }
+
+ /**
+ * Override to implement process definition creation
+ */
+ public Process createProcessOverride(String pXML)
+ {
+ try
+ {
+ ProcessUnmarshaller unmarschaller = new ProcessUnmarshaller();
+ Process proc = unmarschaller.unmarshallProcess(new StringReader(pXML));
+ return proc;
+ }
+ catch (JAXBException ex)
+ {
+ throw new InvalidProcessException("Cannot unmarschall: " + pXML, ex);
+ }
+ }
+
+ /**
+ * Override to implement process definition creation
+ */
+ public Process createProcessOverride(URL pURL) throws IOException
+ {
+ try
+ {
+ ProcessUnmarshaller unmarschaller = new ProcessUnmarshaller();
+ Process proc = unmarschaller.unmarshallProcess(new InputStreamReader(pURL.openStream()));
+ return proc;
+ }
+ catch (JAXBException ex)
+ {
+ throw new InvalidProcessException("Cannot unmarschall: " + pURL, ex);
+ }
+ }
+}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractEvent.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractEvent.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -21,6 +21,7 @@
*/
package org.jboss.bpm.model;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@@ -37,4 +38,58 @@
@XmlType(name="AbstractEvent")
abstract class AbstractEvent extends FlowObject
{
+ protected ExecutionHandler executionHandler;
+ protected FlowHandler flowHandler;
+ protected SignalHandler signalHandler;
+
+ /**
+ * Get the ExecutionHandler for this Event
+ */
+ public ExecutionHandler getExecutionHandler()
+ {
+ return executionHandler;
+ }
+
+ /**
+ * Set the ExecutionHandler for this Event
+ */
+ @XmlElement(name = "execution-handler", required = false)
+ protected void setExecutionHandler(ExecutionHandler executionHandler)
+ {
+ this.executionHandler = executionHandler;
+ }
+
+ /**
+ * Get the FlowHandler for this Event
+ */
+ public FlowHandler getFlowHandler()
+ {
+ return flowHandler;
+ }
+
+ /**
+ * Set the FlowHandler for this Event
+ */
+ @XmlElement(name = "flow-handler", required = false)
+ protected void setFlowHandler(FlowHandler flowHandler)
+ {
+ this.flowHandler = flowHandler;
+ }
+
+ /**
+ * Get the SignalHandler for this Event
+ */
+ public SignalHandler getSignalHandler()
+ {
+ return signalHandler;
+ }
+
+ /**
+ * Set the SignalHandler for this Event
+ */
+ @XmlElement(name = "signal-handler", required = false)
+ protected void setSignalHandler(SignalHandler signalHandler)
+ {
+ this.signalHandler = signalHandler;
+ }
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractGateway.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractGateway.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractGateway.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -42,6 +42,9 @@
abstract class AbstractGateway extends FlowObject implements NamedFlowObject, MultipleOutFlowSupport, MultipleInFlowSupport
{
private String name;
+ protected ExecutionHandler executionHandler;
+ protected FlowHandler flowHandler;
+ protected SignalHandler signalHandler;
@XmlElements( {
@XmlElement(name = "sequence", type = SequenceFlow.class),
@@ -94,4 +97,55 @@
{
this.outFlows = outFlow;
}
+
+ /**
+ * Get the ExecutionHandler for this Event
+ */
+ public ExecutionHandler getExecutionHandler()
+ {
+ return executionHandler;
+ }
+
+ /**
+ * Set the ExecutionHandler for this Event
+ */
+ @XmlElement(name = "execution-handler")
+ protected void setExecutionHandler(ExecutionHandler executionHandler)
+ {
+ this.executionHandler = executionHandler;
+ }
+
+ /**
+ * Get the FlowHandler for this Event
+ */
+ public FlowHandler getFlowHandler()
+ {
+ return flowHandler;
+ }
+
+ /**
+ * Set the FlowHandler for this Event
+ */
+ @XmlElement(name = "flow-handler")
+ protected void setFlowHandler(FlowHandler flowHandler)
+ {
+ this.flowHandler = flowHandler;
+ }
+
+ /**
+ * Get the SignalHandler for this Event
+ */
+ public SignalHandler getSignalHandler()
+ {
+ return signalHandler;
+ }
+
+ /**
+ * Set the SignalHandler for this Event
+ */
+ @XmlElement(name = "signal-handler")
+ protected void setSignalHandler(SignalHandler signalHandler)
+ {
+ this.signalHandler = signalHandler;
+ }
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractSubProcess.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractSubProcess.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractSubProcess.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -37,6 +37,10 @@
@XmlType(name="AbstractSubProcess")
abstract class AbstractSubProcess extends Process implements SingleOutFlowSupport
{
+ protected ExecutionHandler executionHandler;
+ protected FlowHandler flowHandler;
+ protected SignalHandler signalHandler;
+
@XmlElements( {
@XmlElement(name = "sequence", type = SequenceFlow.class),
@XmlElement(name = "message", type = MessageFlow.class)
@@ -76,4 +80,55 @@
{
this.outFlow = outFlow;
}
+
+ /**
+ * Get the ExecutionHandler for this Event
+ */
+ public ExecutionHandler getExecutionHandler()
+ {
+ return executionHandler;
+ }
+
+ /**
+ * Set the ExecutionHandler for this Event
+ */
+ @XmlElement(name = "execution-handler")
+ protected void setExecutionHandler(ExecutionHandler executionHandler)
+ {
+ this.executionHandler = executionHandler;
+ }
+
+ /**
+ * Get the FlowHandler for this Event
+ */
+ public FlowHandler getFlowHandler()
+ {
+ return flowHandler;
+ }
+
+ /**
+ * Set the FlowHandler for this Event
+ */
+ @XmlElement(name = "flow-handler")
+ protected void setFlowHandler(FlowHandler flowHandler)
+ {
+ this.flowHandler = flowHandler;
+ }
+
+ /**
+ * Get the SignalHandler for this Event
+ */
+ public SignalHandler getSignalHandler()
+ {
+ return signalHandler;
+ }
+
+ /**
+ * Set the SignalHandler for this Event
+ */
+ @XmlElement(name = "signal-handler")
+ protected void setSignalHandler(SignalHandler signalHandler)
+ {
+ this.signalHandler = signalHandler;
+ }
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractTask.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractTask.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/AbstractTask.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -40,6 +40,10 @@
@XmlType(name = "AbstractTask")
abstract class AbstractTask extends Activity implements SingleOutFlowSupport
{
+ protected ExecutionHandler executionHandler;
+ protected FlowHandler flowHandler;
+ protected SignalHandler signalHandler;
+
@XmlElements( {
@XmlElement(name = "sequence", type = SequenceFlow.class),
@XmlElement(name = "message", type = MessageFlow.class)
@@ -77,4 +81,55 @@
{
this.outFlow = outFlow;
}
+
+ /**
+ * Get the ExecutionHandler for this Event
+ */
+ public ExecutionHandler getExecutionHandler()
+ {
+ return executionHandler;
+ }
+
+ /**
+ * Set the ExecutionHandler for this Event
+ */
+ @XmlElement(name = "execution-handler")
+ protected void setExecutionHandler(ExecutionHandler executionHandler)
+ {
+ this.executionHandler = executionHandler;
+ }
+
+ /**
+ * Get the FlowHandler for this Event
+ */
+ public FlowHandler getFlowHandler()
+ {
+ return flowHandler;
+ }
+
+ /**
+ * Set the FlowHandler for this Event
+ */
+ @XmlElement(name = "flow-handler")
+ protected void setFlowHandler(FlowHandler flowHandler)
+ {
+ this.flowHandler = flowHandler;
+ }
+
+ /**
+ * Get the SignalHandler for this Event
+ */
+ public SignalHandler getSignalHandler()
+ {
+ return signalHandler;
+ }
+
+ /**
+ * Set the SignalHandler for this Event
+ */
+ @XmlElement(name = "signal-handler")
+ protected void setSignalHandler(SignalHandler signalHandler)
+ {
+ this.signalHandler = signalHandler;
+ }
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -26,6 +26,8 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.runtime.Attachments;
import org.jboss.bpm.runtime.Token;
@@ -42,6 +44,9 @@
@XmlType(name="EndEvent")
public class EndEvent extends AbstractEndEvent implements SingleInFlowSupport
{
+ // provide logging
+ private static final Log log = LogFactory.getLog(EndEvent.class);
+
private Result result;
private Flow inFlow;
@@ -88,26 +93,51 @@
return result;
}
- /** Get signal for enter */
- public Signal getEnterSignal()
+ @XmlTransient
+ public FlowHandler getDefaultFlowHandler()
{
- return new Signal(getProcess(), Signal.Type.ENTER_END_EVENT);
+ return new FlowHandler()
+ {
+ @Override
+ public void transfer(Token token)
+ {
+ log.debug("End reached in: " + getName());
+ }
+ };
}
-
- /** Get signal for exit */
- public Signal getExitSignal()
+
+ public SignalHandler getDefaultSignalHandler()
{
- return new Signal(getProcess(), Signal.Type.EXIT_END_EVENT);
+ return new SignalHandler()
+ {
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_END_EVENT);
+ }
+
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_END_EVENT);
+ }
+ };
}
- public void execute(final Token token)
+ @XmlTransient
+ public ExecutionHandler getDefaultExecutionHandler()
{
- // Provide the result
- result = new Result()
+ return new ExecutionHandler()
{
- public Attachments getAttachments()
+ @Override
+ public void execute(final Token token)
{
- return token.getExecutionContext();
+ // Provide the result
+ result = new Result()
+ {
+ public Attachments getAttachments()
+ {
+ return token.getExecutionContext();
+ }
+ };
}
};
}
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -21,12 +21,10 @@
*/
package org.jboss.bpm.model;
+//$Id$
+
import javax.xml.bind.annotation.XmlType;
-
-
-// $Id$
-
/**
* An Event is something that “happens” during the course of a business process.
* These Events affect the flow of the Process and usually have a cause or an impact.
@@ -35,7 +33,7 @@
* @since 08-Jul-2008
*/
@XmlType(name="Event")
-public abstract class Event extends AbstractEvent implements ExecutableFlowObject
+public abstract class Event extends AbstractEvent implements Executable
{
/**
* Construct an anonymous StartEvent.
@@ -44,20 +42,4 @@
protected Event()
{
}
-
- /**
- * Get signal for enter
- */
- public Signal getEnterSignal()
- {
- return new Signal(getProcess(), Signal.Type.ENTER_EVENT);
- }
-
- /**
- * Get signal for exit
- */
- public Signal getExitSignal()
- {
- return new Signal(getProcess(), Signal.Type.EXIT_EVENT);
- }
}
\ No newline at end of file
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Executable.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/Executable.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Executable.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Executable.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+//$Id$
+
+/**
+ * A combined interface for execution aspects
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface Executable
+{
+ /** Get the associated ExecutionHandler */
+ ExecutionHandler getExecutionHandler();
+
+ /** Get the default ExecutionHandler */
+ ExecutionHandler getDefaultExecutionHandler();
+
+ /** Get the associated SignalHandler */
+ SignalHandler getSignalHandler();
+
+ /** Get the default SignalHandler */
+ SignalHandler getDefaultSignalHandler();
+
+ /** Get the associated FlowHandler */
+ FlowHandler getFlowHandler();
+
+ /** Get the default FlowHandler */
+ FlowHandler getDefaultFlowHandler();
+}
\ No newline at end of file
Deleted: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model;
-
-import org.jboss.bpm.runtime.Token;
-
-//$Id$
-
-/**
- * Implement to make the FlowObject executable
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface ExecutableFlowObject
-{
- /**
- * Get signal for enter
- */
- Signal getEnterSignal();
-
- /**
- * Get signal for exit
- */
- Signal getExitSignal();
-
- /**
- * Execute this flow object
- */
- void execute(Token token);
-}
\ No newline at end of file
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutionHandler.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/ExecutionHandler.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutionHandler.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutionHandler.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+//$Id$
+
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.bpm.runtime.Token;
+
+/**
+ * Implement to make the FlowObject executable
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at XmlType(name = "ExecutionHandler")
+public abstract class ExecutionHandler extends Handler
+{
+ @XmlTransient
+ private ExecutionHandler delegate;
+
+ /**
+ * Execute this flow object
+ */
+ public void execute(Token token)
+ {
+ if (delegate == null)
+ {
+ delegate = newInstance(ExecutionHandler.class);
+ }
+ delegate.execute(token);
+ }
+}
\ No newline at end of file
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowHandler.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/FlowHandler.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowHandler.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowHandler.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+//$Id$
+
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.bpm.runtime.Token;
+
+/**
+ * Implement to handle the outgoing Flows for an FlowObject
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at XmlType(name = "FlowHandler")
+public abstract class FlowHandler extends Handler
+{
+ private FlowHandler delegate;
+
+ /**
+ * Transfer the token to the FlowHandler.
+ * <p/>
+ * The FlowHandler will add the active outgoing @{link Flow}s to
+ * @{link Token}'s flow queue.
+ */
+ public void transfer(Token token)
+ {
+ if (delegate == null)
+ {
+ delegate = newInstance(FlowHandler.class);
+ }
+ delegate.transfer(token);
+ }
+}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -30,6 +30,10 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.runtime.Token;
+
/**
* Gateways are modelling elements that are used to control how Sequence Flow interact as they converge and diverge within a Process.
* If the flow does not need to be controlled, then a Gateway is not needed.
@@ -38,8 +42,11 @@
* @since 08-Jul-2008
*/
@XmlType(name="Gateway")
-public abstract class Gateway extends AbstractGateway implements NamedFlowObject, ExecutableFlowObject
+public abstract class Gateway extends AbstractGateway implements NamedFlowObject, Executable
{
+ // provide logging
+ private static final Log log = LogFactory.getLog(Gateway.class);
+
@XmlTransient
protected List<Flow> inFlows = new ArrayList<Flow>();
@@ -59,19 +66,7 @@
{
super(name);
}
-
- @Override
- public Signal getEnterSignal()
- {
- return new Signal(getProcess(), Signal.Type.ENTER_GATEWAY);
- }
- @Override
- public Signal getExitSignal()
- {
- return new Signal(getProcess(), Signal.Type.EXIT_GATEWAY);
- }
-
public void addOutFlow(Flow flow)
{
outFlows.add(flow);
@@ -86,4 +81,48 @@
{
this.inFlows.add(inFlow);
}
-}
\ No newline at end of file
+
+ @XmlTransient
+ public FlowHandler getDefaultFlowHandler()
+ {
+ return new FlowHandler()
+ {
+ @Override
+ public void transfer(Token token)
+ {
+ List<Flow> outFlows = getOutFlows();
+ if (outFlows.size() == 1)
+ token.addTailFlow(outFlows.get(0));
+ }
+ };
+ }
+
+ public SignalHandler getDefaultSignalHandler()
+ {
+ return new SignalHandler()
+ {
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_GATEWAY);
+ }
+
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_GATEWAY);
+ }
+ };
+ }
+
+ @XmlTransient
+ public ExecutionHandler getDefaultExecutionHandler()
+ {
+ return new ExecutionHandler()
+ {
+ @Override
+ public void execute(Token token)
+ {
+ log.debug("Nothing to do in gateway: " + getName());
+ }
+ };
+ }
+ }
\ No newline at end of file
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Handler.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/Handler.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Handler.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Handler.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+//$Id$
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.bpm.NotImplementedException;
+
+/**
+ * Implement to handle the outgoing Flows for an FlowObject
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at XmlType(name = "Handler")
+public abstract class Handler
+{
+ @XmlElement(name = "class")
+ private String className;
+ @XmlElement(name = "bean")
+ private String beanRef;
+
+ @SuppressWarnings("unchecked")
+ protected <T> T newInstance(Class<T> clazz)
+ {
+ try
+ {
+ if (className != null)
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ return (T)ctxLoader.loadClass(className).newInstance();
+ }
+ else if (beanRef != null)
+ {
+ throw new NotImplementedException();
+ }
+ else
+ {
+ throw new IllegalStateException("There is no 'class' nor 'bean' attribute set for this handler");
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot instanciate the handler", ex);
+ }
+ }
+}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ItermediateEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ItermediateEvent.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ItermediateEvent.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -28,7 +28,11 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.runtime.Token;
+
// $Id$
/**
@@ -44,6 +48,9 @@
@XmlType(name="ItermediateEvent")
public class ItermediateEvent extends AbstractItermediateEvent
{
+ // provide logging
+ private static final Log log = LogFactory.getLog(ItermediateEvent.class);
+
@XmlTransient
protected List<Flow> inFlows = new ArrayList<Flow>();
@@ -79,6 +86,50 @@
this.inFlows.add(inFlow);
}
+ @XmlTransient
+ public FlowHandler getDefaultFlowHandler()
+ {
+ return new FlowHandler()
+ {
+ @Override
+ public void transfer(Token token)
+ {
+ List<Flow> outFlows = getOutFlows();
+ if (outFlows.size() == 1)
+ token.addTailFlow(outFlows.get(0));
+ }
+ };
+ }
+
+ public SignalHandler getDefaultSignalHandler()
+ {
+ return new SignalHandler()
+ {
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_EVENT);
+ }
+
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_EVENT);
+ }
+ };
+ }
+
+ @XmlTransient
+ public ExecutionHandler getDefaultExecutionHandler()
+ {
+ return new ExecutionHandler()
+ {
+ @Override
+ public void execute(Token token)
+ {
+ log.debug("Nothing to do in start-event");
+ }
+ };
+ }
+
public String toString()
{
return "ItermediateEvent[" + getName() + "]";
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -35,7 +35,6 @@
import org.jboss.bpm.NameNotUniqueException;
import org.jboss.bpm.client.ExecutionManager;
import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.Token;
/**
* A Process is any Activity performed within a company or organization.
@@ -181,12 +180,6 @@
return processState;
}
- // Overwrite to prevent execution
- public void execute(Token token)
- {
- throw new IllegalStateException("A Process cannot get executed. Go through startProcess");
- }
-
/**
* Set the process state
*/
Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SignalHandler.java (from rev 1599, api/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/SignalHandler.java)
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SignalHandler.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SignalHandler.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+import javax.xml.bind.annotation.XmlType;
+
+
+//$Id$
+
+/**
+ * Implement to get signals on enter and exit.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at XmlType(name = "SignalHandler")
+public abstract class SignalHandler extends Handler
+{
+ private SignalHandler delegate;
+
+ /**
+ * Get signal for enter
+ */
+ public Signal getEnterSignal()
+ {
+ if (delegate == null)
+ {
+ delegate = newInstance(SignalHandler.class);
+ }
+ return delegate.getEnterSignal();
+ }
+
+ /**
+ * Get signal for exit
+ */
+ public Signal getExitSignal()
+ {
+ if (delegate == null)
+ {
+ delegate = newInstance(SignalHandler.class);
+ }
+ return delegate.getExitSignal();
+ }
+}
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,8 +23,13 @@
//$Id$
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.runtime.Token;
+
/**
* A Start Event indicates where a particular Process will start.
*
@@ -37,6 +42,9 @@
@XmlType(name = "StartEvent")
public class StartEvent extends AbstractStartEvent
{
+ // provide logging
+ private static final Log log = LogFactory.getLog(StartEvent.class);
+
/**
* Construct a StartEvent with a constant name: 'start'
* Note, this MUST NOT leak into the public API.
@@ -45,22 +53,48 @@
{
}
- /**
- * Get signal for enter
- */
- public Signal getEnterSignal()
+ @XmlTransient
+ public FlowHandler getDefaultFlowHandler()
{
- return new Signal(getProcess(), Signal.Type.ENTER_START_EVENT);
+ return new FlowHandler()
+ {
+ @Override
+ public void transfer(Token token)
+ {
+ token.addTailFlow(getOutFlow());
+ }
+ };
}
- /**
- * Get signal for exit
- */
- public Signal getExitSignal()
+ public SignalHandler getDefaultSignalHandler()
{
- return new Signal(getProcess(), Signal.Type.EXIT_START_EVENT);
+ return new SignalHandler()
+ {
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_START_EVENT);
+ }
+
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_START_EVENT);
+ }
+ };
}
+ @XmlTransient
+ public ExecutionHandler getDefaultExecutionHandler()
+ {
+ return new ExecutionHandler()
+ {
+ @Override
+ public void execute(Token token)
+ {
+ log.debug("Nothing to do in start-event");
+ }
+ };
+ }
+
public String toString()
{
return "StartEvent[]";
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -35,7 +35,7 @@
* @since 08-Jul-2008
*/
@XmlType(name="SubProcess")
-public class SubProcess extends AbstractSubProcess implements SingleInFlowSupport, ExecutableFlowObject
+public class SubProcess extends AbstractSubProcess implements SingleInFlowSupport, Executable
{
private Flow inFlow;
@@ -73,23 +73,47 @@
this.inFlow = inFlow;
}
- /** Get signal for enter */
- public Signal getEnterSignal()
+ @XmlTransient
+ public FlowHandler getDefaultFlowHandler()
{
- return new Signal(getProcess(), Signal.Type.ENTER_SUB_PROCESS, getName());
+ return new FlowHandler()
+ {
+ @Override
+ public void transfer(Token token)
+ {
+ token.addTailFlow(getOutFlow());
+ }
+ };
}
- /** Get signal for exit */
- public Signal getExitSignal()
+ public SignalHandler getDefaultSignalHandler()
{
- return new Signal(getProcess(), Signal.Type.EXIT_SUB_PROCESS, getName());
+ return new SignalHandler()
+ {
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_SUB_PROCESS);
+ }
+
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_SUB_PROCESS);
+ }
+ };
}
- public void execute(Token token)
+ @XmlTransient
+ public ExecutionHandler getDefaultExecutionHandler()
{
- startProcess(token.getExecutionContext());
+ return new ExecutionHandler()
+ {
+ @Override
+ public void execute(Token token)
+ {
+ startProcess(token.getExecutionContext());
+ }
+ };
}
-
public String toString()
{
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -24,6 +24,8 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.runtime.Token;
//$Id$
@@ -38,8 +40,11 @@
* @since 08-Jul-2008
*/
@XmlType(name = "Task")
-public class Task extends AbstractTask implements SingleInFlowSupport, ExecutableFlowObject
+public class Task extends AbstractTask implements SingleInFlowSupport, Executable
{
+ // provide logging
+ private static final Log log = LogFactory.getLog(Task.class);
+
private Flow inFlow;
/**
@@ -76,25 +81,52 @@
this.inFlow = inFlow;
}
- /** Get signal for enter */
- public Signal getEnterSignal()
+ @XmlTransient
+ public FlowHandler getDefaultFlowHandler()
{
- return new Signal(getProcess(), Signal.Type.ENTER_TASK, getName());
+ return new FlowHandler()
+ {
+ @Override
+ public void transfer(Token token)
+ {
+ token.addTailFlow(getOutFlow());
+ }
+ };
}
- /** Get signal for exit */
- public Signal getExitSignal()
+ @XmlTransient
+ public SignalHandler getDefaultSignalHandler()
{
- return new Signal(getProcess(), Signal.Type.EXIT_TASK, getName());
+ return new SignalHandler()
+ {
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_TASK);
+ }
+
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_TASK);
+ }
+ };
}
- public void execute(Token token)
+ @XmlTransient
+ public ExecutionHandler getDefaultExecutionHandler()
{
- throw new IllegalStateException("Overwrite to impolement the task");
+ return new ExecutionHandler()
+ {
+ @Override
+ public void execute(Token token)
+ {
+ log.debug("Nothing to do in task: " + getName());
+ }
+ };
}
public String toString()
{
return "Task[" + getName() + "]";
}
+
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,6 +23,10 @@
//$Id$
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.Process;
/**
@@ -37,11 +41,48 @@
* @author Thomas.Diesler at jboss.com
* @since 20-Apr-2007
*/
-public interface Token
+public class Token
{
- /** Get the associated execution context */
- ExecutionContext getExecutionContext();
+ private Process proc;
+ private ExecutionContext context;
+ private Queue<Flow> flowQueue = new ConcurrentLinkedQueue<Flow>();
- /** Get the current process */
- Process getProcess();
+ public Token(Process proc, Attachments att)
+ {
+ this.proc = proc;
+ this.context = new InitialContext(att);
+ }
+
+ public Process getProcess()
+ {
+ return proc;
+ }
+
+ public ExecutionContext getExecutionContext()
+ {
+ return context;
+ }
+
+ public Flow peekHeadFlow()
+ {
+ return flowQueue.peek();
+ }
+
+ public Flow removeHeadFlow()
+ {
+ return flowQueue.remove();
+ }
+
+ public void addTailFlow(Flow flow)
+ {
+ flowQueue.add(flow);
+ }
+
+ static class InitialContext extends BasicAttachments implements ExecutionContext
+ {
+ InitialContext(Attachments att)
+ {
+ super(att);
+ }
+ }
}
\ No newline at end of file
Deleted: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractToken.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractToken.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractToken.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.runtime.internal;
-
-//$Id$
-
-import org.jboss.bpm.runtime.Token;
-
-/**
- * A Token is a descriptive construct used to describe how the flow of a Process will proceed at runtime.
- *
- * By tracking how the Token traverses the Flow Objects, gets diverted through alternative paths, and gets split into parallel paths, the normal Sequence Flow should be
- * completely definable.
- *
- * A Token will have a unique identity that can be used to separate multiple Tokens that may exist because of concurrent process instances or the splitting of the Token
- * for parallel processing within a single process instance.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 20-Apr-2007
- */
-public abstract class AbstractToken implements Token
-{
- // The implementaion object
- private Object implObject;
-
- public Object getImplObject()
- {
- return implObject;
- }
-
- public void setImplObject(Object implObject)
- {
- this.implObject = implObject;
- }
-}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -24,6 +24,9 @@
// $Id$
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import junit.framework.TestCase;
@@ -31,14 +34,18 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.JBPMException;
import org.jboss.bpm.client.internal.EmbeddedBeansDeployer;
+import org.jboss.bpm.model.Signal;
+import org.jboss.bpm.runtime.SignalListener;
-public abstract class AbstractAPITestCase extends TestCase
+public abstract class AbstractAPITestCase extends TestCase implements SignalListener
{
// provide logging
private static final Log log = LogFactory.getLog(AbstractAPITestCase.class);
// Every test case has a deployer
private EmbeddedBeansDeployer deployer;
+ // The signals caught by this test case
+ private List<Signal> signals = new ArrayList<Signal>();
/** Overwrite to provide beans config */
protected abstract String getBeansConfig();
@@ -50,6 +57,7 @@
log.debug("setUp: " + getName());
deployer = new EmbeddedBeansDeployer();
deployTestBeans(getBeansConfig());
+ signals.clear();
}
@Override
@@ -94,4 +102,14 @@
return url;
}
+ public void catchSignal(Signal signal)
+ {
+ signals.add(signal);
+ log.debug("catchSignal: " + signal);
+ }
+
+ public List<Signal> getCaughtSignals()
+ {
+ return Collections.unmodifiableList(signals);
+ }
}
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,44 +23,13 @@
// $Id$
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.client.ProcessEngine;
-import org.jboss.bpm.model.Signal;
-import org.jboss.bpm.runtime.SignalListener;
-public abstract class DefaultEngineTestCase extends AbstractAPITestCase implements SignalListener
+public abstract class DefaultEngineTestCase extends AbstractAPITestCase
{
- // provide logging
- private static final Log log = LogFactory.getLog(DefaultEngineTestCase.class);
-
- private List<Signal> signals = new ArrayList<Signal>();
-
@Override
protected String getBeansConfig()
{
return ProcessEngine.JBPM_ENGINE_CONFIG;
}
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- signals.clear();
- }
-
- public void catchSignal(Signal signal)
- {
- signals.add(signal);
- log.debug("catchSignal: " + signal);
- }
-
- public List<Signal> getCaughtSignals()
- {
- return Collections.unmodifiableList(signals);
- }
}
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -26,6 +26,7 @@
import java.io.Reader;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.jboss.bpm.model.ObjectFactory;
@@ -39,7 +40,7 @@
*/
public class ProcessUnmarshaller
{
- public Process unmarshallProcess(Reader xml) throws Exception
+ public Process unmarshallProcess(Reader xml) throws JAXBException
{
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Deleted: api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm;
-
-//$Id$
-
-import org.jboss.bpm.test.AbstractAPITestCase;
-
-public abstract class AbstractMockEngineTestCase extends AbstractAPITestCase
-{
-
- @Override
- protected String getBeansConfig()
- {
- return "jbpm-mock-beans.xml";
- }
-
-}
Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/MockEngineTestCase.java (from rev 1599, api/branches/tdiesler/modules/api/src/test/java/org/jboss/bpm/MockEngineTestCase.java)
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/MockEngineTestCase.java (rev 0)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/MockEngineTestCase.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm;
+
+//$Id$
+
+import org.jboss.bpm.test.AbstractAPITestCase;
+
+public abstract class MockEngineTestCase extends AbstractAPITestCase
+{
+
+ @Override
+ protected String getBeansConfig()
+ {
+ return "jbpm-mock-beans.xml";
+ }
+
+}
Deleted: api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.client;
-
-//$Id$
-
-/**
- * A process engine with public access
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
-public class MockProcessEngine extends ProcessEngine
-{
-
-}
\ No newline at end of file
Modified: api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,9 +23,9 @@
// $Id$
-import org.jboss.bpm.AbstractMockEngineTestCase;
+import org.jboss.bpm.MockEngineTestCase;
-public class ProcessEngineLocatorTest extends AbstractMockEngineTestCase
+public class ProcessEngineLocatorTest extends MockEngineTestCase
{
public void testLocateProcessEngine() throws Exception
Modified: api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -51,7 +51,7 @@
marshaller.marshallProcess(inProc, strwr);
String xml = strwr.toString();
- //System.out.println(xml);
+ System.out.println(xml);
ProcessUnmarshaller unmarshaller = new ProcessUnmarshaller();
Process outProc = unmarshaller.unmarshallProcess(new StringReader(xml));
Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern (from rev 1599, api/branches/tdiesler/modules/api/src/test/java/org/jboss/bpm/pattern)
Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence (from rev 1599, api/branches/tdiesler/modules/api/src/test/java/org/jboss/bpm/pattern/sequence)
Deleted: api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java
===================================================================
--- api/branches/tdiesler/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java 2008-07-13 13:23:02 UTC (rev 1599)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.pattern.sequence;
-
-// $Id$
-
-import java.util.List;
-import java.util.concurrent.Future;
-
-import org.jboss.bpm.MockEngineTestCase;
-import org.jboss.bpm.client.ProcessManager;
-import org.jboss.bpm.client.SignalManager;
-import org.jboss.bpm.model.Process;
-import org.jboss.bpm.model.ProcessBuilder;
-import org.jboss.bpm.model.Result;
-import org.jboss.bpm.model.Signal;
-
-/**
- * Test the basic execution sequence
- *
- * @author thomas.diesler at jboss.com
- * @since 03-Jul-2008
- */
-public class SequenceTest extends MockEngineTestCase
-{
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- SignalManager em = SignalManager.locateSignalManager();
- em.addListener(getName(), this);
- }
-
- /**
- * Test a basic sequence
- */
- public void testBasicSequence() throws Exception
- {
- Process proc = new ProcessBuilder(getName()).addStartEvent().addSequenceFlow("task").addTask("task").
- addSequenceFlow("end").addEndEvent("end").getProcess();
-
- // Create a Process through the ProcessManager
- ProcessManager pm = ProcessManager.locateProcessManager();
- pm.registerProcess(proc);
-
- // Start the Process
- Future<Result> end = proc.startProcess();
- Result result = end.get();
-
- // Validate the Result
- assertNotNull("Result expected", result);
- assertEquals("No attachments expected", 0, result.getAttachments().getAttachmentKeys().size());
-
- // Validate received signals
- List<Signal> signals = getCaughtSignals();
- assertEquals(Signal.Type.ENTER_PROCESS, signals.get(0).getType());
- assertEquals(Signal.Type.ENTER_START_EVENT, signals.get(1).getType());
- assertEquals(Signal.Type.EXIT_START_EVENT, signals.get(2).getType());
- assertEquals(Signal.Type.ENTER_TASK, signals.get(3).getType());
- assertEquals(Signal.Type.EXIT_TASK, signals.get(4).getType());
- assertEquals(Signal.Type.ENTER_END_EVENT, signals.get(5).getType());
- assertEquals(Signal.Type.EXIT_END_EVENT, signals.get(6).getType());
- assertEquals(Signal.Type.EXIT_PROCESS, signals.get(7).getType());
- }
-}
Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java (from rev 1599, api/branches/tdiesler/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java)
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java (rev 0)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/pattern/sequence/SequenceTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.pattern.sequence;
+
+// $Id$
+
+import java.util.List;
+import java.util.concurrent.Future;
+
+import org.jboss.bpm.MockEngineTestCase;
+import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.client.SignalManager;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.ProcessBuilder;
+import org.jboss.bpm.model.Result;
+import org.jboss.bpm.model.Signal;
+
+/**
+ * Test the basic execution sequence
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 03-Jul-2008
+ */
+public class SequenceTest extends MockEngineTestCase
+{
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ SignalManager em = SignalManager.locateSignalManager();
+ em.addListener(getName(), this);
+ }
+
+ /**
+ * Test a basic sequence
+ */
+ public void testBasicSequence() throws Exception
+ {
+ Process proc = new ProcessBuilder(getName()).addStartEvent().addSequenceFlow("task").addTask("task").
+ addSequenceFlow("end").addEndEvent("end").getProcess();
+
+ // Create a Process through the ProcessManager
+ ProcessManager pm = ProcessManager.locateProcessManager();
+ pm.registerProcess(proc);
+
+ // Start the Process
+ Future<Result> end = proc.startProcess();
+ Result result = end.get();
+
+ // Validate the Result
+ assertNotNull("Result expected", result);
+ assertEquals("No attachments expected", 0, result.getAttachments().getAttachmentKeys().size());
+
+ // Validate received signals
+ List<Signal> signals = getCaughtSignals();
+ assertEquals(Signal.Type.ENTER_PROCESS, signals.get(0).getType());
+ assertEquals(Signal.Type.ENTER_START_EVENT, signals.get(1).getType());
+ assertEquals(Signal.Type.EXIT_START_EVENT, signals.get(2).getType());
+ assertEquals(Signal.Type.ENTER_TASK, signals.get(3).getType());
+ assertEquals(Signal.Type.EXIT_TASK, signals.get(4).getType());
+ assertEquals(Signal.Type.ENTER_END_EVENT, signals.get(5).getType());
+ assertEquals(Signal.Type.EXIT_END_EVENT, signals.get(6).getType());
+ assertEquals(Signal.Type.EXIT_PROCESS, signals.get(7).getType());
+ }
+}
Modified: api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml
===================================================================
--- api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml 2008-07-13 13:29:02 UTC (rev 1601)
@@ -3,8 +3,26 @@
<!-- The Kernel Locator -->
<bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator"/>
- <!-- The BPM Process Engine -->
- <bean name="jBPMProcessEngine" class="org.jboss.bpm.client.MockProcessEngine">
+ <!-- The process engine -->
+ <bean name="jBPMProcessEngine" class="org.jboss.bpm.client.internal.ProcessEngineImpl">
+ <property name="processManager"><inject bean="jBPMProcessManager"/></property>
+ <property name="executionManager"><inject bean="jBPMExecutionManager"/></property>
+ <property name="signalManager"><inject bean="jBPMSignalManager"/></property>
</bean>
+
+ <!-- The process manager -->
+ <bean name="jBPMProcessManager" class="org.jboss.bpm.client.internal.ProcessManagerImpl">
+ <property name="processEngine"><inject bean="jBPMProcessEngine" state="Instantiated"/></property>
+ </bean>
+
+ <!-- The execution manager -->
+ <bean name="jBPMExecutionManager" class="org.jboss.bpm.client.internal.ExecutionManagerImpl">
+ <property name="processEngine"><inject bean="jBPMProcessEngine" state="Instantiated"/></property>
+ </bean>
+
+ <!-- The execution manager -->
+ <bean name="jBPMSignalManager" class="org.jboss.bpm.client.internal.SignalManagerImpl">
+ <property name="processEngine"><inject bean="jBPMProcessEngine" state="Instantiated"/></property>
+ </bean>
</deployment>
\ No newline at end of file
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -72,7 +72,7 @@
// Verify context variables
Attachments att = result.getAttachments();
String msg = att.getAttachment(String.class, "TaskMessage");
- assertEquals("stateA has: [[org.jboss.bpm.samples.context.ContextValue,null]]", msg);
+ assertEquals("TaskA has: [[org.jboss.bpm.samples.context.ContextValue,null]]", msg);
// Validate original attachement
ContextValue att1 = att.getAttachment(ContextValue.class);
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,7 +23,7 @@
// $Id$
-import org.jboss.bpm.model.Task;
+import org.jboss.bpm.model.ExecutionHandler;
import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.Token;
@@ -33,13 +33,13 @@
* @author Thomas.Diesler at jboss.com
* @since 04-Jul-2008
*/
-public class TaskA extends Task
+public class TaskA extends ExecutionHandler
{
@Override
public void execute(Token token)
{
ExecutionContext ctx = token.getExecutionContext();
- ctx.addAttachment(String.class, "TaskMessage", getName() + " has: " + ctx.getAttachmentKeys());
+ ctx.addAttachment(String.class, "TaskMessage", "TaskA has: " + ctx.getAttachmentKeys());
ctx.addAttachment(ContextValue.class, "TaskAttachment", new ContextValue("bar"));
}
}
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/sequence/BasicSequenceTest.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/sequence/BasicSequenceTest.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/sequence/BasicSequenceTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -72,13 +72,13 @@
// Validate received signals
List<Signal> signals = getCaughtSignals();
- assertEquals("ENTER_PROCESS[basic-sequence]", signals.get(0).toString());
- assertEquals("ENTER_START_EVENT[basic-sequence]", signals.get(1).toString());
- assertEquals("EXIT_START_EVENT[basic-sequence]", signals.get(2).toString());
- assertEquals("ENTER_TASK[basic-sequence:stateA]", signals.get(3).toString());
- assertEquals("EXIT_TASK[basic-sequence:stateA]", signals.get(4).toString());
- assertEquals("ENTER_END_EVENT[basic-sequence]", signals.get(5).toString());
- assertEquals("EXIT_END_EVENT[basic-sequence]", signals.get(6).toString());
- assertEquals("EXIT_PROCESS[basic-sequence]", signals.get(7).toString());
+ assertEquals(Signal.Type.ENTER_PROCESS, signals.get(0).getType());
+ assertEquals(Signal.Type.ENTER_START_EVENT, signals.get(1).getType());
+ assertEquals(Signal.Type.EXIT_START_EVENT, signals.get(2).getType());
+ assertEquals(Signal.Type.ENTER_TASK, signals.get(3).getType());
+ assertEquals(Signal.Type.EXIT_TASK, signals.get(4).getType());
+ assertEquals(Signal.Type.ENTER_END_EVENT, signals.get(5).getType());
+ assertEquals(Signal.Type.EXIT_END_EVENT, signals.get(6).getType());
+ assertEquals(Signal.Type.EXIT_PROCESS, signals.get(7).getType());
}
}
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/BasicTaskTest.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/BasicTaskTest.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/BasicTaskTest.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -72,17 +72,17 @@
assertNotNull("Result expected", result);
Attachments att = result.getAttachments();
assertEquals("Attachments expected", 1, att.getAttachmentKeys().size());
- assertEquals("Task: stateA", att.getAttachment(String.class));
+ assertEquals("Task: TaskA", att.getAttachment(String.class));
// Validate received signals
List<Signal> signals = getCaughtSignals();
- assertEquals("ENTER_PROCESS[basic-task]", signals.get(0).toString());
- assertEquals("ENTER_START_EVENT[basic-task]", signals.get(1).toString());
- assertEquals("EXIT_START_EVENT[basic-task]", signals.get(2).toString());
- assertEquals("ENTER_TASK[basic-task:stateA]", signals.get(3).toString());
- assertEquals("EXIT_TASK[basic-task:stateA]", signals.get(4).toString());
- assertEquals("ENTER_END_EVENT[basic-task]", signals.get(5).toString());
- assertEquals("EXIT_END_EVENT[basic-task]", signals.get(6).toString());
- assertEquals("EXIT_PROCESS[basic-task]", signals.get(7).toString());
+ assertEquals(Signal.Type.ENTER_PROCESS, signals.get(0).getType());
+ assertEquals(Signal.Type.ENTER_START_EVENT, signals.get(1).getType());
+ assertEquals(Signal.Type.EXIT_START_EVENT, signals.get(2).getType());
+ assertEquals(Signal.Type.ENTER_TASK, signals.get(3).getType());
+ assertEquals(Signal.Type.EXIT_TASK, signals.get(4).getType());
+ assertEquals(Signal.Type.ENTER_END_EVENT, signals.get(5).getType());
+ assertEquals(Signal.Type.EXIT_END_EVENT, signals.get(6).getType());
+ assertEquals(Signal.Type.EXIT_PROCESS, signals.get(7).getType());
}
}
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java 2008-07-13 13:27:59 UTC (rev 1600)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java 2008-07-13 13:29:02 UTC (rev 1601)
@@ -23,7 +23,7 @@
// $Id$
-import org.jboss.bpm.model.Task;
+import org.jboss.bpm.model.ExecutionHandler;
import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.Token;
@@ -33,12 +33,12 @@
* @author Thomas.Diesler at jboss.com
* @since 04-Jul-2008
*/
-public class TaskA extends Task
+public class TaskA extends ExecutionHandler
{
@Override
public void execute(Token token)
{
ExecutionContext ctx = token.getExecutionContext();
- ctx.addAttachment(String.class, "Task: " + getName());
+ ctx.addAttachment(String.class, "Task: TaskA");
}
}
More information about the jbpm-commits
mailing list