The easiest way for an application to access the Aries transaction manager inside the
OSGi container is to create a bean reference to the OSGi service using either Spring XML
or blueprint XML. In fact, you typically need to reference two OSGi services: the JTA
transaction manager and the Spring PlatformTransactionManager. These two
services access the same underlying transaction manager, but use
alternative wrapper layers (see Figure 9).
In Spring XML, you can get bean references to the JTA transaction manager instance
and to the Spring PlatformTransactionManager instance using the following
sample code:
<?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:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
">
<!--
OSGi TM Service
-->
<!-- access through Spring's PlatformTransactionManager -->
<osgi:reference id="osgiPlatformTransactionManager"
interface="org.springframework.transaction.PlatformTransactionManager"/>
<!-- access through JTA TransactionManager -->
<osgi:reference id="osgiJtaTransactionManager"
interface="javax.transaction.TransactionManager"/>
</beans>In blueprint XML, you can get bean references to the JTA transaction manager instance
and to the Spring PlatformTransactionManager instance using the following
sample code:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
default-activation="lazy">
<!--
OSGi TM Service
-->
<!-- access through Spring's PlatformTransactionManager -->
<reference id="osgiPlatformTransactionManager"
interface="org.springframework.transaction.PlatformTransactionManager"/>
<!-- access through PlatformTransactionManager -->
<reference id="osgiJtaTransactionManager"
interface="javax.transaction.TransactionManager"/>
</blueprint>







