Polishing

This commit is contained in:
Juergen Hoeller
2018-08-09 11:59:15 +02:00
parent 8f513f8561
commit 8e571decc1
6 changed files with 65 additions and 67 deletions

View File

@@ -139,14 +139,14 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
@Override
@Nullable
protected TransactionAttribute findTransactionAttribute(Method method) {
return determineTransactionAttribute(method);
protected TransactionAttribute findTransactionAttribute(Class<?> clazz) {
return determineTransactionAttribute(clazz);
}
@Override
@Nullable
protected TransactionAttribute findTransactionAttribute(Class<?> clazz) {
return determineTransactionAttribute(clazz);
protected TransactionAttribute findTransactionAttribute(Method method) {
return determineTransactionAttribute(method);
}
/**

View File

@@ -55,7 +55,13 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
* Canonical value held in cache to indicate no transaction attribute was
* 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";
}
};
/**
@@ -90,7 +96,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
// First, see if we have a cached value.
Object cacheKey = getCacheKey(method, targetClass);
Object cached = this.attributeCache.get(cacheKey);
TransactionAttribute cached = this.attributeCache.get(cacheKey);
if (cached != null) {
// Value will either be canonical value indicating there is no transaction attribute,
// or an actual transaction attribute.
@@ -98,7 +104,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
return null;
}
else {
return (TransactionAttribute) cached;
return cached;
}
}
else {
@@ -182,25 +188,22 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
/**
* Subclasses need to implement this to return the transaction attribute
* for the given method, if any.
* @param method the method to retrieve the attribute for
* @return all transaction attribute associated with this method
* (or {@code null} if none)
*/
@Nullable
protected abstract TransactionAttribute findTransactionAttribute(Method method);
/**
* Subclasses need to implement this to return the transaction attribute
* for the given class, if any.
* Subclasses need to implement this to return the transaction attribute for the
* given class, if any.
* @param clazz the class to retrieve the attribute for
* @return all transaction attribute associated with this class
* (or {@code null} if none)
* @return all transaction attribute associated with this class, or {@code null} if none
*/
@Nullable
protected abstract TransactionAttribute findTransactionAttribute(Class<?> clazz);
/**
* Subclasses need to implement this to return the transaction attribute for the
* given method, if any.
* @param method the method to retrieve the attribute for
* @return all transaction attribute associated with this method, or {@code null} if none
*/
@Nullable
protected abstract TransactionAttribute findTransactionAttribute(Method method);
/**
* Should only public methods be allowed to have transactional semantics?