TransactionAspectSupport avoids hard references to transaction manager beans

Issue: SPR-14511
(cherry picked from commit 02374d7)
This commit is contained in:
Juergen Hoeller 2016-07-26 21:29:34 +02:00
parent 79f3cf3263
commit 67176e2b75
1 changed files with 9 additions and 11 deletions

View File

@ -18,7 +18,6 @@ package org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
@ -35,6 +34,7 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.support.CallbackPreferringPlatformTransactionManager;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.StringUtils;
/**
@ -68,13 +68,14 @@ import org.springframework.util.StringUtils;
*/
public abstract class TransactionAspectSupport implements BeanFactoryAware, InitializingBean {
// NOTE: This class must not implement Serializable because it serves as base
// class for AspectJ aspects (which are not allowed to implement Serializable)!
/**
* Key to use to store the default transaction manager.
*/
private final Object DEFAULT_TRANSACTION_MANAGER_KEY = new Object();
// NOTE: This class must not implement Serializable because it serves as base
// class for AspectJ aspects (which are not allowed to implement Serializable)!
private static final Object DEFAULT_TRANSACTION_MANAGER_KEY = new Object();
/**
* Holder to support the {@code currentTransactionStatus()} method,
@ -86,9 +87,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
new NamedThreadLocal<TransactionInfo>("Current aspect-driven transaction");
private final ConcurrentMap<Object, PlatformTransactionManager> transactionManagerCache =
new ConcurrentHashMap<Object, PlatformTransactionManager>();
/**
* Subclasses can use this to return the current TransactionInfo.
* Only subclasses that cannot handle all operations in one method,
@ -128,15 +126,15 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
protected final Log logger = LogFactory.getLog(getClass());
/**
* Default transaction manager bean name.
*/
private String transactionManagerBeanName;
private TransactionAttributeSource transactionAttributeSource;
private BeanFactory beanFactory;
private final ConcurrentMap<Object, PlatformTransactionManager> transactionManagerCache =
new ConcurrentReferenceHashMap<Object, PlatformTransactionManager>(4);
/**
* Specify the name of the default transaction manager bean.