xmlns="urn:jbpm.org:jpdl-3.1" name="helloworld">
<swimlane name=""></swimlane>
<start-state name="开始节点">
<transition name="" to="等待状态节点"></transition>
</start-state>
<end-state name="结束节点"></end-state>
<event type="node-enter">
<script>
System.out.println("test");
</script>
</event>
<state name="等待状态节点">
<event type="node-enter">
<script>
System.out.println("test process ");
</script>
<action name="test" class="test.action.HelloWorldAction"></action>
</event>
<event type="node-leave">
<script name="leave test">
System.out.println("离开等待状态");
</script>
</event>
<transition to="state1" name="to state1"></transition>
<transition name="a" to="结束节点">
</transition>
</state>
<event type="node-enter"></event>
<transition to="结束节点" name="to state1"></transition>
<transition to="等待状态节点" name="to first"></transition>
</state>
</process-definition>
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
public static void main(String args[])throws Exception
{
ProcessDefinition processDefinition=ProcessDefinition.parseXmlResource("helloworld/processdefinition.xml");
ProcessInstance instance=new ProcessInstance(processDefinition);
ContextInstance contextInstance = instance.getContextInstance();
contextInstance.setVariable("var1","liujunjietest");
UserInfo user=new UserInfo();
user.setBirthday(new Date());
user.setName("liujunjie");
contextInstance.setVariable("user", user);
Dept dept=new Dept();
dept.setDeptName("测试部门");
user.setDept(dept);
Token rootToken=instance.getRootToken();
System.out.println(rootToken.getNode().getName());
System.out.println(contextInstance.getVariable("var1"));
rootToken.signal();
System.out.println(rootToken.getNode().getName());
rootToken.signal("to state1");
System.out.println(rootToken.getNode().getName());
//实现回退语句
rootToken.signal("to first");
System.out.println(rootToken.getNode().getName());
}
本来想上传图片,空间太小,不便