Top Description Methods
org.springframework.cache.annotation

public Interface CacheAnnotationParser

Known Direct Implementers
org.springframework.cache.annotation.SpringCacheAnnotationParser
Imports
java.lang.reflect.Method, java.util.Collection, org.springframework.cache.interceptor.CacheOperation, org.springframework.lang.Nullable

Strategy interface for parsing known caching annotation types. AnnotationCacheOperationSource delegates to such parsers for supporting specific annotation types such as Spring's own Cacheable, CachePut andCacheEvict.
Authors
Costin Leau, Stephane Nicoll, Juergen Hoeller
Since
3.1
See Also
AnnotationCacheOperationSource, SpringCacheAnnotationParser

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

false if the class is known to have no cache operation annotations at class or method level; true otherwise. The default implementation returns true, leading to regular introspection.
isCandidateClass
(Class<?>
the class to introspect
targetClass
)

Determine whether the given class is a candidate for cache operations in the annotation format of this CacheAnnotationParser.

public Collection<CacheOperation>

Returns:

the configured caching operation, or null if none found
parseCacheAnnotations
(Class<?>
the annotated class
type
)

Parse the cache definition for the given class, based on an annotation type understood by this parser.

public Collection<CacheOperation>

Returns:

the configured caching operation, or null if none found
parseCacheAnnotations
(Method
the annotated method
method
)

Parse the cache definition for the given method, based on an annotation type understood by this parser.

Method Detail

isCandidateClassback to summary
public default boolean isCandidateClass(Class<?> targetClass)

Determine whether the given class is a candidate for cache operations in the annotation format of this CacheAnnotationParser.

If this method returns false, the methods on the given class will not get traversed for #parseCacheAnnotations introspection. Returning false is therefore an optimization for non-affected classes, whereas true simply means that the class needs to get fully introspected for each method on the given class individually.

Parameters
targetClass:Class<?>

the class to introspect

Returns:boolean

false if the class is known to have no cache operation annotations at class or method level; true otherwise. The default implementation returns true, leading to regular introspection.

Since
5.2
parseCacheAnnotationsback to summary
public 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 null if the class is not cacheable.

Parameters
type:Class<?>

the annotated class

Returns:Collection<CacheOperation>

the configured caching operation, or null if none found

Annotations
@Nullable
See Also
AnnotationCacheOperationSource#findCacheOperations(Class)
parseCacheAnnotationsback to summary
public 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 null if the method is not cacheable.

Parameters
method:Method

the annotated method

Returns:Collection<CacheOperation>

the configured caching operation, or null if none found

Annotations
@Nullable
See Also
AnnotationCacheOperationSource#findCacheOperations(Method)