??
整合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服务
?
??????????????
Java代码 ?

- 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;??
- ??
- ?
- ?
- ?
- ?
- ?
- ??
- 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;??
- ????}??
- ??????
- ??????
- ??????
- ?????
- ?
- ?
- ?
- ??
- ????public?String?deployNew(String?resourceName)?{??
- ????????return?repositoryService.createDeployment().addResourceFromClasspath(??
- ????????????????resourceName).deploy();??
- ????}??
- ??
- ??????
- ?????
- ?
- ?
- ?
- ??
- ????public?String?deployZipNew(String?resourceZipName){??
- ????????ZipInputStream?zis?=?new?ZipInputStream(this.getClass().getResourceAsStream(resourceZipName));??
- ??????????
- ????????return?repositoryService.createDeployment().addResourcesFromZipInputStream(zis).deploy();?????
- ??????????
- ????}??
- ??????
- ??????
- ?????
- ?
- ?
- ?
- ?
- ??
- ??????
- ????public?ProcessInstance?startPIById(String?id,Map<String,?>?map){????
- ??????????
- ????????return?executionService.startProcessInstanceById(id,?map);????????
- ??????????
- ????}??
- ??????
- ?????
- ?
- ?
- ?
- ??
- ??????
- ????public?void?completeTask(String?taskId,Map?map){??
- ??????????
- ????????taskService.completeTask(taskId,?map);????
- ????}??
- ??????
- ?????
- ?
- ?
- ??
- ????public?void?completeTask(String?taskId){??
- ????????taskService.completeTask(taskId);??
- ????}??
- ??????
- ??????
- ?????
- ?
- ?
- ?
- ??
- ????public?void?completeTask(String?taskId,String?outcome){??
- ????????taskService.completeTask(taskId,?outcome);??
- ????}??
- ??
- ?????
- ?
- ?
- ??
- ????public?List<ProcessDefinition>?getAllPdList(){??
- ????????return?repositoryService.createProcessDefinitionQuery().list();??
- ????}??
- ??????
- ?????
- ?
- ?
- ??
- ????public?List<ProcessInstance>?getAllPiList(){??
- ????????return?executionService.createProcessInstanceQuery().list();??
- ????}??
- ??????
- ?????
- ?
- ?
- ?
- ?
- ??
- ????public?Object?getVariableByexecutionId(String?executionId,String?variableName){??
- ????????return?executionService.getVariable(executionId,?variableName);??
- ????}??
- ??????
- ??????
- ?????
- ?
- ?
- ?
- ?
- ??
- ????public?Object?getVariableByTaskId(String?taskId,String?variableName){??
- ????????return?taskService.getVariable(taskId,?variableName);??
- ????}??
- ??????
- ?????
- ?
- ?
- ?
- ??
- ????public?List<Task>?findPersonalTasks(String?userName){??
- ????????return?taskService.findPersonalTasks(userName);??
- ????}??
- ??????
- ?????
- ?
- ?
- ?
- ??
- ????public?Task?getTask(String?taskId)?{??
- ????????return?taskService.getTask(taskId);??
- ??????????
- ????}??
- ??????
- ??????
- ??
- ?????
- ?
- ?
- ?
- ??
- ????public?void?deleteDeploymentCascade(String?deploymentId)?{??
- ????????repositoryService.deleteDeploymentCascade(deploymentId);??
- ????}??
- ??
- ??????
- ??
- ??????
- ??
- ??????
- ??
- }??
?
?
?? 完整的application.xml:
?
??
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">??
- ??
- ??
- ??????
- ????<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>??
- ??????
- ??????
- ????<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>??
- ??????????????????
- ????????????????<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>??
- ??????
- ??????
- ??
- ??????
- ????<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>??
?
?
?
?? 当然其他的配置还是比较多的。大家可以参照我前一篇文章。
?
?? ok.基本就是这样。具体的大家可以直接看项目
?? 运行环境:myeclipse8.5+jBPM4.4+jdk1.6+sql server 2000(貌似网上没找到这种建表语句。所以我也上传了)。
????????????????? 其他的主要建表语句在installsrcdb下面。
?
?? 比较大,jar包都没有放的。
-
jBPM4.4库表_sqlserver2000_.rar (4.6 KB)
- 描述: jBPM4.4自带的18张表
- 下载次数: 366
-
leave.rar (371 Bytes)
- 描述: 这个实例中用到的2张库表
- 下载次数: 431
-
jBPM4.4_ssh.rar (75.8 KB)
- 下载次数: 731
转载至http://hellotommy.iteye.com/blog/804233
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|