|
|
|
@ -55,7 +55,13 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran |
|
|
|
* Canonical value held in cache to indicate no transaction attribute was |
|
|
|
* Canonical value held in cache to indicate no transaction attribute was |
|
|
|
* found for this method, and we don't need to look again. |
|
|
|
* found for this method, and we don't need to look again. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final TransactionAttribute NULL_TRANSACTION_ATTRIBUTE = new DefaultTransactionAttribute(); |
|
|
|
@SuppressWarnings("serial") |
|
|
|
|
|
|
|
private static final TransactionAttribute NULL_TRANSACTION_ATTRIBUTE = new DefaultTransactionAttribute() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
|
|
|
return "null"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -78,7 +84,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran |
|
|
|
* <p>Defaults to the class's transaction attribute if no method attribute is found. |
|
|
|
* <p>Defaults to the class's transaction attribute if no method attribute is found. |
|
|
|
* @param method the method for the current invocation (never {@code null}) |
|
|
|
* @param method the method for the current invocation (never {@code null}) |
|
|
|
* @param targetClass the target class for this invocation (may be {@code null}) |
|
|
|
* @param targetClass the target class for this invocation (may be {@code null}) |
|
|
|
* @return TransactionAttribute for this method, or {@code null} if the method |
|
|
|
* @return a TransactionAttribute for this method, or {@code null} if the method |
|
|
|
* is not transactional |
|
|
|
* is not transactional |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -90,7 +96,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran |
|
|
|
|
|
|
|
|
|
|
|
// First, see if we have a cached value.
|
|
|
|
// First, see if we have a cached value.
|
|
|
|
Object cacheKey = getCacheKey(method, targetClass); |
|
|
|
Object cacheKey = getCacheKey(method, targetClass); |
|
|
|
Object cached = this.attributeCache.get(cacheKey); |
|
|
|
TransactionAttribute cached = this.attributeCache.get(cacheKey); |
|
|
|
if (cached != null) { |
|
|
|
if (cached != null) { |
|
|
|
// Value will either be canonical value indicating there is no transaction attribute,
|
|
|
|
// Value will either be canonical value indicating there is no transaction attribute,
|
|
|
|
// or an actual transaction attribute.
|
|
|
|
// or an actual transaction attribute.
|
|
|
|
@ -98,7 +104,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
return (TransactionAttribute) cached; |
|
|
|
return cached; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
@ -182,25 +188,22 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Subclasses need to implement this to return the transaction attribute |
|
|
|
* Subclasses need to implement this to return the transaction attribute for the |
|
|
|
* for the given method, if any. |
|
|
|
* given class, if any. |
|
|
|
* @param method the method to retrieve the attribute for |
|
|
|
* @param clazz the class to retrieve the attribute for |
|
|
|
* @return all transaction attribute associated with this method |
|
|
|
* @return all transaction attribute associated with this class, or {@code null} if none |
|
|
|
* (or {@code null} if none) |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
protected abstract TransactionAttribute findTransactionAttribute(Method method); |
|
|
|
protected abstract TransactionAttribute findTransactionAttribute(Class<?> clazz); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Subclasses need to implement this to return the transaction attribute |
|
|
|
* Subclasses need to implement this to return the transaction attribute for the |
|
|
|
* for the given class, if any. |
|
|
|
* given method, if any. |
|
|
|
* @param clazz the class to retrieve the attribute for |
|
|
|
* @param method the method to retrieve the attribute for |
|
|
|
* @return all transaction attribute associated with this class
|
|
|
|
* @return all transaction attribute associated with this method, or {@code null} if none |
|
|
|
* (or {@code null} if none) |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
protected abstract TransactionAttribute findTransactionAttribute(Class<?> clazz); |
|
|
|
protected abstract TransactionAttribute findTransactionAttribute(Method method); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Should only public methods be allowed to have transactional semantics? |
|
|
|
* Should only public methods be allowed to have transactional semantics? |
|
|
|
|