Interface CacheAnnotationParser
- All Known Implementing Classes:
SpringCacheAnnotationParser
public interface CacheAnnotationParser
Strategy interface for parsing known caching annotation types.AnnotationCacheOperationSourcedelegates to such parsers for supporting specific annotation types such as Spring's ownCacheable,CachePutandCacheEvict.- Since:
- 3.1
- Author:
- Costin Leau, Stephane Nicoll, Juergen Hoeller
- See Also:
AnnotationCacheOperationSource,SpringCacheAnnotationParser
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanisCandidateClass(Class<?> targetClass)Determine whether the given class is a candidate for cache operations in the annotation format of thisCacheAnnotationParser.Collection<CacheOperation>parseCacheAnnotations(Class<?> type)Parse the cache definition for the given class, based on an annotation type understood by this parser.Collection<CacheOperation>parseCacheAnnotations(Method method)Parse the cache definition for the given method, based on an annotation type understood by this parser.
Method Detail
isCandidateClass
default boolean isCandidateClass(Class<?> targetClass)
Determine whether the given class is a candidate for cache operations in the annotation format of thisCacheAnnotationParser.If this method returns
false, the methods on the given class will not get traversed for#parseCacheAnnotationsintrospection. Returningfalseis therefore an optimization for non-affected classes, whereastruesimply means that the class needs to get fully introspected for each method on the given class individually.- Parameters:
targetClass- the class to introspect- Returns:
falseif the class is known to have no cache operation annotations at class or method level;trueotherwise. The default implementation returnstrue, leading to regular introspection.- Since:
- 5.2
parseCacheAnnotations
@Nullable Collection<CacheOperation> parseCacheAnnotations(Class<?> type)
Parse the cache definition for the given class, based on an annotation type understood by this parser.This essentially parses a known cache annotation into Spring's metadata attribute class. Returns
nullif the class is not cacheable.- Parameters:
type- the annotated class- Returns:
- the configured caching operation, or
nullif none found - See Also:
AnnotationCacheOperationSource.findCacheOperations(Class)
parseCacheAnnotations
@Nullable Collection<CacheOperation> parseCacheAnnotations(Method method)
Parse the cache definition for the given method, based on an annotation type understood by this parser.This essentially parses a known cache annotation into Spring's metadata attribute class. Returns
nullif the method is not cacheable.- Parameters:
method- the annotated method- Returns:
- the configured caching operation, or
nullif none found - See Also:
AnnotationCacheOperationSource.findCacheOperations(Method)