紫竹blog

生命应该浪费在美好的事情上……

JBPM工作流初步(下)

第一步:建立所有的jbpm表以及公文表

Jbpm_01_CreateSchema.java类

package com.jbpm;

import org.jbpm.JbpmConfiguration;
import org.junit.Test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Jbpm_01_CreateSchema {
	private Log logger = LogFactory.getLog(Jbpm_01_CreateSchema.class);
	private JbpmConfiguration jbpmConfig = JbpmConfiguration.getInstance();
	
	@Test
	public void testCreateSchema(){
		jbpmConfig.createSchema();
	}
	
}

执行此测试类后,查询数据库,得到下面所有的jbpm表,以及自定义的公文表:


第二步:测试jbpm根据流程文件发布流程,流程文件process.xml文件如下,直接复制吧,自己写也没什么意思:

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

<process-definition 
  xmlns="urn:jbpm.org:jpdl-3.2"
  name="文档测试流程" >
  <start-state name="开始">
      <transition name="提交张三审批" to="张三审批"></transition>
   </start-state>
   <task-node name="张三审批">
      <task name="审批1">
		<assignment actor-id="张三" />
	  </task>
      <transition name="提交李四审批" to="李四审批"></transition>
   </task-node> 
   <task-node name="李四审批">
      <task name="审批2">
		<assignment actor-id="李四" />
	  </task>
      <transition name="提交王五审批" to="王五审批"></transition>
   </task-node>  
   <task-node name="王五审批">
      <task name="审批3">
		<assignment actor-id="王五" />
	  </task>
      <transition name="流程结束" to="结束"></transition>
   </task-node>  
   <end-state name="结束"></end-state>
</process-definition>

Jbpm_02_DeployProcessDefinition.java类

package com.jbpm;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.junit.Test;

public class Jbpm_02_DeployProcessDefinition {
	private Log logger = LogFactory.getLog(Jbpm_02_DeployProcessDefinition.class);
	private JbpmConfiguration jbpmConfig = JbpmConfiguration.getInstance();
	
	@Test
	public void testDeployProcessDefinition(){
		JbpmContext context = jbpmConfig.createJbpmContext();
		ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("process.xml");
		context.deployProcessDefinition(processDefinition);
		//这个地方一定要记得关闭context,否则事务有可能不会提交
		context.close();		
	}
	
}
执行此类后,查询jbpm_node表,得到如下内容:



第三步:


阅读更多
个人分类: javaEE
想对作者说点什么? 我来说一句

jBPM4工作流示例jbpmDemo

2017年02月16日 176.92MB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