List of usage examples for org.springframework.aop.support AopUtils getMostSpecificMethod
public static Method getMostSpecificMethod(Method method, @Nullable Class<?> targetClass)
From source file:org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.java
private void addArgumentsAsVariables() { Object[] args = mi.getArguments(); if (args.length == 0) { return;/*from ww w . jav a 2s. c o m*/ } Object targetObject = mi.getThis(); // SEC-1454 Class<?> targetClass = AopProxyUtils.ultimateTargetClass(targetObject); if (targetClass == null) { // TODO: Spring should do this, but there's a bug in ultimateTargetClass() // which returns null targetClass = targetObject.getClass(); } Method method = AopUtils.getMostSpecificMethod(mi.getMethod(), targetClass); String[] paramNames = parameterNameDiscoverer.getParameterNames(method); if (paramNames == null) { logger.warn("Unable to resolve method parameter names for method: " + method + ". Debug symbol information is required if you are using parameter names in expressions."); return; } for (int i = 0; i < args.length; i++) { if (paramNames[i] != null) { setVariable(paramNames[i], args[i]); } } }
From source file:org.springframework.transaction.interceptor.AttributesTransactionAttributeSource.java
/** * Same return as getTransactionAttribute method, but doesn't cache the result. * getTransactionAttribute is a caching decorator for this method. *///from w w w. jav a2 s. c o m protected TransactionAttribute computeTransactionAttribute(Method method, Class targetClass) { // The method may be on an interface, but we need attributes from the target class. // The AopUtils class provides a convenience method for this. If the target class // is null, the method will be unchanged. Method specificMethod = AopUtils.getMostSpecificMethod(method, targetClass); // First try is the method in the target class TransactionAttribute txAtt = findTransactionAttribute(attributes.getAttributes(specificMethod)); if (txAtt != null) return txAtt; // Second try is the transaction attribute on the target class txAtt = findTransactionAttribute(attributes.getAttributes(specificMethod.getDeclaringClass())); if (txAtt != null) return txAtt; if (specificMethod != method) { // Fallback is to look at the original method txAtt = findTransactionAttribute(attributes.getAttributes(method)); if (txAtt != null) return txAtt; // Last fallback is the class of the original method return findTransactionAttribute(attributes.getAttributes(method.getDeclaringClass())); } return null; }