node节点类型适用于当你想要在节点中编写自己的代码的情形。通过设置action来帮定我们自己的商业逻辑。
<start-state name="start">
<transition name="tr1" to="node1"></transition>
</start-state>
<node name="node1">
<action class="com.jeffentest.JeffenActionHandler">
<msg>HELLO</msg>
</action>
<transition name="tr2" to="end1"></transition>
</node>
<end-state name="end1"></end-state>
------------------------------------
package com.jeffentest;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
public class JeffenActionHandler implements ActionHandler {
private static final long serialVersionUID = 1L;
private String msg;
public void execute(ExecutionContext executionContext) {
System.out.println(msg+"jeffen");
//可以指定流程的运行
//executionContext.leaveNode(transitionName);
}
}
----------------------------------------
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());
jbpmContext.save(processInstance);
}finally {
jbpmContext.close();
}
}
---------------------------------------
StartState(start)
HELLOjeffen
Node(node1)
EndState(end1)