Java 类org.springframework.context.expression.AnnotatedElementKey 实例源码

项目:spring4-understanding    文件:ExpressionEvaluatorTests.java   
@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 = eval.createEvaluationContext(caches, method, args, target, target.getClass());
    Collection<CacheOperation> ops = getOps("multipleCaching");

    Iterator<CacheOperation> it = ops.iterator();

    AnnotatedElementKey key = new AnnotatedElementKey(method, AnnotatedClass.class);

    Object keyA = eval.key(it.next().getKey(), key, evalCtx);
    Object keyB = eval.key(it.next().getKey(), key, evalCtx);

    assertEquals(args[0], keyA);
    assertEquals(args[1], keyB);
}
项目:spring4-understanding    文件:AbstractFallbackJCacheOperationSource.java   
@Override
public JCacheOperation<?> getCacheOperation(Method method, Class<?> targetClass) {
    Object cacheKey = new AnnotatedElementKey(method, targetClass);
    Object cached = this.cache.get(cacheKey);

    if (cached != null) {
        return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation<?>) cached : null);
    }
    else {
        JCacheOperation<?> operation = computeCacheOperation(method, targetClass);
        if (operation != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Adding cacheable method '" + method.getName() + "' with operation: " + operation);
            }
            this.cache.put(cacheKey, operation);
        }
        else {
            this.cache.put(cacheKey, NULL_CACHING_ATTRIBUTE);
        }
        return operation;
    }
}
项目:Qihua    文件:CacheAspectSupport.java   
public CacheOperationContext(CacheOperationMetadata metadata, Object[] args, Object target) {
  this.metadata = metadata;
  this.args = extractArgs(metadata.method, args);
  this.target = target;
  caches = CacheAspectSupport.this.getCaches(this, metadata.cacheResolver);
  cacheNames = createCacheNames(caches);
  methodCacheKey = new AnnotatedElementKey(metadata.method, metadata.targetClass);
}
项目:spring4-understanding    文件:EventExpressionEvaluator.java   
/**
 * Specify if the condition defined by the specified expression matches.
 */
public boolean condition(String conditionExpression,
        AnnotatedElementKey elementKey, EvaluationContext evalContext) {

    return getExpression(this.conditionCache, elementKey, conditionExpression)
            .getValue(evalContext, boolean.class);
}
项目:spring4-understanding    文件:EventExpressionEvaluator.java   
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;
}
项目:spring4-understanding    文件:ApplicationListenerMethodAdapter.java   
public ApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method) {
    this.beanName = beanName;
    this.method = method;
    this.targetClass = targetClass;
    this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
    this.declaredEventTypes = resolveDeclaredEventTypes();
    this.methodKey = new AnnotatedElementKey(this.method, this.targetClass);
}
项目:spring4-understanding    文件:CacheAspectSupport.java   
public CacheOperationContext(CacheOperationMetadata metadata, Object[] args, Object target) {
    this.metadata = metadata;
    this.args = extractArgs(metadata.method, args);
    this.target = target;
    this.caches = CacheAspectSupport.this.getCaches(this, metadata.cacheResolver);
    this.cacheNames = createCacheNames(this.caches);
    this.methodCacheKey = new AnnotatedElementKey(metadata.method, metadata.targetClass);
}
项目:spring4-understanding    文件:ExpressionEvaluator.java   
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;
}
项目:spring    文件:EventExpressionEvaluator.java   
/**
 * Specify if the condition defined by the specified expression matches.
 */
