JBPM4-实例
1. 创建流程
???
2. 创建Hello执行的操作
package com.spring.hello;public class Hello {private String msg = "Hello";public String sayHello() {System.out.println(msg+"VerRan ");return msg;}}
3.? 修改流程文件配置Hello 节点执行 sayHello操作
<?xml version="1.0" encoding="UTF-8"?><process name="Hello" xmlns="http://jbpm.org/4.4/jpdl"><start g="8,60,48,48" name="start"> <transition g="-45,-18" name="to say Hello" to="Hello"/></start><end g="358,62,48,48" name="end"/> <java g="154,46,92,52" method="sayHello" name="Hello"> <transition g="-36,-18" name="to end" to="end"/> </java></process>
?
4. 执行操作
??? 为了检验JBPM4模型,我们分部执行同时查看数据库数据
??? JBPM数据表结构清单
???
select * from JBPM4_DEPLOYMENT;select * from JBPM4_DEPLOYPROP;select * from JBPM4_EXECUTION;select * from JBPM4_HIST_ACTINST;select * from JBPM4_HIST_DETAIL;select * from JBPM4_HIST_PROCINST;select * from JBPM4_HIST_TASK;select * from JBPM4_HIST_VAR;select * from JBPM4_ID_GROUP;select * from JBPM4_ID_MEMBERSHIP;select * from JBPM4_ID_USER;select * from JBPM4_JOB;select * from JBPM4_LOB;select * from JBPM4_PARTICIPATION;select * from JBPM4_PROPERTY;select * from JBPM4_SWIMLANE;select * from JBPM4_TASK;select * from JBPM4_VARIABLE;
?
? (1) 创建流程引擎并发布此流程
??
package com.spring.hello;import org.jbpm.api.Configuration;import org.jbpm.api.ProcessEngine;public class ProcessEngineLearn {/** * @param args */public static void main(String[] args) {ProcessEngine pe = new Configuration().buildProcessEngine();String deploymentId = pe.getRepositoryService().createDeployment().addResourceFromClasspath("com\\spring\\hello\\Hello.jpdl.xml").deploy();System.out.println("deploymentId="+deploymentId);}}
?
??? 查看表数据:
?? JBPM4_PROPERTY 表记录了一条数据记录JBPM的属性信息,记录下个流程实例的版本信息。
??? KEY_?????????? VERSION_?? ?VALUE_
??? next.dbid??? 7????????????????? 70001
?? JBPM4_DEPLOYMENT?? 流程实例信息,记录流程实例的基本信息包括流程实例的状态,当前状态为Active
?? JBPM4_DEPLOYPROP?? 流程实例属性信息 ,记录流程实例的属性信息比如流程参考的jpdl版本信息,流程的名称信息,流程的版本信息等。
?? JBPM4_LOB?? 存储流程模板信息 ,记录了我们上面定义的用于描述流程的xml信息
?
(2) 将上面的流程再执行一次
????? 我们会发现JBPM4_DEPLOYMENT 表增加了一个流程实例ID=70001 的流程实例。
???? JBPM4_DEPLOYPROP?? 对应pdversion 对应的 值=2 上一个 =1.
?(3) 删除流程实例
????
ProcessEngine pe = new Configuration().buildProcessEngine(); pe.getRepositoryService().deleteDeployment("70001");
?数据库中删除了流程实例ID=70001 的相关信息
(4)启动流程实例
?
?