第一步:导入所需jar包:
具体所需jar包见附件图片
第二步:修改jbpm配置文件:
1、src目录下建立jbpm.cfg.xml(注意注释部分)
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<process-engine-context>
<string name="spring.cfg" value="applicationContext.xml" />
</process-engine-context>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.tx.spring.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.console.cfg.xml" />
<import resource="jbpm.spring.default.cfg.xml"/>
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->
</jbpm-configuration>
2、src目录下建立jbpm.spring.default.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<process-engine-context>
<repository-service />
<repository-cache />
<execution-service />
<history-service />
<management-service />
<identity-service />
<task-service />
<!--
<hibernate-configuration>
<cfg resource="jbpm.hibernate.cfg.xml" />
</hibernate-configuration>
<hibernate-session-factory />
-->
<script-manager default-expression-language="juel"
default-script-language="juel"
read-contexts="execution, environment, process-engine"
write-context="">
<script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
</script-manager>
<authentication />
<id-generator />
<types resource="jbpm.variable.types.xml" />
<address-resolver />
<business-calendar>
<monday hours="9:00-12:00 and 12:30-17:00"/>
<tuesday hours="9:00-12:00 and 12:30-17:00"/>
<wednesday hours="9:00-12:00 and 12:30-17:00"/>
<thursday hours="9:00-12:00 and 12:30-17:00"/>
<friday hours="9:00-12:00 and 12:30-17:00"/>
<holiday period="01/07/2008 - 31/08/2008"/>
</business-calendar>
<mail-template name='task-notification'>
<to users="${task.assignee}"/>
<subject>${task.name}</subject>
<text><![CDATA[Hi ${task.assignee},
Task "${task.name}" has been assigned to you.
${task.description}
Sent by JBoss jBPM
]]></text>
</mail-template>
<mail-template name='task-reminder'>
<to users="${task.assignee}"/>
<subject>${task.name}</subject>
<text><![CDATA[Hey ${task.assignee},
Do not forget about task "${task.name}".
${task.description}
Sent by JBoss jBPM
]]></text>
</mail-template>
</process-engine-context>
<transaction-context>
<repository-session />
<db-session />
<message-session />
<timer-session />
<history-session />
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
</mail-server>
</mail-session>
</transaction-context>
</jbpm-configuration>
第三步:修改Spring配置文件
1、applicationContext.xml中加入springHelper配置,作为jbpm processEngine的factory bean
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
<property name="jbpmCfg" value="jbpm.cfg.xml" />
</bean>
2、applicationContext.xml中加入processEngine配置,并以此为factory bean创建JBPM本身的各种Service
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/>
<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService"/>
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/>
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>
3、applicationContext.xml的hibernate配置中加入jbpm所需的hbm.xml配置
<property name="mappingLocations">
<list>
<value>classpath:jbpm.execution.hbm.xml</value>
<value>classpath:jbpm.history.hbm.xml</value>
<value>classpath:jbpm.identity.hbm.xml</value>
<value>classpath:jbpm.repository.hbm.xml</value>
<value>classpath:jbpm.task.hbm.xml</value>
</list>
</property>
4、完整的applicationContext.xml(包括其余DataSource、SessionFacotry、事务控制等)
applicationContext.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
<import resource="serviceContext.xml" />
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
<property name="jbpmCfg" value="jbpm.cfg.xml" />
</bean>
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/>
<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService"/>
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/>
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>
<bean id="mainDataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@XXXXX:1521:XE" />
<property name="username" value="jbpm4" />
<property name="password" value="jbpm" />
<property name="idleConnectionTestPeriod" value="60" />
<property name="idleMaxAge" value="240" />
<property name="maxConnectionsPerPartition" value="60" />
<property name="minConnectionsPerPartition" value="20" />
<property name="partitionCount" value="3" />
<property name="acquireIncrement" value="10" />
<property name="preparedStatementCacheSize" value="50" />
<property name="statementsCachedPerConnection" value="30" />
<property name="releaseHelperThreads" value="3" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<ref local="mainDataSource" />
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingLocations">
<list>
<value>classpath:jbpm.execution.hbm.xml</value>
<value>classpath:jbpm.history.hbm.xml</value>
<value>classpath:jbpm.identity.hbm.xml</value>
<value>classpath:jbpm.repository.hbm.xml</value>
<value>classpath:jbpm.task.hbm.xml</value>
</list>
</property>
<property name="annotatedClasses">
<list>
<value>com.fish119.jssh.pojo.Test</value>
</list>
</property>
</bean>
<!-- 事务配置开始 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!--事务配置-->
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<!-- 配置事务属性 -->
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="add*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="*Save*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="exchange*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="remove*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="set*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="Test*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="*Test">PROPAGATION_REQUIRED,-Exception</prop>
</props>
</property>
</bean>
<bean id="autoproxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Service</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<!-- 事务配置结束 -->
<bean id="testDAO" class="com.fish119.jssh.dao.TestDAO" autowire="byType">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
第四步:配置Struts2(使用了convention plugin)
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="spring" />
<!--
<constant name="struts.objectFactory.spring.autoWire" value="type"/>
-->
<constant name="struts.devMode" value="true" />
<constant name="struts.convention.classes.reload" value="true" />
<!-- 结果资源所在路径 -->
<constant name="struts.convention.result.path" value="/" />
<!-- 默认action所在的包 -->
<constant name="struts.convention.default.parent.package"
value="myPackage" />
<!-- 不被convention组件扫描的包 -->
<!-- <constant name="struts.convention.exclude.packages" value=""/> -->
<package name="myPackage" extends="json-default">
<global-results>
<result name="exception">/error.jsp</result>
<result name="error">/error.jsp</result>
<result name="none">/error.jsp</result>
<result name="login">/login.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="exception" exception="java.lang.Exception">
</exception-mapping>
</global-exception-mappings>
</package>
</struts>
第五步:测试
1、建立action类:IndexAction
public class IndexAction extends BaseAction{
private static final long serialVersionUID = 1L;
ProcessEngine processEngine;
RepositoryService repositoryService;
ExecutionService executionService;
TaskService taskService;
HistoryService historyService;
IdentityService identityService;
public ProcessEngine getProcessEngine(){
return processEngine;
}
public void setProcessEngine(ProcessEngine processEngine){
this.processEngine = processEngine;
}
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 IdentityService getIdentityService(){
return identityService;
}
public void setIdentityService(IdentityService identityService){
this.identityService = identityService;
}
public String execute(){
System.out.println("processEngine:" + this.getProcessEngine());
System.out.println("repositoryService:"
+ this.getRepositoryService());
System.out
.println("executionServcie:" + this.getExecutionService());
System.out.println("taskService:" + this.getTaskService());
System.out.println("historyService:" + this.getHistoryService());
return SUCCESS;
}
}
2、启动tomcat,访问http://localhost:8080/ProjectName/index。控制台出现以下内容:
processEngine:org.jbpm.pvm.internal.processengine.SpringProcessEngine@2553861
repositoryService:org.jbpm.pvm.internal.repository.RepositoryServiceImpl@22b044e
executionServcie:org.jbpm.pvm.internal.svc.ExecutionServiceImpl@220d12e
taskService:org.jbpm.pvm.internal.svc.TaskServiceImpl@22d9289
historyService:org.jbpm.pvm.internal.svc.HistoryServiceImpl@2257b64
identityService:org.jbpm.pvm.internal.svc.IdentityServiceImpl@223f277
3、可以进一步进行事务测试,建立自己的Service类,添加测试方法,可以看到事务已由Spring统一管理,这里就不提供代码了
附件:所需的jar包(使用了hibernate annotation和struts2的convention-plugin,可能有多余的包,没做清理):
分享到:
相关推荐
整合JBPM4.4、Hibernate3.5.4、Spring3.0.4和Struts2.1.8,首先需要确保所有组件的版本兼容。开发环境通常选择Tomcat作为应用服务器,MySQL作为数据库,Java JDK 6作为开发环境。在整合过程中,需要配置数据库连接,...
SSH和JBPM是两个在Java开发领域中广泛使用的框架,SSH代表Spring、Struts和Hibernate,而JBPM则是一个流程管理平台。这篇文章将详细介绍如何整合SSH与JBPM 4.4,以及它们整合后能带来的优势。 首先,让我们了解SSH...
【jbpm4.4+SSH】是一个集成的Java企业级应用框架,主要涉及的是工作流管理系统jbpm4.4与Spring、Struts2(SSH)三大框架的整合。jbpm4是一个开源的工作流程管理系统,它提供了流程定义、执行、监控和优化等一系列...
【描述】中的关键信息是"JBPM4.4与ssh的整合实例",这里的"ssh"通常指的是Struts、Spring和Hibernate这三个Java Web开发框架的组合。这个项目表明,开发者已经成功地将JBPM4.4集成到基于SSH的应用程序中,使得业务...
jbpm4.4 shh2 项目示例是基于jbpm4.4版本与SSH2(Struts2、Spring和Hibernate)集成的一个实战项目。jbPM(Business Process Management)是一款开源的工作流管理系统,用于实现业务流程自动化。SSH2是Java开发中的...
SSH2 指的是 Struts2、Spring 和 Hibernate3 的整合框架,这三个组件分别是 MVC(模型-视图-控制器)架构的前端框架、依赖注入和事务管理的中间件以及持久化层的 ORM(对象关系映射)工具。jBPM 4.4 版本与 SSH2 的...
【描述】"myeclipse的jBPM4.4整合ssh2" 指的是将jBPM这个强大的工作流管理系统与SSH2(Spring、Struts2和Hibernate的组合)相结合,构建一个完整的Java企业级应用。在MyEclipse环境下,这种整合有助于开发者更高效地...
在“struts_spring_hibernate_jbpm”这个文件中,我们可以推测这是将SSH框架与JBPM4.4集成的示例项目。开发者可能已经配置好了Struts、Spring和Hibernate的集成,同时也将JBPM的工作流引擎集成到了应用中,以便实现...
jbpm4.4与SSH的整合是Java Web开发中常见的实践,它结合了jbpm强大的工作流管理功能和SSH的灵活性,为开发高效、可维护的企业级应用提供了可能。整合过程涉及多个层面,包括框架集成、数据源配置、业务逻辑封装以及...
将jbpm4.4与SSH2整合,可以实现强大的业务流程管理和数据持久化能力。 **jbpm4.4核心组件与功能** 1. **流程定义语言(JPDL)**:jbpm4.4使用基于XML的JPDL进行流程定义,开发者可以通过JPDL定义工作流的各个节点...
SSH框架指的是Struts2、Spring和Hibernate三个开源框架的组合,它们分别负责表示层、业务逻辑层和数据访问层的开发,是Java Web开发中的经典架构之一。 - **Struts2**:提供了MVC模式的框架,用于构建动态的Web应用...
SSH(Struts2、Spring、Hibernate)是一个流行的Java Web开发框架,它集合了Struts2的MVC设计模式,Spring的依赖注入和事务管理,以及Hibernate的对象关系映射能力,为开发者提供了一套高效、稳定且易用的开发工具集...
**jBPM4.4与SSH整合配置及完整实例详解** jBPM(Java Business Process Management)是一款开源的工作流管理系统,主要用于处理业务流程自动化。在本实例中,我们将讨论如何将jBPM 4.4版本与SSH(Spring、Struts、...
在本压缩包 "jBPM4.4Pssh.rar" 中,重点是将 jbPM 4.4 与 SSH(Struts、Spring 和 Hibernate)框架整合的示例。SSH 是 Java Web 开发中常见的三大框架,它们分别负责视图层、业务层和数据持久层的管理。 Struts 是...
【JBPM4.4 SSH案例】是一个基于Java技术栈的业务流程管理(BPM)示例项目,结合了Struts2、Spring和Hibernate这三大流行框架。JBPM4.4是JBoss公司提供的一个开源BPM平台,它允许开发者设计、执行和管理业务流程。在...
SSH+JBPM4.4是一个综合的IT项目,它整合了三个主要的技术栈:Spring、Struts2和Hibernate,这些都是Java开发中非常流行的开源框架。SSH(Spring、Struts2、Hibernate)组合提供了完整的MVC(Model-View-Controller)...