JBPM4.4 简的的应用

本文提供了一段使用JBPM引擎发起并管理流程实例的代码示例,包括流程定义、流程实例创建、执行流程及查看执行状态等基本操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 原理就备了

 

只接给大家点代码看看吧哈。。

 

package org.zk.liuqing.jbpm.test.helloworld;

import java.util.List;

import org.jbpm.api.Configuration;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;

/**
 * 
 * @author LiuQing
 * @see Jbpm 测试用例
 * @date 2009-7-5下午02:14:10
 * @version 1.0
 */
public class HelloWorldJbpm {


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//启动流程引擎
		ProcessEngine engine = Configuration.getProcessEngine();
		//专门用于管理流程实例
		ExecutionService executionService = engine.getExecutionService();
		//通过流程定义的Key来发起新流程
		executionService.signalExecutionById("helloworld.40001");
		//查看执行状态
		Execution execution = executionService.findExecutionById("helloworld.40001");
		System.out.println(execution.getState());

	}
	
	/**
	 * @see 根据已经定义的流程创建实例
	 */
	public void viewProcessInstance() {
		//启动流程引擎
		ProcessEngine engine = Configuration.getProcessEngine();
		//专门用于管理流程实例
		ExecutionService executionService = engine.getExecutionService();
		//通过流程定义的Key来发起新流程
		ProcessInstance processInstance = executionService.startProcessInstanceByKey("helloworld");
		//执行流程下一步
		processInstance = executionService.signalExecutionById(processInstance.getId());
		//是否正常结束
		boolean isEnd = processInstance.isEnded();
		System.out.println(isEnd);
		//查看流程列表
		List<ProcessInstance> processInstances = executionService.createProcessInstanceQuery().list();
		for (ProcessInstance en:processInstances) {
			System.out.println(en);
		}
		
	}
	
	/**
	 * @see 那立流程
	 */
	public void viewSystem() {
		
		//启动流程引擎
		ProcessEngine engine = Configuration.getProcessEngine();
		//获得流程服务
		RepositoryService service = engine.getRepositoryService();
		//发布流程定义信息到流程引擎中去
		String developementId = service.createDeployment()
		   .addResourceFromClasspath("org/zk/liuqing/jbpm/test/helloworld/helloworld.jpdl.xml").deploy();
		System.out.println(developementId);
		//查看以定询流程
		List<ProcessDefinition> definitions = service.createProcessDefinitionQuery().list();
		for (ProcessDefinition en:definitions) {
			System.out.println(en.getDeploymentId());
		}
		//删除部署流程
		service.deleteDeploymentCascade("10001");
		
	}

}

 

 

2. 环境文件就从jbpm中复制出来到项目中就OK

 

helloworld.jpdl.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>

<process description="start" name="helloworld" xmlns="http://jbpm.org/4.4/jpdl">
   <start g="180,22,48,48" name="start">
      <transition name="to s" to="s" g="-23,-18"/>
   </start>
   <state g="150,130,92,52" name="s">
      <transition name="to end" to="end" g="-36,-18"/>
   </state>
   <end g="188,259,48,48" name="end"/>
</process>
 

 

与JBPM3不同也不说了。。就这样吧

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值