Jbpm4環境搭建和整合Spring

livedba發表於2012-07-26
Jbpm4環境搭建和整合Spring,這裡關於jbpm4的資料庫表和jar匯入就不說了,主要講一下關鍵點配置檔案[@more@]

jbpm.cfg.xml配置檔案內容如下:







<!--使用spring的事務管理器--&gt




<!--


--&gt

<!-- Job executor is excluded for running the example test cases. --&gt
<!--



--&gt

spring配置檔案applicationContext.xml中hibernate配置新增:




classpath:jbpm.repository.hbm.xml
classpath:jbpm.execution.hbm.xml
classpath:jbpm.history.hbm.xml
classpath:jbpm.task.hbm.xml
classpath:jbpm.identity.hbm.xml


然後配置jbpm4的工廠bean


<!--工作流統一service介面,業務封裝用--&gt




jbpmService的實現類如下

package net.uni.ap.jbpm.bo;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipInputStream;

import net.uni.ap.exp.BOException;
import net.uni.ap.exp.DAOException;
import net.uni.ap.jbpm.BaseJbpmTask;
import net.uni.ap.jbpm.BaseJbpmVar;
import net.uni.ap.jbpm.JbpmConstants;
import net.uni.ap.jbpm.dao.IJbpmDAO;
import net.uni.ap.jbpm.handle.CountJoinsignTaskCmd;
import net.uni.ap.jbpm.model.Deploy;
import net.uni.ap.jbpm.model.JbpmTask;
import net.uni.in1.BaseDictConstants;
import net.uni.in1.bo.IBaseUserRoleBO;
import net.uni.in1.model.BaseUserRole;
import net.uni.in1.model.User;
import net.uni.util.Page;

import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.HistoryService;
import org.jbpm.api.JbpmException;
import org.jbpm.api.ManagementService;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.ProcessInstanceQuery;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
import org.jbpm.api.history.HistoryActivityInstance;
import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.api.history.HistoryTask;
import org.jbpm.api.history.HistoryTaskQuery;
import org.jbpm.api.model.ActivityCoordinates;
import org.jbpm.api.task.Task;

/**
* 處理內容:jbpm統一介面實現類
* @version: 1.0
* @see:net.uni.ap.jbpm.bo.JbpmBOImpl.java
* @date:2012-2-21
* @author:孫偉
*/
public class JbpmBOImpl implements IJbpmBO {

private ProcessEngine processEngineService;
private RepositoryService repositoryService = null;
private ExecutionService executionService = null;
private TaskService taskService = null;
private HistoryService historyService = null;
private ManagementService managementService = null;
private IJbpmDAO jbpmDAO;
private IBaseUserRoleBO baseUserRoleService;

public JbpmBOImpl(ProcessEngine processEngineService) {
super();
this.processEngineService = processEngineService;
this.repositoryService = processEngineService.getRepositoryService();
this.executionService = processEngineService.getExecutionService();
this.taskService = processEngineService.getTaskService();
this.historyService = processEngineService.getHistoryService();
this.managementService = processEngineService.getManagementService();
}
public JbpmBOImpl() {
super();
}

/**
* @return the processEngineService
*/
public ProcessEngine getProcessEngineService() {
return processEngineService;
}
/**
* @param processEngineService the processEngineService to set
*/
public void setProcessEngineService(ProcessEngine processEngineService) {
this.processEngineService = processEngineService;
this.repositoryService = processEngineService.getRepositoryService();
this.executionService = processEngineService.getExecutionService();
this.taskService = processEngineService.getTaskService();
this.historyService = processEngineService.getHistoryService();
this.managementService = processEngineService.getManagementService();
}
/**
* @return the repositoryService
*/
public RepositoryService getRepositoryService() {
return repositoryService;
}
/**
* @param repositoryService the repositoryService to set
*/
public void setRepositoryService(RepositoryService repositoryService) {
this.repositoryService = repositoryService;
}
/**
* @return the executionService
*/
public ExecutionService getExecutionService() {
return executionService;
}
/**
* @param executionService the executionService to set
*/
public void setExecutionService(ExecutionService executionService) {
this.executionService = executionService;
}
/**
* @return the taskService
*/
public TaskService getTaskService() {
return taskService;
}
/**
* @param taskService the taskService to set
*/
public void setTaskService(TaskService taskService) {
this.taskService = taskService;
}
/**
* @return the historyService
*/
public HistoryService getHistoryService() {
return historyService;
}
/**
* @param historyService the historyService to set
*/
public void setHistoryService(HistoryService historyService) {
this.historyService = historyService;
}
/**
* @return the managementService
*/
public ManagementService getManagementService() {
return managementService;
}
/**
* @param managementService the managementService to set
*/
public void setManagementService(ManagementService managementService) {
this.managementService = managementService;
}
public IJbpmDAO getJbpmDAO() {
return jbpmDAO;
}
public void setJbpmDAO(IJbpmDAO jbpmDAO) {
this.jbpmDAO = jbpmDAO;
}
@Override
public Map getTaskVariableByTaskId(String taskId) throws BOException {
return taskService.getVariables(taskId, taskService.getVariableNames(taskId));
}
public IBaseUserRoleBO getBaseUserRoleService() {
return baseUserRoleService;
}
public void setBaseUserRoleService(IBaseUserRoleBO baseUserRoleService) {
this.baseUserRoleService = baseUserRoleService;
}
}
到這裡,Jbpm4的環境搭建基本完成,後續的介面呼叫都透過業務jbpmService來完成,因為這個注入了所有jbpm的service

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25261409/viewspace-1059010/,如需轉載,請註明出處,否則將追究法律責任。

相關文章