Top Description Fields Constructors Methods
org.springframework.cache.jcache.interceptor

public abstract Class AnnotationJCacheOperationSource

extends AbstractFallbackJCacheOperationSource
Class Inheritance
Known Direct Subclasses
org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource
Imports
java.lang.annotation.Annotation, java.lang.reflect.Method, java.util.ArrayList, .List, javax.cache.annotation.CacheDefaults, .CacheKeyGenerator, .CacheMethodDetails, .CachePut, .CacheRemove, .CacheRemoveAll, .CacheResolverFactory, .CacheResult, org.springframework.cache.interceptor.CacheResolver, .KeyGenerator, org.springframework.lang.Nullable, org.springframework.util.StringUtils

Implementation of the JCacheOperationSource interface that reads the JSR-107 CacheResult, CachePut, CacheRemove and CacheRemoveAll annotations.
Author
Stephane Nicoll
Since
4.1

Field Summary

Inherited from org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource:
logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private int
countNonNull(Object... instances)

protected CachePutOperation
protected CacheRemoveAllOperation
protected CacheRemoveOperation
protected CacheResultOperation
private <A extends Annotation> CacheMethodDetails<A>
createMethodDetails(Method method, A annotation, String cacheName)

protected String
determineCacheName(Method method, CacheDefaults defaults, String candidate)

protected CacheResolverFactory
protected KeyGenerator
protected JCacheOperation<?>
findCacheOperation(Method
the method to retrieve the operation for
method
,
Class<?>
the target class
targetType
)

Implements abstract org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource.findCacheOperation.

Subclasses need to implement this to return the caching operation for the given method, if any.

protected String

Returns:

the default cache name, according to JSR-107
generateDefaultCacheName
(Method
the annotated method
method
)

Generate a default cache name for the specified Method.

protected abstract <T> T

Returns:

the required bean
getBean
(Class<T>
the type of the bean to manage
type
)

Locate or create an instance of the specified cache strategy type.

protected CacheDefaults
getCacheDefaults(Method method, Class<?> targetType)

protected CacheResolver
protected abstract CacheResolver
getDefaultCacheResolver()

Return the default CacheResolver if none is set.

protected abstract CacheResolver
getDefaultExceptionCacheResolver()

Return the default exception CacheResolver if none is set.

protected abstract KeyGenerator
getDefaultKeyGenerator()

Return the default KeyGenerator if none is set.

protected CacheResolver
Inherited from org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource:
allowPublicMethodsOnlygetCacheOperation

Constructor Detail

AnnotationJCacheOperationSourceback to summary
public AnnotationJCacheOperationSource()

Method Detail

countNonNullback to summary
private int countNonNull(Object... instances)
createCachePutOperationback to summary
protected CachePutOperation createCachePutOperation(Method method, CacheDefaults defaults, CachePut ann)
createCacheRemoveAllOperationback to summary
protected CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, CacheDefaults defaults, CacheRemoveAll ann)
createCacheRemoveOperationback to summary
protected CacheRemoveOperation createCacheRemoveOperation(Method method, CacheDefaults defaults, CacheRemove ann)
createCacheResultOperationback to summary
protected CacheResultOperation createCacheResultOperation(Method method, CacheDefaults defaults, CacheResult ann)
createMethodDetailsback to summary
private <A extends Annotation> CacheMethodDetails<A> createMethodDetails(Method method, A annotation, String cacheName)
determineCacheNameback to summary
protected String determineCacheName(Method method, CacheDefaults defaults, String candidate)
determineCacheResolverFactoryback to summary
protected CacheResolverFactory determineCacheResolverFactory(CacheDefaults defaults, Class<? extends CacheResolverFactory> candidate)
Annotations
@Nullable
determineKeyGeneratorback to summary
protected KeyGenerator determineKeyGenerator(CacheDefaults defaults, Class<? extends CacheKeyGenerator> candidate)
findCacheOperationback to summary
protected JCacheOperation<?> findCacheOperation(Method method, Class<?> targetType)

Implements abstract org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource.findCacheOperation.

Doc from org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource.findCacheOperation.

Subclasses need to implement this to return the caching operation for the given method, if any.

Parameters
method:Method

the method to retrieve the operation for

targetType:Class<?>

the target class

Returns:JCacheOperation<?>

the cache operation associated with this method (or null if none)

Annotations
@Override
generateDefaultCacheNameback to summary
protected String generateDefaultCacheName(Method method)

Generate a default cache name for the specified Method.

Parameters
method:Method

the annotated method

Returns:String

the default cache name, according to JSR-107

getBeanback to summary
protected abstract <T> T getBean(Class<T> type)

Locate or create an instance of the specified cache strategy type.

Parameters
type:Class<T>

the type of the bean to manage

Returns:T

the required bean

getCacheDefaultsback to summary
protected CacheDefaults getCacheDefaults(Method method, Class<?> targetType)
Annotations
@Nullable
getCacheResolverback to summary
protected CacheResolver getCacheResolver(CacheResolverFactory factory, CacheMethodDetails<?> details)
getDefaultCacheResolverback to summary
protected abstract CacheResolver getDefaultCacheResolver()

Return the default CacheResolver if none is set.

getDefaultExceptionCacheResolverback to summary
protected abstract CacheResolver getDefaultExceptionCacheResolver()

Return the default exception CacheResolver if none is set.

getDefaultKeyGeneratorback to summary
protected abstract KeyGenerator getDefaultKeyGenerator()

Return the default KeyGenerator if none is set.

getExceptionCacheResolverback to summary
protected CacheResolver getExceptionCacheResolver(CacheResolverFactory factory, CacheMethodDetails<CacheResult> details)