JBPM的流程示例

package org.jbpm.helloworld;

import junit.framework.TestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;

public class HelloWorldTest extends TestCase {
      
  public void testHelloWorldProcess() {
        ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("helloWorld.xml");
        /* 从这里可以看出,是对流程定义的XML进行解析*/
   
    ProcessInstance processInstance =  new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
     assertSame(processDefinition.getStartState(), token.getNode()); 
     token.signal();
     assertSame(processDefinition.getNode("s"), token.getNode());
     token.signal();
     assertSame(processDefinition.getNode("end"), token.getNode());
  }



  流程定义文件: helloWorld.xml
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Helloworld">
        <start-state>
                <transition to='s' />
         </start-state>
          <state name='s'>
                 <transition to='end' />
        </state>
         <end-state name='end' />
</process-definition>

你可能感兴趣的:(JBPM的流程示例)