supber

导航

JBPM使用步骤

JBPM使用步骤:

  New 一个java项目 Src下: New?Jboss jbpm?jbpm4 process definition

有了一个文件:xxxx.jpdl.xml 使用GPD可视化编辑一个流程 起点 State 终点 保存后,还会生成一个图片文件

添加  jbpm.jar   以及其他jar包

添加配置文件 src下的配置copy到src下:

  jbpm.cfg.xml(主配置文件), jbpm.hibernate.cfg.xml, jbpm.mail.properties, jbpm.mail.template.xml, logging.properties

解决设计器中文乱码问题,

  修改eclipse.ini或myeclipse.ini,最后增加代码: -Dfile.encoding=UTF-8

发布流程:

  public class JbpmTest extends TestCase {  

    ProcessEngine processEngine;

     public JbpmTest() {   

    processEngine = Configuration.getProcessEngine();  }

 @Test

 @BeforeClass  //发布流程定义  

public void testDeploy() {  

   RepositoryService repositoryService = processEngine.getRepositoryService();   

  String deploymentId = repositoryService.createDeployment().addResourceFromClasspath( "hi.jpdl.xml").deploy();

 

JBPM数据库表

 JBPM4_DEPLOYMENT?? 流程定义表  JBPM4_DEPLOYPROP 流程定义属性表  JBPM4_EXECUTION? 流程实例表  JBPM4_HIST_ACTINST 流程活动(节点)实例表  JBPM4_HIST_DETAIL? 流程历史详细表  JBPM4_HIST_PROCINST 流程实例历史表  JBPM4_HIST_TASK? 流程任务实例历史表  JBPM4_HIST_VAR? 流程变量(上下文)历史表  JBPM4_ID_GROUP 组表  JBPM4_ID_MEMBERSHIP 用户角色表  JBPM4_ID_USER? 用户表  JBPM4_JOB? 定时表  JBPM4_LOB? 存储表  JBPM4_PARTICIPATION 参与者表  JBPM4_SWIMLANE? 泳道表  JBPM4_TASK 任务表  JBPM4_VARIABLE 上下文表

 

发布流程  

public void testDeploy() {   

  RepositoryService repositoryService = processEngine .getRepositoryService();   

  String deploymentId = repositoryService.createDeployment().addResourceFromClasspath( "hi.jpdl.xml").deploy();

 }

删除流程  

  repositoryService.deleteDeploymentCascade(deploymentId);

 

查看流程  

public void testListDeploy(){  

   List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();  

     for (ProcessDefinition processDefinition : list) {    

      System.out.println("***********"+processDefinition.getDeploymentId());   

  }  }

 

创建流程实例

   ExecutionService executionService = processEngine.getExecutionService();

   ProcessInstance pi = executionService.startProcessInstanceByKey("hi");

 

执行流程实例  

  ProcessInstance  pi = executionService.findProcessInstanceById("hi.100007");  

  System.out.println("*************"+pi.findActiveActivityNames());

   pi = executionService.signalExecutionById(pi.getId(),"to 经理审批");  

  System.out.println("---"+pi.findActiveActivityNames());

 

 

 

posted on 2013-08-15 17:01  supber  阅读(559)  评论(0)    收藏  举报