public class

AnnotationCacheDefinitionSource

extends AbstractFallbackCacheDefinitionSource
implements Serializable
java.lang.Object
   ↳ org.springframework.cache.interceptor.AbstractFallbackCacheDefinitionSource
     ↳ org.springframework.cache.annotation.AnnotationCacheDefinitionSource

Class Overview

Implementation of the CacheDefinitionSource interface for working with caching metadata in JDK 1.5+ annotation format.

This class reads Spring's JDK 1.5+ Cacheable and CacheEvict annotations and exposes corresponding caching operation definition to Spring's cache infrastructure. This class may also serve as base class for a custom CacheDefinitionSource.

Summary

[Expand]
Inherited Fields
From class org.springframework.cache.interceptor.AbstractFallbackCacheDefinitionSource
Public Constructors
AnnotationCacheDefinitionSource()
Create a default AnnotationCacheOperationDefinitionSource, supporting public methods that carry the Cacheable and CacheInvalidate annotations.
AnnotationCacheDefinitionSource(boolean publicMethodsOnly)
Create a custom AnnotationCacheOperationDefinitionSource, supporting public methods that carry the Cacheable and CacheInvalidate annotations.
AnnotationCacheDefinitionSource(CacheAnnotationParser... annotationParsers)
Create a custom AnnotationCacheOperationDefinitionSource.
Protected Methods
boolean allowPublicMethodsOnly()
By default, only public methods can be made cacheable.
CacheDefinition determineCacheDefinition(AnnotatedElement ae)
Determine the cache operation definition for the given method or class.
CacheDefinition findCacheDefinition(Class<?> clazz)
Subclasses need to implement this to return the caching attribute for the given class, if any.
CacheDefinition findCacheOperation(Method method)
Subclasses need to implement this to return the caching attribute for the given method, if any.
[Expand]
Inherited Methods
From class org.springframework.cache.interceptor.AbstractFallbackCacheDefinitionSource
From class java.lang.Object
From interface org.springframework.cache.interceptor.CacheDefinitionSource

Public Constructors

public AnnotationCacheDefinitionSource ()

Create a default AnnotationCacheOperationDefinitionSource, supporting public methods that carry the Cacheable and CacheInvalidate annotations.

public AnnotationCacheDefinitionSource (boolean publicMethodsOnly)

Create a custom AnnotationCacheOperationDefinitionSource, supporting public methods that carry the Cacheable and CacheInvalidate annotations.

Parameters
publicMethodsOnly whether to support only annotated public methods typically for use with proxy-based AOP), or protected/private methods as well (typically used with AspectJ class weaving)

public AnnotationCacheDefinitionSource (CacheAnnotationParser... annotationParsers)

Create a custom AnnotationCacheOperationDefinitionSource.

Parameters
annotationParsers the CacheAnnotationParser to use

Protected Methods

protected boolean allowPublicMethodsOnly ()

By default, only public methods can be made cacheable.

protected CacheDefinition determineCacheDefinition (AnnotatedElement ae)

Determine the cache operation definition for the given method or class.

This implementation delegates to configured CacheAnnotationParsers for parsing known annotations into Spring's metadata attribute class. Returns null if it's not cacheable.

Can be overridden to support custom annotations that carry caching metadata.

Parameters
ae the annotated method or class
Returns
  • CacheOperationDefinition the configured caching operation, or null if none was found

protected CacheDefinition findCacheDefinition (Class<?> clazz)

Subclasses need to implement this to return the caching attribute for the given class, if any.

Parameters
clazz the class to retrieve the attribute for
Returns
  • all caching attribute associated with this class (or null if none)

protected CacheDefinition findCacheOperation (Method method)

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

Parameters
method the method to retrieve the attribute for
Returns
  • all caching attribute associated with this method (or null if none)