}
//this method was roughly based on the implementation of:
//org.springframework.cache.interceptor.LazyParamAwareEvaluationContext#loadArgsAsVariables(...)
private EvaluationContext getEvaluationContext(Class<?> targetClass, Method method, Object[] args) {
EvaluationContext context = new StandardEvaluationContext();
if (ArrayUtils.isEmpty(args)) {
return context;
}
Method targetMethod = getTargetMethod(targetClass, method);
for (int i = 0; i < args.length; i++) {
context.setVariable("p" + i, args[i]);
}
String[] parameterNames = paramNameDiscoverer.getParameterNames(targetMethod);
if (parameterNames != null) {
for (int i = 0; i < parameterNames.length; i++) {
context.setVariable(parameterNames[i], args[i]);
}
}
return context;
}