Announcement Announcement Module
Collapse
No announcement yet.
Trying to apply advise to a method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to apply advise to a method

    I have businessClass having multiple methods.
    When main entry method is called, it further calls other methods.
    But only one method works with DB. So instead of wrapping all methods to Transaction advice, I want to apply only to a method. But it's not working for me.

    Code:
     
     <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
          <tx:method name="*" 
            		 propagation="REQUIRED" 
          			 rollback-for="com.xyz.general.lang.AbcException"/>
        </tx:attributes>
      </tx:advice>
    
      <aop:config>
    
        <aop:pointcut id="emailServiceOperation" expression="execution(* com.xyz.service.EmailService._insertEmailMessage(..))"/>
    
        <aop:pointcut id="emailServiceOperation2" expression="execution(* _insertEmailMessage(..))"/>
        
    <!-- For any method of class implementing this interface -->
        <aop:pointcut id="xyzServiceOperations" expression="execution(* *..AbcService.*(..))"/>
        
        <aop:advisor advice-ref="txAdvice" pointcut-ref="emailServiceOperation"/> 
        <aop:advisor advice-ref="txAdvice" pointcut-ref="emailServiceOperation2"/> 
        <aop:advisor advice-ref="txAdvice" pointcut-ref="xyzServiceOperations"/> 
           
      </aop:config>
    Above only -- <aop:advisor advice-ref="txAdvice" pointcut-ref="xyzServiceOperations"/> --
    is working.
    But i want to apply transaction boundaries to "_insertEmailMessage" method of EmailService (implements AbcService).

    Is it possible? If anyone has done it?
Working...
X