Example usage for org.springframework.core MethodClassKey MethodClassKey

List of usage examples for org.springframework.core MethodClassKey MethodClassKey

Introduction

In this page you can find the example usage for org.springframework.core MethodClassKey MethodClassKey.

Prototype

public MethodClassKey(Method method, @Nullable Class<?> targetClass) 

Source Link

Document

Create a key object for the given method and target class.

Usage

From source file:org.hswebframework.web.cache.spring.fix.FixUseSupperClassFallbackCacheOperationSource.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})
 *//*from   w  ww.j  av a  2 s .co m*/
protected Object getCacheKey(Method method, Class<?> targetClass) {
    return new MethodClassKey(method, targetClass);
}

From source file:org.springframework.cache.interceptor.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})
 *//*from   w ww .  j  a va  2  s  .  c om*/
protected Object getCacheKey(Method method, @Nullable Class<?> targetClass) {
    return new MethodClassKey(method, targetClass);
}

From source file:org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource.java

@Override
public JCacheOperation<?> getCacheOperation(Method method, Class<?> targetClass) {
    MethodClassKey cacheKey = new MethodClassKey(method, targetClass);
    Object cached = this.cache.get(cacheKey);

    if (cached != null) {
        return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation<?>) cached : null);
    } else {/*from  w  ww  . ja v  a 2  s.  c om*/
        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;
    }
}