Custom AnnotationTransactionAttributeSource with aspectj
Hi there,
I'm using a custom AnnotationTransactionAttributeSource to use my custom annotation instead of Spring @Transactional annotation.
I use below BeanFactoryPostProcessor to change original AnnotationTransactionAttributeSource with my own one.
Code:
public class CustomTransactionalConfigurer implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory) throws BeansException {
String[] beanNames = beanFactory.getBeanNamesForType(AnnotationTransactionAttributeSource.class);
for(String beanName : beanNames) {
BeanDefinition def = beanFactory.getBeanDefinition(beanName);
def.setBeanClassName("com.example.transaction.CustomAnnotationTransactionalAttributeSource");
}
}
Everything works fine when application context configured with
<tx:annotation-driven transaction-manager="txManager"/>
But I want to enable aspectj mode
<tx:annotation-driven transaction-manager="txManager" mode="aspectj"/>
When I enable aspectj mode getBeansNamesForType method returns an empty list so my custom annotation becomes useless and Spring Transactional annotation starts working since I can not change bean definition.
Any ideas?