[jboss-user] [JBoss jBPM] - Using end-complete-process attribute of end-state
nizzy
do-not-reply at jboss.com
Tue Jun 3 09:24:38 EDT 2008
Hi,
I have attached the update schema to the jira issue created by Tom.
This fixed the exception I was seeing. However I'm still not seeing the behaviour from the process execution that I would expect.
Could someone have a look at my test process definition and see if I'm doing something wrong
<?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition xmlns="" name="forktest">
|
|
| <start-state name="start">
| <transition to="doThis1"></transition>
| </start-state>
|
|
| <node name="doThis1">
| <transition to="fork1"></transition>
| </node>
|
| <fork name="fork1">
| <transition to="wait for a" name="a"></transition>
| <transition to="wait for b" name="b"></transition>
| </fork>
|
| <node name="doThis2">
| <action class="com.ecebs.sample.action.DoThis2ActionHandler"></action>
| <transition to="join1" name="success"></transition>
| <transition to="end - doThis2 failed" name="failure"></transition>
| </node>
|
| <node name="doThis3">
| <action class="com.ecebs.sample.action.DoThis2ActionHandler"></action>
| <transition to="join1" name="success"></transition>
| <transition to="end - doThis3 failed" name="failure"></transition>
| </node>
|
| <join name="join1">
| <transition to="wait state"></transition>
| </join>
|
| <state name="wait for a">
| <transition to="doThis2"></transition>
| </state>
|
| <state name="wait for b">
| <transition to="doThis3"></transition>
| </state>
|
| <state name="wait state">
| <transition to="end"></transition>
| </state>
|
|
| <end-state name="end" />
| <end-state name="end - doThis2 failed" end-complete-process='true'/>
| <end-state name="end - doThis3 failed" end-complete-process='true'/>
|
|
| </process-definition>
I set in the ContextInstance a variable that I use to define success or failure, i.e. if success then I call
ctx.leaveNode("success")
from my action handler, if it fails then I calll same method passing in failure.
I still dont see the process completing at the expected end-state which leads me to believe I'm doing something wrong, either in my process definition or my test code
test code is
@Test
| public void testFork() {
| if (log.isDebugEnabled()) {
| log.debug("inside testFork()");
| }
|
| // Create an instance of the process definition.
| ProcessInstance instance = new ProcessInstance(processDefinition);
| debugState("new ProcessInstance()", instance);
| log.debug("ProcessId is " + instance.getId());
|
| // Signal to Start Process
| log.info("Signaling: Start");
| signal(instance, null);
| debugState("1. Start", instance);
|
| ContextInstance ctxInst = instance.getContextInstance();
| ctxInst.setVariable("status", "failure");
|
| // Signal: Waiting for a
| log.info("Signaling: Waiting for a");
| signal(instance, "a");
| debugState("2. signal(instance, \"wait for a\")", instance);
|
| ctxInst.setVariable("status", "success");
|
| // Signal: Waiting for a
| log.info("Signaling: Waiting for b");
| signal(instance, "b");
| debugState("3. signal(instance, \"wait for b\")", instance);
|
| // Signal: Waiting for a
| log.info("Signaling: to exit wait");
| signal(instance, null);
| debugState("3. signal(instance, \"null\")", instance);
|
| Assert.assertEquals(processDefinition.getNode("end - doThis2 failed"), instance.getRootToken().getNode());
| //Assert.assertEquals(processDefinition.getNode("end"), instance.getRootToken().getNode());
| }
|
| private void debugState(String action, ProcessInstance instance) {
| log.info("**************************************************");
| log.info("just performed action: " + action);
| log.info("root token node: " + instance.getRootToken().getNode());
| log.info("root token active children: "
| + instance.getRootToken().getActiveChildren());
| log.info("**************************************************");
| }
|
| private void signal(ProcessInstance instance, String childKey) {
| if (log.isDebugEnabled()) {
| log.debug("inside signal(instance, childKey = " + childKey + ")");
| }
|
| Token rootToken = instance.getRootToken();
| if (rootToken.hasActiveChildren()) {
| Map<?, ?> children = rootToken.getActiveChildren();
| if (children.containsKey(childKey)) {
| Token childToken = (Token) children.get(childKey);
| childToken.signal();
| } else {
| // TODO handle this
| String msg = "Root Token does not contain, " + childKey;
| log.debug(msg);
| throw new RuntimeException(msg);
| }
| } else {
| rootToken.signal();
| }
| }
Help is much appreciated!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4155335#4155335
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4155335
More information about the jboss-user
mailing list