jbpm流程控制初学者容易接触的domo
package com.sxdx.jbpm;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.zip.ZipInputStream;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import junit.framework.TestCase;
public class JbpmTest extends TestCase{
public void testbushu() throws Exception{
//1.获取sessionFactory
JbpmConfiguration jbpmConfiguration=JbpmConfiguration.getInstance();
//2.获取session
JbpmContext jc=jbpmConfiguration.createJbpmContext();
//要把流程图转换成java对象
InputStream is=new FileInputStream("D://java_dianli//jbpm//src//leave//leave.zip");
ZipInputStream zis=new ZipInputStream(is);
ProcessDefinition pd=ProcessDefinition.parseParZipInputStream(zis);
//需要使用jc的方法吧pd持久到数据库中
jc.deployProcessDefinition(pd);
jc.close();
}
public void testgetinstance(){
//得到流程定义(在数据库)
JbpmConfiguration jbpmConfiguration=JbpmConfiguration.getInstance();
JbpmContext jc=jbpmConfiguration.createJbpmContext();
ProcessDefinition pd=jc.getGraphSession().findLatestProcessDefinition("qingjia");
//根据流程定义创建流程实例
ProcessInstance pi=pd.createProcessInstance();
jc.close();
}
public void testrun(){
//得到流程定义(在数据库)
JbpmConfiguration jbpmConfiguration=JbpmConfiguration.getInstance();
JbpmContext jc=jbpmConfiguration.createJbpmContext();
//还没开始走,看看我的令牌在哪里
ProcessInstance pi=jc.getProcessInstance(1);
Token token=pi.getRootToken();
String n1=token.getNode().getName();
System.out.println("当前走到了"+n1+"节点");
//令牌开始往下走
token.signal();
System.out.println("当前走到了"+token.getNode().getName()+"节点");
token.signal();
System.out.println("当前走到了"+token.getNode().getName()+"节点");
}
}
2019-12-21 22:08:04
20.25MB
jbpm
1