TransactionAttributeSource that caches
attributes for methods and implements a fallback policy: 1. specific target
method; 2. target class; 3. declaring method; 4. declaring class/interface.
Defaults to using the target class's transaction attribute if none is associated with the target method. Any transaction attribute associated with the target method completely overrides a class transaction attribute. If none found on the target class, the interface that the invoked method has been called through (in case of a JDK proxy) will be checked.
This implementation caches attributes by method after they are first used. If it is ever desirable to allow dynamic changing of transaction attributes (which is very unlikely), caching could be made configurable. Caching is desirable because of the cost of evaluating rollback rules.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | attributeCache
Cache of TransactionAttributes, keyed by method on a specific target class. |
| private transient StringValueResolver | |
| protected final Log | logger
Logger available to subclasses. |
| private static final TransactionAttribute | NULL_TRANSACTION_ATTRIBUTE
Canonical value held in cache to indicate no transaction attribute was found for this method, and we don't need to look again. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | |
| protected TransactionAttribute | computeTransactionAttribute(Method method, Class<?> targetClass)
Same signature as |
| protected abstract TransactionAttribute | Returns: all transaction attribute associated with this class, ornull if nonethe class to retrieve the attribute for clazz)Subclasses need to implement this to return the transaction attribute for the given class, if any. |
| protected abstract TransactionAttribute | Returns: all transaction attribute associated with this method, ornull if nonethe method to retrieve the attribute for method)Subclasses need to implement this to return the transaction attribute for the given method, if any. |
| protected Object | Returns: the cache key (nevernull)the method (never method, Class<?> null)the target class (may be targetClass)null)Determine a cache key for the given method and target class. |
| public TransactionAttribute | Returns: a TransactionAttribute for this method, ornull if the method
is not transactionalthe method for the current invocation (never method, Class<?> null)the target class for this invocation (may be targetClass)null)Implements org. Determine the transaction attribute for this method invocation. |
| public void | setEmbeddedValueResolver(StringValueResolver resolver)
Implements org. Set the StringValueResolver to use for resolving embedded definition values. |
| attributeCache | back to summary |
|---|---|
| private final Map<Object, TransactionAttribute> attributeCache Cache of TransactionAttributes, keyed by method on a specific target class. As this base class is not marked Serializable, the cache will be recreated after serialization - provided that the concrete subclass is Serializable. | |
| embeddedValueResolver | back to summary |
|---|---|
| private transient StringValueResolver embeddedValueResolver
| |
| logger | back to summary |
|---|---|
| protected final Log logger Logger available to subclasses. As this base class is not marked Serializable, the logger will be recreated after serialization - provided that the concrete subclass is Serializable. | |
| NULL_TRANSACTION_ATTRIBUTE | back to summary |
|---|---|
| private static final TransactionAttribute NULL_TRANSACTION_ATTRIBUTE Canonical value held in cache to indicate no transaction attribute was found for this method, and we don't need to look again.
| |
| AbstractFallbackTransactionAttributeSource | back to summary |
|---|---|
| public AbstractFallbackTransactionAttributeSource() | |
| allowPublicMethodsOnly | back to summary |
|---|---|
| protected boolean allowPublicMethodsOnly() Should only public methods be allowed to have transactional semantics? The default implementation returns | |
| computeTransactionAttribute | back to summary |
|---|---|
| protected TransactionAttribute computeTransactionAttribute(Method method, Class<?> targetClass) Same signature as As of 4.1.8, this method can be overridden.
| |
| findTransactionAttribute | back to summary |
|---|---|
| protected abstract TransactionAttribute findTransactionAttribute(Class<?> clazz) Subclasses need to implement this to return the transaction attribute for the given class, if any.
| |
| findTransactionAttribute | back to summary |
|---|---|
| protected abstract TransactionAttribute findTransactionAttribute(Method method) Subclasses need to implement this to return the transaction attribute for the given method, if any.
| |
| getCacheKey | back to summary |
|---|---|
| protected Object getCacheKey(Method method, Class<?> targetClass) Determine a cache key for the given method and target class. Must not produce same key for overloaded methods. Must produce same key for different instances of the same method. | |
| getTransactionAttribute | back to summary |
|---|---|
| public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) Implements org. Determine the transaction attribute for this method invocation. Defaults to the class's transaction attribute if no method attribute is found.
| |
| setEmbeddedValueResolver | back to summary |
|---|---|
| public void setEmbeddedValueResolver(StringValueResolver resolver) Implements org. Doc from org. Set the StringValueResolver to use for resolving embedded definition values.
| |