state是一种节点类型,当流程运行到该节点后会等待,需要外界进行触发,流程才能继续进行。一般用在同系统外部进行交互,如当流程进入该节点后向外系统发业务处理请求,然后进入等待状态,当外系统完成后发回响应信息后,通过token.signal()触发流程继续。
如:
<process-definition  xmlns=""  name="yytest">
   <start-state name="start">
      <transition name="" to="state1"></transition>
   </start-state>
   <state name="state1">
     <event type="node-enter">
   <script>System.out.println("this script is entering node "+node);</script>
  </event>
       <transition name="" to="end1"></transition>
   </state>
   <end-state name="end1"></end-state>
</process-definition>
---------------------------------------------------
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)
this script is entering node State(state1)
State(state1)
EndState(end1)
 
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jeffen2006/archive/2006/10/13/1333424.aspx