JBPM4.4 简的的应用

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不同也不说了。。就这样吧

相关推荐