Example usage for org.springframework.cache.interceptor CacheOperationSource getCacheOperations

List of usage examples for org.springframework.cache.interceptor CacheOperationSource getCacheOperations

Introduction

In this page you can find the example usage for org.springframework.cache.interceptor CacheOperationSource getCacheOperations.

Prototype

@Nullable
Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass);

Source Link

Document

Return the collection of cache operations for this method, or null if the method contains no cacheable annotations.

Usage

From source file:org.springframework.cache.interceptor.CacheAspectSupport.java

@Nullable
protected Object execute(CacheOperationInvoker invoker, Object target, Method method, Object[] args) {
    // Check whether aspect is enabled (to cope with cases where the AJ is pulled in automatically)
    if (this.initialized) {
        Class<?> targetClass = getTargetClass(target);
        CacheOperationSource cacheOperationSource = getCacheOperationSource();
        if (cacheOperationSource != null) {
            Collection<CacheOperation> operations = cacheOperationSource.getCacheOperations(method,
                    targetClass);/*from   www  .  j  ava2s  .c  o m*/
            if (!CollectionUtils.isEmpty(operations)) {
                return execute(invoker, method,
                        new CacheOperationContexts(operations, method, args, target, targetClass));
            }
        }
    }

    return invoker.invoke();
}