jbpm知识点大全
jbpm知识点大全
超状态是一组节点,超状态可以被递归嵌套。超状态可以被用来在流程定义中产生一些层次,例如,一个应用可能要把流程中的所有节点按阶段进行分组。动作可以与超状态事件关联,结果就是一个令牌在某个给定时间可以存在于多个嵌套的节点,这便于检查流程是否执行,比如,是否在启动阶段。在Jbpm模型中,你可以任意分组任何节点到一个超状态。在指定节点时用(/)隔开节点名称,用“..”指向上一层次。
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="" name="yytest">
<event type='superstate-enter'>
<action name='Enter' class='com.jeffentest.JeffenActionHandler' />
</event>
<event type='superstate-leave'>
<action name='Leave' class='com.jeffentest.JeffenActionHandler' />
</event>
<start-state name='START' >
<transition name='done' to='SS_1/N1.1'/>
</start-state>
<super-state name="SS_1">
<node name='N1.1'>
<transition name='done' to='SS_1.2/N1.2'/>
</node>
<super-state name="SS_1.2">
<node name='N1.2'>
<transition name='done' to='SS_1.3/N1.3'/>
</node>
<super-state name="SS_1.3">
<node name='N1.3'>
<transition name='done' to='/N999'/>
</node>
</super-state>
</super-state>
</super-state>
<state name="N999">
<transition name='done' to='END'/>
</state>
<end-state name="END" />
</process-definition>
-------------------------------------------
package com.jeffentest;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import java.io.*;
public class JeffenActionHandler implements ActionHandler {
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) {
String msg = executionContext.getEvent().getEventType()+":"+executionContext.getEventSource().getName();
System.out.println(msg);
}
}
-------------------------------------------------
private static void run(){JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
long processInstanceId =1;
processInstance = jbpmContext.loadProcessInstance(processInstanceId);
Token token = processInstance.getRootToken();
System.out.println(token.getNode());
token.signal();
System.out.println(token.getNode());
token.signal();
System.out.println(token.getNode());
token.signal();
System.out.println(token.getNode());
token.signal();
System.out.println(token.getNode());
token.signal();
System.out.println(token.getNode());
token.signal();
System.out.println(token.getNode());
jbpmContext.save(processInstance);
}finally {
jbpmContext.close();
}
}
---------------------------------------------------
运行结果:从进入、离开的顺序看得出嵌套的关系。
StartState(START)
superstate-enter:SS_1
superstate-enter:SS_1.2
superstate-enter:SS_1.3
superstate-leave:SS_1.3
superstate-leave:SS_1.2
superstate-leave:SS_1
State(N999)
EndState(END)