打开jbpm-test-6.1.0.Final.jar找到usergroups.properties文件,这个文件里的10个用户可以在测试代码里使用,等号左边是用户名右边是用户所在的组(例如:john=admins,managers,users,PM)
修改sample.bpmn文件,自定义流程节点,笔者这里模拟一个请假申请书的例子,截图如下:
修改后的ProcessMain.java文件内容如下:
package com.sample;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.jbpm.test.JBPMHelper;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.manager.RuntimeEngine;
import org.kie.api.runtime.manager.RuntimeEnvironmentBuilder;
import org.kie.api.runtime.manager.RuntimeManager;
import org.kie.api.runtime.manager.RuntimeManagerFactory;
import org.kie.api.task.TaskService;
import org.kie.api.task.model.TaskSummary;
public class ProcessMain {
public static void main(String[] args) {
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieBase kbase = kContainer.getKieBase("kbase");
RuntimeManager manager = createRuntimeManager(kbase);
RuntimeEngine engine = manager.getRuntimeEngine(null);
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
Map<String, Object> params = new HashMap<String, Object>();
params.put("recipient", "kylin");
ksession.startProcess("com.sample.bpmn.hello", params);
// let salaboy execute Task 1
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
TaskSummary task = list.get(0);
System.out.println("Salaboy is executing task " + task.getName());
taskService.start(task.getId(), "salaboy");
taskService.complete(task.getId(), "salaboy", null);
// let john execute Task 2
list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
task = list.get(0);
System.out.println("John is executing task " + task.getName());
taskService.start(task.getId(), "john");
taskService.complete(task.getId(), "john", null);
// let mary execute Task 3
list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
task = list.get(0);
System.out.println("Mary is executing task " + task.getName());
taskService.start(task.getId(), "mary");
taskService.complete(task.getId(), "mary", null);
manager.disposeRuntimeEngine(engine);
System.exit(0);
}
private static RuntimeManager createRuntimeManager(KieBase kbase) {
JBPMHelper.startH2Server();
JBPMHelper.setupDataSource();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).knowledgeBase(kbase);
return RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(builder.get());
//return RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(builder.get(), "com.sample:example:1.0");
}
}
在eclipse里运行ProcessMain.java文件会在控制台得到如下结果:
Salaboy is executing task 起草请假申请书
John is executing task 部门经理审批
Mary is executing task 区域总监审批
- 大小: 137.8 KB
- 大小: 171.9 KB
分享到:
相关推荐
jbpm-flow-builder-5.1.0.Final.jar jbpm5
【jbpm-kie-services-6.1.0.Beta4.zip】这个压缩包是JBoss Business Automation Projects(以前称为jBPM)中的一个版本,它是一个开源的工作流和业务流程管理套件。jBPM专注于提供全面的业务流程自动化解决方案,...
jbpm-jpdl-suite-3.2.GA.zip
jbpm-persistence-jpa-5.1.0.Final.jar jbpm5
jbpm-human-task-5.1.0.Final.jar jbpm5
3.1.4.jar jbpm-identity-3.1.4.jar jbpm-identity-src-3.1.4.jar jbpm-src-3.1.4.jar jbpm-webapp-3.1.4.jar jcommon-1.0.0.jar jfreechart-1.0.1.jar junit-3.8.1.jar jxl.jar log4j-1.2.8.jar mysqldriver.jar ...
jbpm-human-task-5.1.0.Final-sources.jar jbpm5 源码
jbpm-persistence-jpa-5.1.0.Final-sources.jar jbpm5 源码
jbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3.zipjbpm-jpdl-suite-3.2.3....
jbpm-flow-5.1.0.Final.jar jbpm5
jbpm-bam-5.1.0.Final.jar jbpm5
在配置jbpm-jpdl-suite-3.2.3的过程中,需要注意以下几个关键步骤: 1. **环境准备**: - 首先,确保你已经安装了JDK 1.6,因为jbpm-jpdl-suite-3.2.3需要依赖Java运行环境。 - 安装Ant 1.7.1,这是一个Java编译...
jbpm-jpdl-suite-3.2.GA.zip
jbpm-jpdl-suite-3.2.GA.zip
jbpm-bpmn2-5.1.0.Final.jar jbpm5
jbpm-starters-kit-3.1.2.插件,jbpm-starters-kit-3.1.2.插件,jbpm-starters-kit-3.1.2.插件,jbpm-starters-kit-3.1.2.插件,jbpm-starters-kit-3.1.2.插件,jbpm-starters-kit-3.1.2.插件,jbpm-starters-kit-...
jbpm-jpdl-suite-3.2.GA.zip
5. **ejb服务与定时器**:jbpm-services-ejb-timer-7.3.0.Final.jar和jbpm-services-ejb-client-7.3.0.Final.jar提供了基于EJB的定时服务和客户端接口,使得jBPM能够集成到Java EE环境中,实现定时触发流程事件或...