Search in sources :

Example 1 with AnnotatedElementKey

use of org.springframework.context.expression.AnnotatedElementKey in project spring-framework by spring-projects.

the class EventExpressionEvaluator method getTargetMethod.

private Method getTargetMethod(Class<?> targetClass, Method method) {
    AnnotatedElementKey methodKey = new AnnotatedElementKey(method, targetClass);
    Method targetMethod = this.targetMethodCache.get(methodKey);
    if (targetMethod == null) {
        targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
        if (targetMethod == null) {
            targetMethod = method;
        }
        this.targetMethodCache.put(methodKey, targetMethod);
    }
    return targetMethod;
}
Also used : Method(java.lang.reflect.Method) AnnotatedElementKey(org.springframework.context.expression.AnnotatedElementKey)

Example 2 with AnnotatedElementKey

use of org.springframework.context.expression.AnnotatedElementKey in project spring-framework by spring-projects.

the class ExpressionEvaluatorTests method testMultipleCachingEval.

@Test
public void testMultipleCachingEval() throws Exception {
    AnnotatedClass target = new AnnotatedClass();
    Method method = ReflectionUtils.findMethod(AnnotatedClass.class, "multipleCaching", Object.class, Object.class);
    Object[] args = new Object[] { new Object(), new Object() };
    Collection<ConcurrentMapCache> caches = Collections.singleton(new ConcurrentMapCache("test"));
    EvaluationContext evalCtx = this.eval.createEvaluationContext(caches, method, args, target, target.getClass(), null);
    Collection<CacheOperation> ops = getOps("multipleCaching");
    Iterator<CacheOperation> it = ops.iterator();
    AnnotatedElementKey key = new AnnotatedElementKey(method, AnnotatedClass.class);
    Object keyA = this.eval.key(it.next().getKey(), key, evalCtx);
    Object keyB = this.eval.key(it.next().getKey(), key, evalCtx);
    assertEquals(args[0], keyA);
    assertEquals(args[1], keyB);
}
Also used : ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Method(java.lang.reflect.Method) EvaluationContext(org.springframework.expression.EvaluationContext) AnnotatedElementKey(org.springframework.context.expression.AnnotatedElementKey) Test(org.junit.Test)

Example 3 with AnnotatedElementKey

use of org.springframework.context.expression.AnnotatedElementKey in project spring-framework by spring-projects.

the class CacheOperationExpressionEvaluator method getTargetMethod.

private Method getTargetMethod(Class<?> targetClass, Method method) {
    AnnotatedElementKey methodKey = new AnnotatedElementKey(method, targetClass);
    Method targetMethod = this.targetMethodCache.get(methodKey);
    if (targetMethod == null) {
        targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
        if (targetMethod == null) {
            targetMethod = method;
        }
        this.targetMethodCache.put(methodKey, targetMethod);
    }
    return targetMethod;
}
Also used : Method(java.lang.reflect.Method) AnnotatedElementKey(org.springframework.context.expression.AnnotatedElementKey)

Aggregations

Method (java.lang.reflect.Method)3 AnnotatedElementKey (org.springframework.context.expression.AnnotatedElementKey)3 Test (org.junit.Test)1 ConcurrentMapCache (org.springframework.cache.concurrent.ConcurrentMapCache)1 EvaluationContext (org.springframework.expression.EvaluationContext)1