AtomikosTransactionsEssentials-3.3.1 JTA的配置

数据库 Oracle 9i
#jdbc.properties

jdbc.driverClassName=oracle.jdbc.xa.client.OracleXADataSource
jdbc.url=jdbc:oracle:thin:@hostOne:1521:one
jdbc.username=oracle
jdbc.password=oracle

jdbc.driverClassName1=oracle.jdbc.xa.client.OracleXADataSource
jdbc.url1=jdbc:oracle:thin:@hostTow:two
jdbc.username1=oracle
jdbc.password1=oracle
############################################
#jta.properties
com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.console_file_name = tm.out
com.atomikos.icatch.log_base_name = tmlog
com.atomikos.icatch.tm_unique_name = com.atomikos.spring.jdbc.tm
com.atomikos.icatch.console_log_level = INFO
###############################################
依赖的库
AtomikosTransactionsEssentials-3.3.1/lib/ojdbc14.jar
AtomikosTransactionsEssentials-3.3.1/dist/atomikos-util.jar
AtomikosTransactionsEssentials-3.3.1/dist/transactions.jar
AtomikosTransactionsEssentials-3.3.1/dist/transactions-api.jar
AtomikosTransactionsEssentials-3.3.1/dist/transactions-jta.jar
AtomikosTransactionsEssentials-3.3.1/dist/transactions-jdbc.jar
AtomikosTransactionsEssentials-3.3.1/lib/slf4j-api-1.4.3.jar
AtomikosTransactionsEssentials-3.3.1/lib/slf4j-nop-1.4.3.jar
AtomikosTransactionsEssentials-3.3.1/examples/lib/activemq-3.1.jar
AtomikosTransactionsEssentials-3.3.1/examples/lib/concurrent.jar
AtomikosTransactionsEssentials-3.3.1/examples/lib/fsjclient.jar
AtomikosTransactionsEssentials-3.3.1/examples/lib/geronimo-spec-j2ee-management-1.0-rc4.jar

spring-framework-2.5.2/dist/modules/spring-tx.jar
spring-framework-2.5.2/dist/modules/spring-aop.jar
spring-framework-2.5.2/dist/modules/spring-beans.jar
spring-framework-2.5.2/dist/modules/spring-context.jar
spring-framework-2.5.2/dist/modules/spring-context-support.jar
spring-framework-2.5.2/dist/modules/spring-core.jar
spring-framework-2.5.2/dist/modules/spring-jdbc.jar
spring-framework-2.5.2/dist/modules/spring-test.jar
spring-framework-2.5.2/lib/junit/junit-3.8.2.jar
spring-framework-2.5.2/lib/jakarta-commons/commons-logging.jar
spring-framework-2.5.2/lib/aopalliance/aopalliance.jar
spring-framework-2.5.2/lib/aspectj/aspectjrt.jar
spring-framework-2.5.2/lib/aspectj/aspectjweaver.jar
spring-framework-2.5.2/lib/j2ee/jta.jar
spring-framework-2.5.2/lib/cglib/cglib-nodep-2.1_3.jar

//dataAccessContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans default-autowire="byName" default-lazy-init="false">


<bean id="dataSource"
class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init"
destroy-method="close">
<property name="uniqueResourceName">
<value>oracle/main</value>
</property>
<property name="xaDataSourceClassName">
<value>${jdbc.driverClassName}</value>
</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="poolSize">
<value>1</value>
</property>
</bean>
<bean id="dataSourceB"
class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init"
destroy-method="close" lazy-init="true">
<property name="uniqueResourceName">
<value>mysql/main</value>
</property>
<property name="xaDataSourceClassName">
<value>${jdbc.driverClassName1}</value>
</property>
<property name="xaProperties">
<props>
<prop key="URL">${jdbc.url1}</prop>
<prop key="user">${jdbc.username1}</prop>
<prop key="password">${jdbc.password1}</prop>
</props>
</property>
<property name="poolSize">
<value>1</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jtaTransactionManager" ref="atomikosTransactionManager" />
<property name="configLocations">
<list>
<value>classpath*:/config/hibernate.cfg.xml</value>
</list>
</property>
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>

<prop key="current_session_context_class">jta</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
<prop key="hibernate.connection.release_mode">after_statement</prop>
</props>
</property>
</bean>
<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</value>
</property>
</bean>
<bean id="atomikosUserTransaction"
class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="240" />
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<ref bean="atomikosTransactionManager" />
</property>
<property name="userTransaction">
<ref bean="atomikosUserTransaction" />
</property>
</bean>
</beans>



//applicationContext.xml

<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byName" default-lazy-init="false">

<!-- 属性文件读入 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:config/jdbc.properties</value>
<value>classpath*:spring/jta.properties</value>
</list>
</property>
</bean>

<!-- 支持 @Transactional 标记 -->
<tx:annotation-driven/>

<!-- 支持 @AspectJ 标记-->
<aop:aspectj-autoproxy/>

<!-- 以AspectJ方式 定义 AOP -->
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* com.ibm.jta.demo.service.*Service.*(..))" advice-ref="txAdvice"/>
</aop:config>


<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
</beans>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值