流程实例的执行

流程定义【ProcessDefinition】:流程定义是对业务过程步骤的描述,在jBPM4中它表现为若干“活动”节点通过“转移(transition)”线条串联。

流程实例【ProcessInstance】:流程实例是表示流程定义在运行时特有的执行例程。打个比方:可以把流程定义理解为Java Class定义,而流程实例则可以理解为有Java Class定义实例化生成的Java Object对象。

执行【execution】:一个流程实例在其生命周期中,最典型的特征就是具有指向当前执行活动的指针—“执行”。

 

流程定义的查询:

 

import java.util.List;

import org.jbpm.api.Configuration;
import org.jbpm.api.NewDeployment;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;

/**
 * @author fish
 * @version 1.0
 * @created 2011-5-2 下午11:11:47
 */

public class ProcessDefinitionTest
{

	/**
	 * 描述 jBPM部署流程: 1.获得Configuration的实例。 2.获得ProcessEngine流程对象;
	 * 3.获得RepositoryService对象 4.获得NewDeployment对象并增加流程资源 5.完成实际的部署
	 */
	public static void main(String[] args)
	{
		Configuration configuration = new Configuration();
		ProcessEngine processEngine = configuration.buildProcessEngine();
		RepositoryService repositoryService = processEngine
				.getRepositoryService();
		NewDeployment newDeployment = repositoryService.createDeployment()
				.addResourceFromClasspath("firstprocess.jpdl.xml");
		String deploymentId = newDeployment.deploy();
		System.out.println("deploymentId:" + deploymentId);

		List<ProcessDefinition> list = repositoryService
				.createProcessDefinitionQuery().list();

		for (ProcessDefinition processDefinition : list)
		{
			System.out.println(processDefinition.getDeploymentId() + ", "
					+ processDefinition.getId() + ", "+processDefinition.getName());
		}
		System.out.println(list.size());
	}

 流程定义的执行:

 

 

import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessInstance;

import org.jbpm.api.ProcessEngine;


/**    
 * @author fish      
 * @version 1.0    
 * 流程实例的执行
 * @created 2011-5-3 下午08:38:02   
 */

public class ExecutionTest
{

	public static void main(String[] args)
	{
		Configuration configuration = new Configuration();
		ProcessEngine processEngine = configuration.buildProcessEngine();
		
		ExecutionService executionService = processEngine.getExecutionService();
		
		//ProcessInstance processInstance = executionService.startProcessInstanceByKey("firstprocess");
		//id={key}-{version}
		ProcessInstance processInstance = executionService.startProcessInstanceById("firstprocess-2");
		
		System.out.println("processInstance id"+processInstance.getId());
		System.out.println(processInstance.isEnded());
	}
}

 流程定义的执行1:

 

import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.NewDeployment;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;

import org.jbpm.api.ProcessEngine;


/**    
 * @author fish      
 * @version 1.0    
 * 流程实例的执行
 * @created 2011-5-3 下午08:38:02   
 * 注意:使用jBPM时需要将Hibernate的MySQL方言org.hibernate.dialect.MySQLDialect修改为
 * org.hibernate.dialect.MySQL5InnoDBDialect
 */

public class ExecutionTest1
{

	public static void main(String[] args)
	{
		Configuration configuration = new Configuration();
		ProcessEngine processEngine = configuration.buildProcessEngine();
		RepositoryService repositoryService = processEngine.getRepositoryService();
		NewDeployment newDeployment = repositoryService.createDeployment()
				.addResourceFromClasspath("firstprocess.jpdl.xml");
		newDeployment.deploy();
		
		ExecutionService executeService = processEngine.getExecutionService();
		ProcessInstance processInstance = executeService.startProcessInstanceByKey("firstprocess");
		System.out.println(processInstance.isEnded());
		ProcessInstance processInstance1 = executeService.signalExecutionById(processInstance.getId());
		System.out.println(processInstance1.isEnded());
	}
	
	
}

  注意:使用jBPM时需要将Hibernate的MySQL方言org.hibernate.dialect.MySQLDialect修改为

  org.hibernate.dialect.MySQL5InnoDBDialect

你可能感兴趣的:(Hibernate,xml,mysql,jbpm)