public boolean condition(String conditionExpression,
        AnnotatedElementKey elementKey, EvaluationContext evalContext) {

    return getExpression(this.conditionCache, elementKey, conditionExpression)
            .getValue(evalContext, boolean.class);
}
项目:spring    文件:EventExpressionEvaluator.java   
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;
}
项目:spring    文件:ApplicationListenerMethodAdapter.java   
public ApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method) {
    this.beanName = beanName;
    this.method = method;
    this.targetClass = targetClass;
    this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
    this.declaredEventTypes = resolveDeclaredEventTypes();
    this.methodKey = new AnnotatedElementKey(this.method, this.targetClass);
}
项目:spring    文件:CacheAspectSupport.java   
public CacheOperationContext(CacheOperationMetadata metadata, Object[] args, Object target) {
    this.metadata = metadata;
    this.args = extractArgs(metadata.method, args);
    this.target = target;
    this.caches = CacheAspectSupport.this.getCaches(this, metadata.cacheResolver);
    this.cacheNames = createCacheNames(this.caches);
    this.methodCacheKey = new AnnotatedElementKey(metadata.method, metadata.targetClass);
}
项目:spring    文件:CacheOperationExpressionEvaluator.java   
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;
}
项目:spring-distributelock    文件:LockExpressionEvaluator.java   
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;
}
项目:spring-distributelock    文件:LockOperationContext.java   
public LockOperationContext(LockOperationMetadata metadata, Object target, Method method, Object[] args) {
    this.metadata = metadata;
    this.args = extractArgs(metadata.getMethod(), args);
    this.target = target;
    this.method = method;
    this.methodCacheKey = new AnnotatedElementKey(metadata.getMethod(), metadata.getTargetClass());
}
项目:Qihua    文件:CacheAspectSupport.java   
private CacheOperationCacheKey(CacheOperation cacheOperation, Method method, Class<?> targetClass) {
  this.cacheOperation = cacheOperation;
  methodCacheKey = new AnnotatedElementKey(method, targetClass);
}
项目:spring4-understanding    文件:CacheAspectSupport.java   
private CacheOperationCacheKey(CacheOperation cacheOperation, Method method, Class<?> targetClass) {
    this.cacheOperation = cacheOperation;
    this.methodCacheKey = new AnnotatedElementKey(method, targetClass);
}
项目:spring4-understanding    文件:ExpressionEvaluator.java   
public Object key(String keyExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.keyCache, methodKey, keyExpression).getValue(evalContext);
}
项目:spring4-understanding    文件:ExpressionEvaluator.java   
public boolean condition(String conditionExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.conditionCache, methodKey, conditionExpression).getValue(evalContext, boolean.class);
}
项目:spring4-understanding    文件:ExpressionEvaluator.java   
public boolean unless(String unlessExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.unlessCache, methodKey, unlessExpression).getValue(evalContext, boolean.class);
}
项目:spring    文件:CacheAspectSupport.java   
private CacheOperationCacheKey(CacheOperation cacheOperation, Method method, Class<?> targetClass) {
    this.cacheOperation = cacheOperation;
    this.methodCacheKey = new AnnotatedElementKey(method, targetClass);
}
项目:spring    文件:CacheOperationExpressionEvaluator.java   
public Object key(String keyExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.keyCache, methodKey, keyExpression).getValue(evalContext);
}
项目:spring    文件:CacheOperationExpressionEvaluator.java   
public boolean condition(String conditionExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.conditionCache, methodKey, conditionExpression).getValue(evalContext, boolean.class);
}
项目:spring    文件:CacheOperationExpressionEvaluator.java   
public boolean unless(String unlessExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.unlessCache, methodKey, unlessExpression).getValue(evalContext, boolean.class);
}
项目:spring-distributelock    文件:LockExpressionEvaluator.java   
public Object key(String keyExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
    return getExpression(this.lockCache, methodKey, keyExpression).getValue(evalContext);
}
项目:spring-distributelock    文件:LockOperationContext.java   
public AnnotatedElementKey getMethodCacheKey() {
    return methodCacheKey;
}
项目:spring4-understanding    文件:AbstractFallbackCacheOperationSource.java   
/**
 * Determine a cache key for the given method and target class.
 * <p>Must not produce same key for overloaded methods.
 * Must produce same key for different instances of the same method.
 * @param method the method (never {@code null})
 * @param targetClass the target class (may be {@code null})
 * @return the cache key (never {@code null})
 */
protected Object getCacheKey(Method method, Class<?> targetClass) {
    return new AnnotatedElementKey(method, targetClass);
}