diff --git a/org.springframework.integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java b/org.springframework.integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java index 1cb515423f6..e5e59cdee57 100644 --- a/org.springframework.integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java +++ b/org.springframework.integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -33,14 +32,9 @@ import org.junit.Test; import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.cache.Cache; -import org.springframework.cache.CacheManager; -import org.springframework.cache.concurrent.ConcurrentMapCache; -import org.springframework.cache.support.SimpleCacheManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; import org.springframework.context.config.AdviceMode; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; @@ -158,38 +152,6 @@ public class EnableTransactionManagementIntegrationTests { assertThat(txManager2.rollbacks, equalTo(0)); } - @Test - public void apcEscalation() { - AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); - ctx.register(EnableTxAndCachingConfig.class); - ctx.refresh(); - } - - - @Configuration - @EnableTransactionManagement - @ImportResource("org/springframework/transaction/annotation/enable-caching.xml") - static class EnableTxAndCachingConfig { - @Bean - public PlatformTransactionManager txManager() { - return new CallCountingTransactionManager(); - } - - @Bean - public FooRepository fooRepository() { - return new DummyFooRepository(); - } - - @Bean - public CacheManager cacheManager() { - SimpleCacheManager mgr = new SimpleCacheManager(); - ArrayList caches = new ArrayList(); - caches.add(new ConcurrentMapCache()); - mgr.setCaches(caches); - return mgr; - } - } - @Configuration @EnableTransactionManagement diff --git a/org.springframework.integration-tests/src/test/resources/org/springframework/transaction/annotation/enable-caching.xml b/org.springframework.integration-tests/src/test/resources/org/springframework/transaction/annotation/enable-caching.xml deleted file mode 100644 index efc9ec29f30..00000000000 --- a/org.springframework.integration-tests/src/test/resources/org/springframework/transaction/annotation/enable-caching.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/org.springframework.transaction/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java b/org.springframework.transaction/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java index 74d5f583526..2dca350475b 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java +++ b/org.springframework.transaction/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java @@ -16,12 +16,9 @@ package org.springframework.transaction.annotation; -import javax.annotation.PostConstruct; - import org.springframework.aop.config.AopConfigUtils; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Role; @@ -42,17 +39,6 @@ import org.springframework.transaction.interceptor.TransactionInterceptor; @Configuration public class ProxyTransactionManagementConfiguration extends AbstractTransactionManagementConfiguration { - @Autowired - private DefaultListableBeanFactory registry; - - @PostConstruct - public void registerAutoProxyCreator() { - AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry); - if ((Boolean)enableTx.get("proxyTargetClass")) { - AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry); - } - } - @Bean(name=TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() { @@ -81,4 +67,12 @@ public class ProxyTransactionManagementConfiguration extends AbstractTransaction return interceptor; } + // TODO: deal with escalation of APCs + @Bean(name=AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME) + @Role(BeanDefinition.ROLE_INFRASTRUCTURE) + public InfrastructureAdvisorAutoProxyCreator apc() { + InfrastructureAdvisorAutoProxyCreator apc = new InfrastructureAdvisorAutoProxyCreator(); + apc.setProxyTargetClass((Boolean) this.enableTx.get("proxyTargetClass")); + return apc; + } }