jbpm+spring

22 篇文章 0 订阅
7 篇文章 0 订阅
jbpm4.3与spring整合
*************************    一    *******************************
前言:前几天用ssh整合jbpm,但是jbpm4.2版本是个很不完善的版本,对spring的支持也不友好。所以4.2才出了一个月jboss就出了4.3版本。4.3对spring整合提供了配置文件,并重新设计了类,起码整合spring不用再自己搞配置文件了。
这几天在学jbpm,搞了好几天的整合,终于把ssh和jbpm4.3整合成功,暂时没出现
什么问题。
一。安装gpd

二。进行数据表导入。
首先修改jbpm-4.3\install\jdbc\mysql.properties文件。
然后修改build.xml文件的数据库<property name="database" value="mysql" />。
最后进入jbpm-4.3\install目录执行ant  -create.jbpm.schema。

三。jar包导入
1)最关键的一步,整合时主要卡在这个地方:
删除Tomcat6.0的lib的el-api.jar包,把jbpm-4.3的/lib/juel.jar和/lib/juel-engine.jar和/lib/juel-impl.jar放到Tomcat6.0的lib目录。
2)拷贝ssh包和jdbc包
3)将jbpm-4.3下的所有包拷贝到项目里面
四。配置文件
1)复制jbpm-4.3examples的jbpm.cfg.xml,jbpm.hibernate.cfg.xml,logging.properties到项目的src目录。
修改jbpm.hibernate.cfg.xml的数据库连接。
mysq方言需要设置为<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect </property>
在jbpm.cfg.xml里面加入<import resource="jbpm.tx.spring.cfg.xml" />
2)复制jbpm-4.3install\src\cfg\spring\applicationContext.xml到项目的src目录。
3)修修改改就好。


*************************    二    *******************************
四本人的配置文件。
说明:由于session和transaction的管理,使用jbpm不方便使用hibernate的annotation,但是可以使用spring的annotation。所以我使用了注解配置spring。还没学到mail。
1)applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Application context definition for PetClinic on JPA.
-->
<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" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- 配置注解处理器,开启注解 -->
<context:annotation-config/>

<!--  配置bean扫描器 ,自动扫描处理 -->
<context:component-scan base-package="com.sxt" />


<!--        配置sessionFactory  -->
<bean id="sessionFactory"  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
</bean>  

<!-- =========================  事务配置    ========================= -->


<!-- 定义事务管理器(声明式的事务) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!--  注解配置事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />

<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->



<!--  配置service业务类,单例 -->

<!--  配置action -->


<!-- ========================= jbpm4 ========================= -->
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />

<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />


</beans>

2)jbpm.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>

<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.tx.spring.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />


<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->


</jbpm-configuration>


3)jbpm.hibernate.xml
<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/HBOA</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">7777777</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.format_sql">true</property>

<mapping resource="jbpm.repository.hbm.xml" />
<mapping resource="jbpm.execution.hbm.xml" />
<mapping resource="jbpm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.identity.hbm.xml" />

<!-- mapping files -->

</session-factory>
</hibernate-configuration>


3)web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!-- ******************  配置struts开始 *********************-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- ******************** 配置struts结束 *******************-->    

<!-- ******************** 配置spring  *******************-->
<!-- 设置spring读取的application文件位置  -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- 加载spring  -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>

<!-- 设置spring过滤器来管理session打开关闭,使用OSIV 避免延迟加载问题lazy-->
<!--            使用 hibernate的osiv管理 -->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- spring编码过滤器,解决乱码 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- ********************  spring配置结束  *******************-->

</web-app>

*************************  三   *******************************
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值