浏览 4979 次
锁定老帖子 主题:JBPM4.2与spring集成
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (1)
|
|
---|---|
作者 | 正文 |
发表时间:2009-11-19
最后修改:2009-11-19
修改jbpm提供的spring.jbpm.cfg.xml,application.xml,jbpm.tx.spring.cfg.xml,jbpm.tx.hibernate.cfg.xml来做spring与jbpm的集成, <jbpm-configuration> <process-engine-context> <!--结合jbpm.tx.hibernate.xml--> <command-service name="txRequiredCommandService"> <skip-interceptor /> <retry-interceptor /> <environment-interceptor /> <!--使用spring管理transaction--> <spring-transaction-interceptor /> </command-service> <command-service name="newTxRequiredCommandService"> <retry-interceptor /> <environment-interceptor policy="requiresNew" /> <spring-transaction-interceptor current="true"/> </command-service> <!--下面为jbpm.default.cfg.xml中的配置,由于jbpm.default.cfg.xml中需要引入jbpm.hibernate.cfg.xml,所以将配置改写到这里,或改jbpm.hibernate.cfg.xml源码,将引入jbpm.hibernate.cfg.xml注掉--> <repository-service /> <repository-cache /> <execution-service /> <history-service /> <management-service /> <identity-service /> <task-service /> <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator"> <field name="commandService"> <ref object="newTxRequiredCommandService" /> </field> </object> <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" /> <script-manager default-expression-language="juel" default-script-language="juel"> <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" /> </script-manager> <types resource="jbpm.variable.types.xml" /> <address-resolver /> </process-engine-context> <transaction-context> <!--强制从当前线程中获取, 删掉了原来的<transaction />--> <hibernate-session factory="hibernateSessionFactory" current="true" /> <!--jbpm.default.cfg.xml中的配置--> <repository-session /> <db-session /> <message-session /> <timer-session /> <history-session /> </transaction-context> </jbpm-configuration> 接下来将spring.jbpm.cfg.xml改为
<jbpm-configuration> <import resource="jbpm.jpdl.cfg.xml" /> <import resource="spring/jbpm42.spring.cfg.xml" /> <import resource="jbpm.identity.cfg.xml" /> <import resource="jbpm.businesscalendar.cfg.xml" /> <import resource="jbpm.console.cfg.xml" /> <!-- <import resource="jbpm.jobexecutor.cfg.xml" />--> </jbpm-configuration> 最后将applicationContext.xml改为
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" 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/aop http://www.springframework.org/schema/aop/spring-aop-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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" default-autowire="byName"> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- Configure DB data source --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>${jdbc.driver}</value> </property> <property name="jdbcUrl"> <value>${jdbc.url}</value> </property> <property name="user"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> <!-- <property name="maxActive" value="2" /> <property name="maxIdle" value="2" /> <property name="maxWait" value="10000" /> --> <!--连接池中保留的最小连接数。--> <property name="minPoolSize"> <value>5</value> </property> <property name="maxPoolSize"> <value>5000</value> </property> <property name="maxIdleTime"> <value>60</value> </property> <property name="idleConnectionTestPeriod"> <value>60</value> </property> <property name="acquireIncrement"> <value>10</value> </property> <property name="checkoutTimeout"> <value>0</value> </property> </bean> <!-- Configure hibernate session factory --> <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.format_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>jbpm.repository.hbm.xml</value> <value>jbpm.execution.hbm.xml</value> <value>jbpm.history.hbm.xml</value> <value>jbpm.task.hbm.xml</value> <value>jbpm.identity.hbm.xml</value> </list> </property> </bean> <!-- =========jbpm4.2 configuration========= --> <bean id="jbpm4Configuration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration"> <constructor-arg value="spring/spring.jbpm.cfg.xml" /> </bean> <bean id="processEngine" factory-bean="jbpm4Configuration" factory-method="buildProcessEngine" /> <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="managementService" factory-bean="processEngine" factory-method="getManagementService" /> <!-- =========jbpm4.2 end========= --> <!-- Transaction management--> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="hibernateSessionFactory" /> </property> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> </beans> 修改完成。 途中出现的错误: exception while executing command org.jbpm.pvm.internal.cmd.DeployCmd@ java.lang.NullPointerException 开始在网上找原因说是因为少了这么两句: <deployer-manager> 但我是引入了jbpm.jpdl.cfg.xml的,不需要加这两句,后来跟代码发现repositorySession 为null 是由于没有加入<repository-session />所致。
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-12-08
谢谢了,下午试着更新了一下,无法保持的同一个事务中,呵呵。
用下面这个就好了。 <hibernate-session factory="hibernateSessionFactory" current="true" /> |
|
返回顶楼 | |