Announcement Announcement Module
No announcement yet.
.AnnotationTransactionAspect - Do I need it. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • .AnnotationTransactionAspect - Do I need it.

    I am using compile time weaving for transaction support for my service beans.
    I have the following iin my applicationContext.xml

        <tx:annotation-driven mode="aspectj" order="999" /
    I am using maven aspectj plugin to do the compile time weaving. Everything is working perfectly. But in the Ref. doc. I saw somwthing like
    It is also possible to use the Spring Framework's @Transactional support outside of a Spring container by
    means of an AspectJ aspect. To use this support you must first annotate your classes (and optionally your
    classes' methods with the @Transactional annotation, and then you must link (weave) your application with
    the org.springframework.transaction.aspectj.Annotation TransactionAspect defined in the
    spring-aspects.jar file. The aspect must also be configured with a transaction manager. You could of course
    use the Spring Framework's IoC container to take care of dependency injecting the aspect.
    And also saw some configuration on some blog posts like
        <bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf">
            <property name="transactionManager" ref="transactionManager"/>
    Do I need the last part ? I thought that <tx:annotation-driven will take care of every thing ? And that seems to be the case, as the transactions are working correctly.
    Last edited by gumnaam.sur; Apr 7th, 2008, 10:21 AM.

  • #2
    <tx:annotationd-driven /> doesn't use loadtime weaving it creates a proxy.

    The second sample does use weaving.

    So you can use either one, using both is overkill and actually pretty useles (and might cause problems).


    • #3
      Actually as per 2.5's ref. documentation
      <tx:annotation-driven mode=aspectj />
      Does not creates proxy, rather it depends on either load time or compile time weaving of AnnotationTransactionAspect.
      <tx:annotation-driven mode=proxy />
      will create either JDK dynamic proxies or CGLIB proxies depending on the value of 'proxy-target-class' attribute. But when mode='aspectj', then no proxying is done.
      I am quite sure of that. What I want to know is , if mode is set to 'aspectj', is there a need to define AnnotationTransactionAspect separately in spring config file, with the transactionmanager injected ?
      Or will <tx:annotation-driven mode='aspectj' /> do it for me ?