Jbpm 4.2 + Spring 配置


Spring 配置文件
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
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/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/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:property-placeholder location="classpath:jdbc.properties"/>

<!-- ibatis START ====================================================== -->
<bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="mysql/ns"/>
<property name="xaDataSourceClassName" value="${jdbc.xa.driverClassName}"/>
<property name="xaProperties">
<props>
<prop key="URL">${jdbc.url.ns}</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="5"/>
<property name="maxIdleTime" value="10"/>
<property name="testQuery" value="select 1"/>
</bean>

<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"
p:dataSource-ref="dataSource"
p:configLocation="classpath:sqlmap-config.xml"
/>

<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"
p:sqlMapClient-ref="sqlMapClient"
/>
<!-- ibatis END ======================================================== -->

<!-- jbpm3 START ======================================================= -->
<bean id="jbpm3DataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" destroy-method="close">
<property name="uniqueResourceName" value="mysql/jbpm3"/>
<property name="xaDataSourceClassName" value="${jdbc.xa.driverClassName}"/>
<property name="xaProperties">
<props>
<prop key="URL">${jdbc.url.jbpm3}</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="5"/>
<property name="maxIdleTime" value="10"/>
<property name="testQuery" value="select 1"/>
</bean>

<bean id="jbpm3SessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="jbpm3DataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.query.substitutions">true 'Y', false 'N'</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="mappingLocations" value="classpath*:/org/jbpm/**/*.hbm.xml"/>
</bean>

<bean id="jbpm3Configuration" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean"
p:sessionFactory-ref="jbpm3SessionFactory"
p:configuration="classpath:jbpm3.cfg.xml"
p:createSchema="false"
/>

<bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<constructor-arg index="0" ref="jbpm3Configuration"/>
</bean>
<!-- jbpm3 END ========================================================= -->

<!-- jbpm4 START ======================================================= -->
<bean id="jbpm4DataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" destroy-method="close">
<property name="uniqueResourceName" value="mysql/jbpm4"/>
<property name="xaDataSourceClassName" value="${jdbc.xa.driverClassName}"/>
<property name="xaProperties">
<props>
<prop key="URL">${jdbc.url.jbpm4}</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="5"/>
<property name="maxIdleTime" value="10"/>
<property name="testQuery" value="select 1"/>
</bean>

<!-- jbpm4SessionFactory -->
<bean id="jbpm4SessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="jbpm4DataSource"/>
<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>
</list>
</property>
</bean>

<bean id="jbpm4Configuration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
<constructor-arg value="jbpm42.spring.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 END ========================================================= -->

<!-- transaction START ================================================= -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"
p:forceShutdown="true"
/>

<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" p:transactionTimeout="300"/>

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"
p:transactionManager-ref="atomikosTransactionManager"
p:userTransaction-ref="atomikosUserTransaction"
/>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" rollback-for="java.lang.Exception"/>
<tx:method name="*" rollback-for="java.lang.Exception" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>

<aop:config>
<aop:advisor pointcut="execution(* org.kyll.ns.*..*Facade.*(..))" advice-ref="txAdvice"/>
</aop:config>
<!-- transaction END =================================================== -->

</beans>


Jbpm 4.2 配置文件
<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>

<process-engine-context>

<command-service name="txRequiredCommandService">
<skip-interceptor/>
<retry-interceptor/>
<environment-interceptor/>
<spring-transaction-interceptor/>
</command-service>

<command-service name="newTxRequiredCommandService">
<retry-interceptor/>
<environment-interceptor policy="requiresNew"/>
<spring-transaction-interceptor/>
</command-service>

<repository-service/>
<repository-cache/>
<execution-service/>
<history-service/>
<management-service/>
<identity-service/>
<task-service/>

<!--<hibernate-session-factory/>-->

<deployer-manager>
<jpdl-deployer/>
</deployer-manager>

<!--<job-executor/>-->

<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/>

<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>

</process-engine-context>

<transaction-context>
<hibernate-session factory="jbpm4SessionFactory" current="true"/>
<repository-session/>
<db-session/>
<message-session/>
<timer-session/>
<history-session/>
</transaction-context>

</jbpm-configuration>

这篇配置文件包括 Spring + iBatis + Jbpm3 + Jbpm4.2 和跨数据源的事务, 留作自己备忘^_^。

注意: Jbpm4.2 配置中的 <hibernate-session factory="jbpm4SessionFactory" current="true"/> 这行, factory="jbpm4SessionFactory" 和 current="true" 不加的时候, 会引起异常, factory 指定使用哪个 SessionFactory, 查了源码才知道是这个属性, 唉~~~~~~ Jbpm 的源码就不能再好好写吗?不看源码鬼才知道是这个属性!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值