Class AnnotationJCacheOperationSource

java.lang.Object
org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource
org.springframework.cache.jcache.interceptor.AnnotationJCacheOperationSource
All Implemented Interfaces:
JCacheOperationSource
Direct Known Subclasses:
DefaultJCacheOperationSource

public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJCacheOperationSource
Implementation of the JCacheOperationSource interface that reads the JSR-107 CacheResult, CachePut, CacheRemove and CacheRemoveAll annotations.
Since:
4.1
Author:
Stephane Nicoll, Juergen Hoeller
  • Constructor Details

    • AnnotationJCacheOperationSource

      public AnnotationJCacheOperationSource()
  • Method Details

    • isCandidateClass

      public boolean isCandidateClass(Class<?> targetClass)
      Description copied from interface: JCacheOperationSource
      Determine whether the given class is a candidate for cache operations in the metadata format of this JCacheOperationSource.

      If this method returns false, the methods on the given class will not get traversed for JCacheOperationSource.getCacheOperation(Method, Class) 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 - the class to introspect
      Returns:
      false if the class is known to have no cache operation metadata at class or method level; true otherwise. The default implementation returns true, leading to regular introspection.
      See Also:
    • findCacheOperation

      protected @Nullable JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType)
      Description copied from class: AbstractFallbackJCacheOperationSource
      Subclasses need to implement this to return the caching operation for the given method, if any.
      Specified by:
      findCacheOperation in class AbstractFallbackJCacheOperationSource
      Parameters:
      method - the method to retrieve the operation for
      targetType - the target class
      Returns:
      the cache operation associated with this method (or null if none)
    • getCacheDefaults

      protected @Nullable javax.cache.annotation.CacheDefaults getCacheDefaults(Method method, @Nullable Class<?> targetType)
    • createCacheResultOperation

      protected org.springframework.cache.jcache.interceptor.CacheResultOperation createCacheResultOperation(Method method, @Nullable javax.cache.annotation.CacheDefaults defaults, javax.cache.annotation.CacheResult ann)
    • createCachePutOperation

      protected org.springframework.cache.jcache.interceptor.CachePutOperation createCachePutOperation(Method method, @Nullable javax.cache.annotation.CacheDefaults defaults, javax.cache.annotation.CachePut ann)
    • createCacheRemoveOperation

      protected org.springframework.cache.jcache.interceptor.CacheRemoveOperation createCacheRemoveOperation(Method method, @Nullable javax.cache.annotation.CacheDefaults defaults, javax.cache.annotation.CacheRemove ann)
    • createCacheRemoveAllOperation

      protected org.springframework.cache.jcache.interceptor.CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, @Nullable javax.cache.annotation.CacheDefaults defaults, javax.cache.annotation.CacheRemoveAll ann)
    • getCacheResolver

      protected CacheResolver getCacheResolver(@Nullable javax.cache.annotation.CacheResolverFactory factory, javax.cache.annotation.CacheMethodDetails<?> details)
    • getExceptionCacheResolver

      protected CacheResolver getExceptionCacheResolver(@Nullable javax.cache.annotation.CacheResolverFactory factory, javax.cache.annotation.CacheMethodDetails<javax.cache.annotation.CacheResult> details)
    • determineCacheResolverFactory

      protected @Nullable javax.cache.annotation.CacheResolverFactory determineCacheResolverFactory(@Nullable javax.cache.annotation.CacheDefaults defaults, Class<? extends javax.cache.annotation.CacheResolverFactory> candidate)
    • determineKeyGenerator

      protected KeyGenerator determineKeyGenerator(@Nullable javax.cache.annotation.CacheDefaults defaults, Class<? extends javax.cache.annotation.CacheKeyGenerator> candidate)
    • determineCacheName

      protected String determineCacheName(Method method, @Nullable javax.cache.annotation.CacheDefaults defaults, String candidate)
    • generateDefaultCacheName

      protected String generateDefaultCacheName(Method method)
      Generate a default cache name for the specified Method.
      Parameters:
      method - the annotated method
      Returns:
      the default cache name, according to JSR-107
    • getBean

      protected abstract <T> T getBean(Class<T> type)
      Locate or create an instance of the specified cache strategy type.
      Parameters:
      type - the type of the bean to manage
      Returns:
      the required bean
    • getDefaultCacheResolver

      protected abstract CacheResolver getDefaultCacheResolver()
      Return the default CacheResolver if none is set.
    • getDefaultExceptionCacheResolver

      protected abstract CacheResolver getDefaultExceptionCacheResolver()
      Return the default exception CacheResolver if none is set.
    • getDefaultKeyGenerator

      protected abstract KeyGenerator getDefaultKeyGenerator()
      Return the default KeyGenerator if none is set.