Upon detecting a new OSGi service supporting the javax.sql.XADataSource interface, the activator automatically creates a new XADataSourceEnlistingWrapper object, which wraps the original XA data source, effectively acting as a data source proxy. The XADataSourceEnlistingWrapper object also obtains a reference to the JTA transaction manager service (from the org.apache.aries.transaction.manager bundle). Finally, the activator exports the XADataSourceEnlistingWrapper object with the javax.sql.DataSource interface.
<bean id="xxxBean" class="xxxx">
<tx:transaction method="*" value="Required" />
.....
</bean>
xmlns:tx="
<bean id="xaDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<property name="serverName" value="${jta.atomikos.dbServerName}" />
<property name="portNumber" value="${jta.atomikos.dbServerPort}" />
<!-- <property name="selectMethod" value="cursor" /> -->
<property name="databaseName" value="${jta.atomikos.dbName}" />
<property name="user" value="${jta.atomikos.dbUser}" />
<property name="password" value="${jta.atomikos.dbPassword}" />
<property name="autoReconnect" value="true"/>
</bean>
<!--发布XA数据源成OSGI服务,Aries Transaction才会自动enlist这个数据源 -->
<service ref="xaDataSource" interface="javax.sql.XADataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mySqlXADS"/>
</service-properties>
</service>
<tx:transaction method="*" value="Required"/>