paulwong

JBPM的双数据源配置

JBPM数据源和业务数据源不是同一个的时候的配置:


<!-- jta config -->
    
<!-- 业务数据库 -->
    
<bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
        init-method
="init" destroy-method="close">
        
<property name="uniqueResourceName">
            
<value>mysql/main</alue>
        
</property>
        
<property name="xaDataSourceClassName">
            
<value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</alue>
        
</property>
        
<property name="xaProperties">
            
<props>
                
<prop key="URL">${jdbc.url}</prop>
                
<prop key="user">${jdbc.username}</prop>
                
<prop key="password">${jdbc.password}</prop>
            
</props>
        
</property>
        
<property name="maxPoolSize">
            
<value>3</alue>
        
</property>
        
<property name="testQuery">
            
<value>SELECT 1</alue>
        
</property>
    
</bean>

    
<!-- JBPM数据库 -->
    
<bean id="dataSourceJbpm"
        class
="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init"
        destroy-method
="close">
        
<property name="uniqueResourceName">
            
<value>mysql/news</alue>
        
</property>
        
<property name="xaDataSourceClassName">
            
<value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</alue>
        
</property>
        
<property name="xaProperties">
            
<props>
                
<prop key="URL">${jbpm.jdbc.url}</prop>
                
<prop key="user">${jbpm.jdbc.username}</prop>
                
<prop key="password">${jbpm.jdbc.password}</prop>
            
</props>
        
</property>
        
<property name="maxPoolSize">
            
<value>3</alue>
        
</property>
        
<property name="testQuery">
            
<value>SELECT 1</alue>
        
</property>
    
</bean>

    
<bean id="lobHandler"
        class
="org.springframework.jdbc.support.lob.DefaultLobHandler" />

    
<!-- 业务数据库的sqlMapClient -->
    
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        
<property name="configLocation" value="classpath:SqlMapConfig.xml" />
        
<property name="dataSource" ref="dataSource" />
        
<property name="lobHandler" ref="lobHandler" />
    
</bean>

    
<!-- Construct Atomikos UserTransactionManager, needed to configure Spring -->
    
<bean id="atomikosTransactionManager"
        class
="com.atomikos.icatch.jta.UserTransactionManager"
        init-method
="init" destroy-method="close">
        
<!--  when close is called, should we force transactions to terminate or not? -->
        
<property name="forceShutdown">
            
<value>true</alue>
        
</property>
    
</bean>

    
<!-- Also use Atomikos UserTransactionImp, needed to configure Spring  -->
    
<bean id="atomikosUserTransaction"
        class
="com.atomikos.icatch.jta.UserTransactionImp">
        
<property name="transactionTimeout" value="300" />
    
</bean>

    
<!-- Configure the Spring framework to use JTA transactions from Atomikos -->
    
<bean id="transactionManager"
        class
="org.springframework.transaction.jta.JtaTransactionManager">
        
<property name="transactionManager" ref="atomikosTransactionManager"/>
        
<property name="userTransaction" ref="atomikosUserTransaction"/>
    
</bean>
    
    
<tx:advice id="txAdvice" transaction-manager="transactionManager">
        
<tx:attributes>
            
<tx:method name="find*" propagation="REQUIRED" read-only="true" rollback-for="ServiceException"/>
            
<tx:method name="get*" propagation="REQUIRED" read-only="true" rollback-for="ServiceException"/>
            
<tx:method name="list*" propagation="REQUIRED" read-only="true" rollback-for="ServiceException"/>
            
<tx:method name="*" propagation="REQUIRED" rollback-for="ServiceException"/>
        
< :attributes>
    
< :advice>

    
<aop:config>
        
<aop:advisor pointcut="execution(* com.service.impl.*.*(..))" advice-ref="txAdvice" />
    
</aop:config>
    
    
<!-- JBPM集成配置 -->
    
<bean id="sessionFactoryForJbpm"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
<property name="mappingJarLocations">
            
<list>
            
<!-- hibernate 映射文件所在的jar包路径 -->
                
<value>WEB-INF b/jbpm-jpdl.jar</alue>
            
< st>
        
</property>
        
<property name="hibernateProperties">
            
<props>
                
<prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQL5Dialect
                
</prop>
                
<prop key="hibernate.show_sql">true</prop>
                
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
            
</props>
        
</property>
        
<property name="dataSource" ref="dataSourceJbpm" />
    
</bean>

    
<bean id="jbpmConfiguration"
        class
="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
        
<property name="sessionFactory" ref="sessionFactoryForJbpm" />
        
<!-- jbpm.cfg.xml 配置JBPM的参数,如邮件服务器地址等,保持默认即可-->
        
<property name="configuration" value="classpath:jbpm.cfg.xml" />
        
<property name="createSchema" value="false" />
    
</bean>

    
<bean id="jbpmTemplate"
        class
="com.ideal.common.util.JbpmUtils">
        
<constructor-arg index="0" ref="jbpmConfiguration" />
    
</bean>
    
<!-- END OF JBPM集成配置 --> 

posted on 2009-03-11 09:34 paulwong 阅读(1253) 评论(0)  编辑  收藏 所属分类: JBPM


只有注册用户登录后才能发表评论。


网站导航: