部署JBPM 流程

JBPM流程开发完成之后,首先需要部署流程,才可以运行。
/* 
package com.ibm.cdl.scst.service;

import org.apache.log4j.Logger;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.ProcessDefinition;
import org.springmodules.workflow.jbpm31.JbpmCallback;

import com.ibm.cdl.scst.BaseTestCase;

public class ProcessDefinitionDeploymentTest extends BaseTestCase {
	static Logger logger = Logger.getLogger(ProcessDefinitionDeploymentTest.class);
	
	private ProcessService processService;
	
	/*
	 * 注意流程间的顺序: 子流程在前, 父流程在后; 
	 * 此处的名字对应于在Spring为流程定义所定义的Bean的名字
	 */
	private String [] processDefinitionBeanNames = { //please make sure the order
			"subSunsetProcessDefinition",
			"systemSunsetProcessDefinition"
			
	};
	
	public void setProcessService(ProcessService processService) {
		this.processService = processService;
	}

	public void testDeploymentOnly() {
		logger.debug("Start deploying the process definition....");
		deployDefinitionByNames(processDefinitionBeanNames);
		this.setComplete();
	}

	
	/**
	 * 对给定的流程进行发布
	 * <p>
	 * <strong>注意:</strong> 目前使用procesService的deployProcess时出现获取不到当前context的情况, 因此采用此方式加以实现;
	 * </p> 
	 * 
	 * @param defNames
	 * 			为待发布流程所定义的Spring Bean的名字
	 * @return	流程定义发布结果
	 */	
	private Boolean deployDefinitionByNames(final String [] defNames){
		return (Boolean)processService.execute(new JbpmCallback(){
			public Object doInJbpm(JbpmContext context) throws JbpmException {
				for(int i = 0; i < defNames.length; i ++){
					ProcessDefinition pdf = (ProcessDefinition) getApplicationContext().getBean(defNames[i],
							ProcessDefinition.class);
					try {
						context.getGraphSession().deployProcessDefinition(pdf);
					} catch (Exception e) {
						if(logger.isDebugEnabled()){
							logger.debug("Deploy definition failed. ", e);
						}
						return Boolean.FALSE;
					}
					logger.debug("Deploying the process definition: " + defNames[i]);
				}
				
				return Boolean.TRUE;
			}
		});
	}
}

你可能感兴趣的:(workflow,jbpm)