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
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- XA Datasource --> <bean id="datasource1" class="com.atomikos.jdbc.SimpleDataSourceBean" init-method="init" destroy-method="close"> <property name="uniqueResourceName"> <value>mysql/main</value> </property> <property name="xaDataSourceClassName"> <value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</value> </property> <property name="xaDataSourceProperties"> <value>URL=jdbc:mysql://localhost:3306/test;user=root;password=admin</value> </property> <property name="exclusiveConnectionMode"> <value>true</value> </property> <property name="connectionPoolSize"> <value>3</value> </property> <property name="validatingQuery"> <value>SELECT 1</value> </property> </bean> <bean id="datasource2" class="com.atomikos.jdbc.SimpleDataSourceBean" init-method="init" destroy-method="close"> <property name="uniqueResourceName"> <value>mysql/news</value> </property> <property name="xaDataSourceClassName"> <value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</value> </property> <property name="xaDataSourceProperties"> <value>URL=jdbc:mysql://localhost:3306/test2;user=root;password=admin</value> </property> <property name="exclusiveConnectionMode"> <value>true</value> </property> <property name="connectionPoolSize"> <value>3</value> </property> <property name="validatingQuery"> <value>SELECT 1</value> </property> </bean> <bean id="template1" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="datasource1" /> </bean> <bean id="template2" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="datasource2" /> </bean> <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"> <property name="forceShutdown"><value>true</value></property> </bean> <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"> <property name="transactionTimeout" value="300"/> </bean> <bean id="springTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager"><ref bean="atomikosTransactionManager" /></property> <property name="userTransaction"><ref bean="atomikosUserTransaction" /></property> </bean> <bean id="dao1" class="com.xa.dao.UserDao1"> <property name="jdbcTemplate"> <ref bean="template1"></ref> </property> </bean> <bean id="dao2" class="com.xa.dao.UserDao2"> <property name="jdbcTemplate"> <ref bean="template2"></ref> </property> </bean> <!-- --> <bean id="userServiceTarget" class="com.xa.service.UserServiceImpl"> <property name="dao1" ref="dao1"/> <property name="dao2" ref="dao2"/> </bean> <bean id="userTest" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="springTransactionManager"/> </property> <property name="target"> <ref bean="userServiceTarget"/> </property> <property name="transactionAttributes"> <props> <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop> </props> </property> </bean> </beans>
<property name="uniqueResourceName"> <value>mysql/main</value> </property>
<property name="uniqueResourceName"> <value>mysql/news</value> </property>
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"> <property name="forceShutdown"><value>true</value></property> </bean> <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"> <property name="transactionTimeout" value="300"/> </bean> <bean id="springTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager"><ref bean="atomikosTransactionManager" /></property> <property name="userTransaction"><ref bean="atomikosUserTransaction" /></property> </bean>
protected String[] getConfigLocations() { //return new String[] { "classpath:ApplicationContext-jotm.xml" }; return new String[] { "classpath:ApplicationContext-atomikos.xml" }; }