JPBM4.4与Spring的整合
最近刚开始学习JBPM4.4,安装和运行其自带的例子均没有碰到什么问题。
但是,和项目整合的时候需要与原有的系统进行整合。所以,问题来了:
1、JBPM4.4到底需要哪些JAR包,jar包冲突了怎么办呢?
2、JPBM4.4怎么和原有的Spring配置整合在一起呢?
首先,第一个问题一直都是很困扰JAVA开发者的一个问题(jar包的依赖关系,版本冲突等等问题)。我认为有两种无奈的解决思路: 1、不管三七二十一,把所需的jar包一股脑的扔进去,等发生冲突了,再一个个剔除。2、不管这个框架需要什么jar包,直接运行你写的单元测试例子,查看出错信息一个个去将缺少的包加入进来。幸运的是我们原来的项目采用maven管理项目,所以我采用第二种思路,很轻松的就将jbpm4.4所需的最小依赖包加入进来了。
那么,接下来就是和spring的配置问题了。我查看了JPBM4.4的官方开发者指南(http://docs.jboss.com/jbpm/v4/devguide/html_single/)的第17节(Chapter 17. Spring Integration)中spring的配置描述 :
第一步骤(配置spring的事务管理):
The easiest way to integrate Spring with jBPM is to import the jbpm.tx.spring.cfg.xml in your jbpm.cfg.xml file:(最最简单的方法就是,直接在jbpm.cfg.xml文件中导入jbpm.tx.spring.cfg.xml)<import resource="jbpm.tx.spring.cfg.xml" />
<bean id="springHelper" value="org/jbpm/spring/jbpm.cfg.xml"></property> </bean> <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<jbpm-configuration spring="enabled"> <process-engine-context> <command-service name="newTxRequiredCommandService"> <retry-interceptor /> <environment-interceptor policy="requiresNew" /> <spring-transaction-interceptor policy="requiresNew" /> </command-service> <!-- Default command service has a Spring transaction interceptor--> <command-service name="txRequiredCommandService"> <retry-interceptor /> <environment-interceptor /> <spring-transaction-interceptor /> </command-service> </process-engine-context> <transaction-context> <transaction type="spring" /> <hibernate-session current="true" /> </transaction-context></jbpm-configuration>
<spring-transaction-interceptor transaction-manager="你的事务管理器" />