Skip to content

Instantly share code, notes, and snippets.

@neilcarlocatalan
Last active May 22, 2019 17:10
Show Gist options
  • Save neilcarlocatalan/68544d4f3e0f76d0f80faf1fa98b9c18 to your computer and use it in GitHub Desktop.
Save neilcarlocatalan/68544d4f3e0f76d0f80faf1fa98b9c18 to your computer and use it in GitHub Desktop.
Different Ways of Injecting Bitronix Transaction Manager
<aop:config>
<aop:pointcut id="serviceOperation" expression="your-pointcut-expression" />
<aop:advisor advice-ref="transactionAdvice" pointcut-ref="serviceOperation" />
</aop:config>
<tx:advice id="transactionAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" read-only="false" />
<tx:method name="find*" read-only="true" rollback-for="java.lang.Exception" />
<tx:method name="get*" read-only="true" rollback-for="java.lang.Exception" />
<tx:method name="retrieve*" read-only="true" rollback-for="java.lang.Exception" />
</tx:attributes>
</tx:advice>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" depends-on="bitronixTransactionManager" primary="true">
<property name="transactionManager" ref="bitronixTransactionManager" />
<property name="userTransaction" ref="bitronixTransactionManager" />
</bean>
<!-- Container Managed Bitronix configuration (use this if container exposes a JNDI name) -->
<!-- <bean id="bitronixTransactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/UserTransaction" />
</bean> -->
<!-- Use this if container has already a btm instance not expose via JNDI -->
<!-- <bean id="bitronixTransactionManager" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices" destroy-method="shutdown" /> -->
<!-- Embedded Bitronix configuration -->
<!-- <bean id="bitronixTransactionManager" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig" destroy-method="shutdown" />
<bean id="btmConfig" class="bitronix.tm.TransactionManagerServices" factory-method="getConfiguration">
<property name="serverId" value="mule-labormdb-embedded-btm" />
</bean> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment