[color=red]-----使用jbpm4.4自身提供的factortBean[/color]
[color=green]<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" >
<property name="jbpmCfg" value="jbpm.cfg.xml"></property>
</bean>[/color]
[color=red]-----配置sessionFactory,包括jbpm本身的对象操作和用户自带的dataSource[/color]
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
[color=red]事务处理[/color]
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.bpm.service.*.*(..))" id="txPointcut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config>
[color=red]自定义Dao,注入processEngine与session[/color]
<bean id="commonDao" class="com.bpm.dao.CommonDao">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="processEngine" ref="processEngine"/>
</bean>
[color=red]数据源[/color]
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@172.17.250.82:1521:EIMP" />
<property name="username" value="jbpm" />
<property name="password" value="jbpm" />
<property name="maxActive" value="50" />
<property name="initialSize" value="1" />
<!-- 超时等待时间以毫秒为单位 -->
<property name="maxWait" value="60000" />
<property name="maxIdle" value="20" />
<property name="minIdle" value="3" />
<!-- 是否自动回收超时连接 -->
<property name="removeAbandoned" value="true" />
<!-- 超时时间 -->
<property name="removeAbandonedTimeout" value="180" />
</bean>
以上是spring文件的主要配置,然后自定义一个jbpm.tx.spring.cfg.xml文件,添加语句 <transaction-context type="spring" />到jbpm.cfg.xml以下是内容:
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration spring="enabled" >
<process-engine-context>
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor policy="requiresNew"/>
<spring-transaction-interceptor policy="requiresNew"/>
</command-service>
<command-service name="txRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>
</process-engine-context>
<transaction-context>
<transaction type="spring" />
<hibernate-session current="true"/>
</transaction-context>
</jbpm-configuration>
[color=green]<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" >
<property name="jbpmCfg" value="jbpm.cfg.xml"></property>
</bean>[/color]
[color=red]-----配置sessionFactory,包括jbpm本身的对象操作和用户自带的dataSource[/color]
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
[color=red]事务处理[/color]
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.bpm.service.*.*(..))" id="txPointcut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config>
[color=red]自定义Dao,注入processEngine与session[/color]
<bean id="commonDao" class="com.bpm.dao.CommonDao">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="processEngine" ref="processEngine"/>
</bean>
[color=red]数据源[/color]
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@172.17.250.82:1521:EIMP" />
<property name="username" value="jbpm" />
<property name="password" value="jbpm" />
<property name="maxActive" value="50" />
<property name="initialSize" value="1" />
<!-- 超时等待时间以毫秒为单位 -->
<property name="maxWait" value="60000" />
<property name="maxIdle" value="20" />
<property name="minIdle" value="3" />
<!-- 是否自动回收超时连接 -->
<property name="removeAbandoned" value="true" />
<!-- 超时时间 -->
<property name="removeAbandonedTimeout" value="180" />
</bean>
以上是spring文件的主要配置,然后自定义一个jbpm.tx.spring.cfg.xml文件,添加语句 <transaction-context type="spring" />到jbpm.cfg.xml以下是内容:
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration spring="enabled" >
<process-engine-context>
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor policy="requiresNew"/>
<spring-transaction-interceptor policy="requiresNew"/>
</command-service>
<command-service name="txRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>
</process-engine-context>
<transaction-context>
<transaction type="spring" />
<hibernate-session current="true"/>
</transaction-context>
</jbpm-configuration>