PDA

View Full Version : Help Needed with AOP and Database Transactions



sshah
Jul 18th, 2011, 03:50 PM
Hello,

I am having a problem with controlling when a transaction is committed in the situation below. I two services - Synchronization and DefaultProvisioning

Synchronization calls methods on the DefaultProvisioning service. The issue is that I would like to see commits occur when each method on the DefaultProvisioning service completes. Instead they are occuring then the Synchronization service method completes.

Is there any way that I can control this behavior?

The settings for the AOP config are below.




<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransa ctionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<tx:annotation-driven transaction-manager="transactionManager"/>


<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- all methods starting with 'get' are read-only -->
<tx:method name="get*" read-only="true" propagation="SUPPORTS" />
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*" propagation="REQUIRED" rollback-for="RuntimeException"/>
<tx:method name="send*" read-only="true" propagation="NOT_SUPPORTED" />
</tx:attributes>
</tx:advice>




<aop:config>
<aop:pointcut id="defaultProvisionOperation" expression="execution(* org.openiam.provision.service.DefaultProvisioningS ervice.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="defaultProvisionOperation"/>
</aop:config>


<aop:config>
<aop:pointcut id="synchServiceWSOperation" expression="execution(* org.openiam.idm.srvc.synch.ws.IdentitySynchWebServ iceImpl.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="synchServiceWSOperation"/>
</aop:config>

RahulMalviya
Jul 21st, 2011, 07:56 AM
Your configuration looks like right..........first check your transaction have been managed in defaultProvisionOperation bean or not by throwing any exception and then check previous committed operations are rolled back or not.