JBPM4.4+SSH 整合配置及完整实例
整合jBPM4.4+ssh过程(spring接管struts2和hibernate,例中都整合在application.xml中,没有单独的jbpm.hibernate.cfg.xml):
1.在sessionFactory的mappingLocations属性加入以下几个jbpm.*.hbm.xml由jBPM自带
<value>classpath:jbpm.repository.hbm.xml</value>
<value>classpath:jbpm.execution.hbm.xml</value>
<value>classpath:jbpm.history.hbm.xml</value>
<value>classpath:jbpm.task.hbm.xml</value>
<value>classpath:jbpm.identity.hbm.xml</value>
2.jBPM自己内部的配置(spring来接管processEngine)
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-
method="createProcessEngine" />
这样子就配好啦。只要在要用的地方注入processEngine就可以了!简单吧
3.当然为了编程的方便,可以自己写个工具类,直接就可以通过注入这个类来获取所需要的jBPM服务
package com.ht.util; import java.util.List;
import java.util.Map;
import java.util.zip.ZipInputStream;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.HistoryService;
import org.jbpm.api.ManagementService;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Task; /**
* jBPM4.4工具类
*
* @author ht
*
*/
public class JBPMUtil { private ProcessEngine processEngine;
private RepositoryService repositoryService = null;
private ExecutionService executionService = null;
private TaskService taskService = null;
private HistoryService historyService = null;
private ManagementService managementService = null; public JBPMUtil(){ }
public JBPMUtil(ProcessEngine processEngine) {
this.processEngine = processEngine;
repositoryService = processEngine.getRepositoryService();
executionService = processEngine.getExecutionService();
taskService = processEngine.getTaskService();
historyService = processEngine.getHistoryService();
managementService = processEngine.getManagementService();
} public ProcessEngine getProcessEngine() {
return processEngine;
} public void setProcessEngine(ProcessEngine processEngine) {
this.processEngine = processEngine;
System.out.println("processEngine="+processEngine);
repositoryService = processEngine.getRepositoryService();
executionService = processEngine.getExecutionService();
taskService = processEngine.getTaskService();
historyService = processEngine.getHistoryService();
managementService = processEngine.getManagementService();
} public RepositoryService getRepositoryService() {
return repositoryService;
} public void setRepositoryService(RepositoryService repositoryService) {
this.repositoryService = repositoryService;
} public ExecutionService getExecutionService() {
return executionService;
} public void setExecutionService(ExecutionService executionService) {
this.executionService = executionService;
} public TaskService getTaskService() {
return taskService;
} public void setTaskService(TaskService taskService) {
this.taskService = taskService;
} public HistoryService getHistoryService() {
return historyService;
} public void setHistoryService(HistoryService historyService) {
this.historyService = historyService;
} public ManagementService getManagementService() {
return managementService;
} public void setManagementService(ManagementService managementService) {
this.managementService = managementService;
} /**
* 部署新流程定义
* @param resourceName
* @return 返回流程定义id
*/
public String deployNew(String resourceName) {
return repositoryService.createDeployment().addResourceFromClasspath(
resourceName).deploy();
} /**
* 部署新流程定义(zip)
* @param resourceName
* @return 返回流程定义id
*/
public String deployZipNew(String resourceZipName){
ZipInputStream zis = new ZipInputStream(this.getClass().getResourceAsStream(resourceZipName));
return repositoryService.createDeployment().addResourcesFromZipInputStream(zis).deploy();
} /**
* 开始一个流程实例
* @param id
* @param map
* @return
*/ public ProcessInstance startPIById(String id,Map<String,?> map){
return executionService.startProcessInstanceById(id, map);
} /**
* 完成任务
* @param taskId
* @param map
*/ public void completeTask(String taskId,Map map){
taskService.completeTask(taskId, map);
} /**
* 完成任务
* @param taskId
*/
public void completeTask(String taskId){
taskService.completeTask(taskId);
} /**
* 将任务流转到指定名字的流程outcome中去
* @param taskId
* @param outcome
*/
public void completeTask(String taskId,String outcome){
taskService.completeTask(taskId, outcome);
} /**
* 获得所有发布了的流程
* @return
*/
public List<ProcessDefinition> getAllPdList(){
return repositoryService.createProcessDefinitionQuery().list();
} /**
* 获得所有流程实例
* @return
*/
public List<ProcessInstance> getAllPiList(){
return executionService.createProcessInstanceQuery().list();
} /**
* 根据流程实例Id,即executionId获取指定的变量值
* @param executionId
* @param variableName
* @return
*/
public Object getVariableByexecutionId(String executionId,String variableName){
return executionService.getVariable(executionId, variableName);
} /**
* 根据任务id,即taskId获取指定变量值
* @param taskId
* @param variableName
* @return
*/
public Object getVariableByTaskId(String taskId,String variableName){
return taskService.getVariable(taskId, variableName);
} /**
* 获取指定用户名字的任务
* @param userName
* @return
*/
public List<Task> findPersonalTasks(String userName){
return taskService.findPersonalTasks(userName);
} /**
* 根据任务id获取任务
* @param taskId
* @return
*/
public Task getTask(String taskId) {
return taskService.getTask(taskId);
} /**
* 级联删除流程定义,直接删除该流程定义下的所有实例
*
* @param deploymentId 流程定义id
*/
public void deleteDeploymentCascade(String deploymentId) {
repositoryService.deleteDeploymentCascade(deploymentId);
}
}
完整的application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 配置数据源,导入c3p0-0.9.1.2.jar-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:jtds:sqlserver://localhost:1433;DatabaseName=jBPM</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value>123</value>
</property>
</bean> <bean name="hibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop> </props>
</property>
</bean> <!-- spring集成hibernate配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties" ref="hibernateProperties" />
<property name="mappingLocations">
<list>
<value>classpath*:com/ht/entity/*.hbm.xml</value>
<!-- 以下几个jbpm.*.hbm.xml由jBPM自带 -->
<value>classpath:jbpm.repository.hbm.xml</value>
<value>classpath:jbpm.execution.hbm.xml</value>
<value>classpath:jbpm.history.hbm.xml</value>
<value>classpath:jbpm.task.hbm.xml</value>
<value>classpath:jbpm.identity.hbm.xml</value>
</list>
</property>
</bean> <!-- jbpm配置 -->
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" /> <bean id="jBPMUtil" class="com.ht.util.JBPMUtil">
<property name="processEngine" ref="processEngine"></property>
</bean> <!-- 事务配置 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
本文转自:http://hellotommy.iteye.com/blog/804233
JBPM4.4+SSH 整合配置及完整实例的更多相关文章
- jBPM4.3+ssh+会签 整合配置及完整实例
大佬们的项目里有用到会签,所以趁双休日研究了下. 其实也是简单的会签情况,不过开始的时候研究了4.4,(因为先前研究的都是4.4),发现4.4跟4.3的处理方法完全不一样,搞的我比较郁闷……弄了一天, ...
- Spring+Hibernate整合配置 --- 比较完整的spring、hibernate 配置
Spring+Hibernate整合配置 分类: J2EE2010-11-25 17:21 16667人阅读 评论(1) 收藏 举报 springhibernateclassactionservlet ...
- SSH整合配置二级缓存
一.了解 Hibernate的session提供了一级缓存,每个session,对同一个id进行两次load,不会发送两条sql给数据库,但session关闭时,一级缓存失效. 二级缓存是Sessio ...
- java SSH整合配置
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="3 ...
- springmvc 项目完整示例05 日志 --log4j整合 配置 log4j属性设置 log4j 配置文件 log4j应用
log4j 就是log for java嘛,老外都喜欢这样子,比如那个I18n ---internationalization 不就是i和n之间有18个字母... http://logging.a ...
- ssh整合hibernate 使用spring管理hibernate二级缓存,配置hibernate4.0以上二级缓存
ssh整合hibernate 使用spring管理hibernate二级缓存,配置hibernate4.0以上二级缓存 hibernate : Hibernate是一个持久层框架,经常访问物理数据库 ...
- Spring和ActiveMQ整合的完整实例
Spring和ActiveMQ整合的完整实例 前言 这篇博文,我们基于Spring+JMS+ActiveMQ+Tomcat,做一个Spring4.1.0和ActiveMQ5.11.1整合实例,实现了 ...
- Hibernate 注解时 hibernate.hbm.xml的配置方法 以及与SSH整合里的配置方式
①纯Hibernate开发: 当你在Bean中写入注解后,需要告诉hibernate哪些类使用了注解. 方法是在hibernate.hbm.xml文件中配置 <!DOCTYPE hibernat ...
- SSH整合,applicationContext.xml中配置hibernate映射文件问题
今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...
随机推荐
- 【Python】Django 时间字段 最佳实践
. python datetime from datetime import datetime datetime.now() datetime.utcnow() from datetime impor ...
- js删除提醒
2014年7月3日 16:28:03 html <input type="submit" name="submit" value="删除&quo ...
- mysql5.6 timestamp
1.timestamp 默认值 CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 在创建新记录和修改现有记录的时候都对这个数据列刷新 CURRENT_TIME ...
- 【JAVA、C++】LeetCode 001 Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The ...
- DP:Coins(POJ 1742)
用硬币换钱 题目大意:就是有面值为A1,A2,A3....的硬币,各有C1,C2,C3...的数量,问在钱数为m的范围内,能换多少钱?(不找零) 这题看名字就知道是完全背包,但是这题又有点不一样, ...
- 【python】继承时注意事项
1. __init__ 注意事项 如果父类有__init__函数,子类没有,则子类自动调用父类__init__函数 如果父类有__init__函数,子类也有,则子类必须主动调用父类__init__函数 ...
- GLSL
变量修饰符 修饰符给出了变量的特殊含义,GLSL中有如下修饰符: ·const – 声明一个编译期常量. ·attribute– 随不同顶点变化的全局变量,由OpenGL应用程序传给顶点shader. ...
- git merge和个git rebase的区别
http://stackoverflow.com/questions/16666089/whats-the-difference-between-git-merge-and-git-rebase/16 ...
- weblogic 安装和部署项目(原创)
1.下载weblogic(含破解文件,土豪请支持正版,谢谢!) 2.安装如下图: 3.新建domain 4.打开weblogic Console 5.开始部署项目 6.部署成功
- linux下跳板机跟客户端之间无密码登陆
创建证书: [root@lnmp src]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which ...