1首先下载:jbpm4.4
2.然后安装MyEclipse jbpm的插件.在MyEclipse Configuration Center 中的Software 中
点击addsite 然后在弹窗中点击add form Archive File然后把下载的
jbpm- 4.4\install\src\gpd导入进来.然后继续在softeware中把jbpm4.4下拉框中的所有文件 Add to Profile,然后在窗口右上角可以看到apply. 点击下,插件就安装好了.
3.安装jbpm的数据库脚本 在jbpm4.4下/install/src/db/create 里面.根据你的数据库做选择.
各种表安装后,开始配置.
4.利用jbpm已经给我们弄好的简单的实例配置,全部复制到项目下.在jbpm4.4/example/src下的所有配置文件,不包括org.
5.实例主要用到了jbpm下的state 所以我们要先建立一个 流程图,
这里新建流程图 就用到插件了. 由于懒 就直接
里面的代码也要有点修改
6.差点忘记数据库的配置了. 我用的是oracle.连接字符串这些的就自己把握了.
7.建立一个有main方法的类.类中的代码是
import org.jbpm.api.Configuration;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
public class TestJbpm {
public static RepositoryService repositoryService = null;
public static ProcessEngine processEngine = null;
public static ExecutionService executionServicece = null;
public static void main(String[] args) {
//发布流程
processEngine = Configuration.getProcessEngine();
repositoryService = processEngine.getRepositoryService();
executionServicece = processEngine.getExecutionService();
String processId = repositoryService.createDeployment().addResourceFromClasspath("hellodWorld.jpdl.xml")
.deploy();
System.out.println("发布完成!:processId = " + processId);
//启动流程
ProcessInstance processInstance = executionServicece.startProcessInstanceByKey("StateSequence");
printLocation(processInstance);
//执行流程
Execution executionInA = processInstance.findActiveExecutionIn("a");
processInstance = executionServicece.signalExecutionById(executionInA.getId());
printLocation(processInstance);
Execution executionInB = processInstance.findActiveExecutionIn("b");
processInstance = executionServicece.signalExecutionById(executionInB.getId());
printLocation(processInstance);
Execution executionInE = processInstance.findActiveExecutionIn("helloWorld!");
processInstance = executionServicece.signalExecutionById(executionInE.getId());
}
//输出当前流程的位置!
public static void printLocation(ProcessInstance processInstance){
if(processInstance.isActive("a")){
System.out.println("流程到了a");
}else if(processInstance.isActive("b")){
System.out.println("流程到了b");
}else if(processInstance.isActive("helloWorld!")){
System.out.println("helloWorld!");
}
}
}
8.
public static RepositoryService repositoryService = null;
public static ProcessEngine processEngine = null;
public static ExecutionService executionServicece = null;
public static ProcessEngine processEngine = null;
public static ExecutionService executionServicece = null;
这三个类中:第一个是用到发布流程的,第二个是控制全局的,
第三个是用来取得流程实例,且可以执行流程的
processEngine = Configuration.getProcessEngine();
repositoryService = processEngine.getRepositoryService();
executionServicece = processEngine.getExecutionService();
processEngine = Configuration.getProcessEngine();
repositoryService = processEngine.getRepositoryService();
executionServicece = processEngine.getExecutionService();
9.效果图: