Announcement Announcement Module
Collapse
No announcement yet.
Replacing AnnotationTransactionAspect using <tx:annotation-driven mode="aspectj" ../> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Replacing AnnotationTransactionAspect using <tx:annotation-driven mode="aspectj" ../>

    Hello,

    I would like to use my own Aspect (derived from AbstractTransactionAspect) with <tx:annotation-driven mode="aspectj" .../>. For this, I tried having the following Class as spring bean (yes, I'm using <context:component-scan ../> as well):

    Code:
    package org.nuclos.server.spring.tx;
    
    import org.springframework.beans.factory.config.BeanDefinition;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Role;
    import org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration;
    import org.springframework.transaction.config.TransactionManagementConfigUtils;
    
    @Configuration
    public class NuclosAspectJTransactionManagementConfiguration extends AbstractTransactionManagementConfiguration {
        
        NuclosAspectJTransactionManagementConfiguration() {
        }
    
        @Bean(name=TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME)
        @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
        public NuclosAnnotationTransactionAspect transactionAspect() {
            NuclosAnnotationTransactionAspect txAspect = NuclosAnnotationTransactionAspect.aspectOf();
            if (this.txManager != null) {
                txAspect.setTransactionManager(this.txManager);
            }
            return txAspect;
        }
    }
    However, this does not work. Spring still uses its own AnnotationTransactionAspect.

    Any suggestions, anyone?

    Cheers,

    aanno

  • #2
    AspectJ weaving

    Well,

    I just have analyzed the problem a little further. For me, it looks like the problem is to get my TransactionAspect woven into the annotated classes. As I'm using compile-time aspectj weaving, this is to say that the problem boils down to the build process. I'm using maven (and the aspectj-maven-plugin) for this.

    It turns out to be delicate to replace the AnnotationTransactionAspect with something other but, the following options come to my mind:
    • Patch and recompile spring-aspects.jar
    • Using a annotation of my own instead of the standard @Transactional

    For me it looks like that AspectJTransactionManagementConfiguration is only used when class-loading-time aspectj weaving (aka agent-based) is used...

    Comment

    Working...
    X