Search in sources :

Example 1 with BeanFactoryTransactionAttributeSourceAdvisor

use of org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor in project spring-framework by spring-projects.

the class ProxyTransactionManagementConfiguration method transactionAdvisor.

@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
    BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
    advisor.setTransactionAttributeSource(transactionAttributeSource());
    advisor.setAdvice(transactionInterceptor());
    advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
    return advisor;
}
Also used : BeanFactoryTransactionAttributeSourceAdvisor(org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor) Role(org.springframework.context.annotation.Role) Bean(org.springframework.context.annotation.Bean)

Example 2 with BeanFactoryTransactionAttributeSourceAdvisor

use of org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor in project spring-framework by spring-projects.

the class EnableTransactionManagementIntegrationTests method assertTxProxying.

private void assertTxProxying(AnnotationConfigApplicationContext ctx) {
    FooRepository repo = ctx.getBean(FooRepository.class);
    boolean isTxProxy = false;
    if (AopUtils.isAopProxy(repo)) {
        for (Advisor advisor : ((Advised) repo).getAdvisors()) {
            if (advisor instanceof BeanFactoryTransactionAttributeSourceAdvisor) {
                isTxProxy = true;
                break;
            }
        }
    }
    assertTrue("FooRepository is not a TX proxy", isTxProxy);
    // trigger a transaction
    repo.findAll();
}
Also used : Advised(org.springframework.aop.framework.Advised) Advisor(org.springframework.aop.Advisor) BeanFactoryTransactionAttributeSourceAdvisor(org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor) BeanFactoryTransactionAttributeSourceAdvisor(org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor)

Aggregations

BeanFactoryTransactionAttributeSourceAdvisor (org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor)2 Advisor (org.springframework.aop.Advisor)1 Advised (org.springframework.aop.framework.Advised)1 Bean (org.springframework.context.annotation.Bean)1 Role (org.springframework.context.annotation.Role)1