transaction names based on method id from most specific method (target class instead of interface; SPR-7317)

This commit is contained in:
Juergen Hoeller
2010-06-28 19:47:13 +00:00
parent f9017ea05d
commit 4d56b89619
3 changed files with 31 additions and 11 deletions

View File

@@ -270,7 +270,25 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
// If the transaction attribute is null, the method is non-transactional.
TransactionAttribute txAttr = getTransactionAttributeSource().getTransactionAttribute(method, targetClass);
PlatformTransactionManager tm = determineTransactionManager(txAttr);
return createTransactionIfNecessary(tm, txAttr, methodIdentification(method));
return createTransactionIfNecessary(tm, txAttr, methodIdentification(method, targetClass));
}
/**
* Convenience method to return a String representation of this Method
* for use in logging. Can be overridden in subclasses to provide a
* different identifier for the given method.
* @param method the method we're interested in
* @param targetClass class the method is on
* @return log message identifying this method
* @see org.springframework.util.ClassUtils#getQualifiedMethodName
*/
protected String methodIdentification(Method method, Class targetClass) {
String simpleMethodId = methodIdentification(method);
if (simpleMethodId != null) {
return simpleMethodId;
}
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
return ClassUtils.getQualifiedMethodName(specificMethod);
}
/**
@@ -279,10 +297,11 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
* different identifier for the given method.
* @param method the method we're interested in
* @return log message identifying this method
* @see org.springframework.util.ClassUtils#getQualifiedMethodName
* @deprecated in favor of {@link #methodIdentification(Method, Class)}
*/
@Deprecated
protected String methodIdentification(Method method) {
return ClassUtils.getQualifiedMethodName(method);
return null;
}
/**

View File

@@ -98,7 +98,7 @@ public class TransactionInterceptor extends TransactionAspectSupport implements
final TransactionAttribute txAttr =
getTransactionAttributeSource().getTransactionAttribute(invocation.getMethod(), targetClass);
final PlatformTransactionManager tm = determineTransactionManager(txAttr);
final String joinpointIdentification = methodIdentification(invocation.getMethod());
final String joinpointIdentification = methodIdentification(invocation.getMethod(), targetClass);
if (txAttr == null || !(tm instanceof CallbackPreferringPlatformTransactionManager)) {
// Standard transaction demarcation with getTransaction and commit/rollback calls.