org.springframework.cache.jcache.interceptor

## Class JCacheAspectSupport

- java.lang.Object
- - org.springframework.cache.interceptor.AbstractCacheInvoker
  - - org.springframework.cache.jcache.interceptor.JCacheAspectSupport

- All Implemented Interfaces:
    InitializingBean
  Direct Known Subclasses:
    JCacheInterceptor

      public class JCacheAspectSupport
      extends AbstractCacheInvoker
      implements InitializingBean

  Base class for JSR-107 caching aspects, such as the `JCacheInterceptor` or an AspectJ aspect.

  Use the Spring caching abstraction for cache-related operations. No JSR-107 `Cache` or `CacheManager` are required to process standard JSR-107 cache annotations.

  The `JCacheOperationSource` is used for determining caching operations

  A cache aspect is serializable if its `JCacheOperationSource` is serializable.

  Since:
    4.1
  Author:
    Stephane Nicoll
  See Also:
    `CacheAspectSupport`, `KeyGeneratorAdapter`, `CacheResolverAdapter`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `logger`

    - ### Fields inherited from class org.springframework.cache.interceptor.AbstractCacheInvoker

      `errorHandler`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JCacheAspectSupport()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Invoked by the containing `BeanFactory` after it has set all bean properties and satisfied `BeanFactoryAware`, `ApplicationContextAware` etc.
    `protected Object` | `execute(CacheOperationInvoker invoker, Object target, Method method, Object[] args)`
    `JCacheOperationSource` | `getCacheOperationSource()` Return the CacheOperationSource for this cache aspect.
    `protected Object` | `invokeOperation(CacheOperationInvoker invoker)` Execute the underlying operation (typically in case of cache miss) and return the result of the invocation.
    `void` | `setCacheOperationSource(JCacheOperationSource cacheOperationSource)` Set the CacheOperationSource for this cache aspect.

    - ### Methods inherited from class org.springframework.cache.interceptor.AbstractCacheInvoker

      `doClear, doEvict, doGet, doPut, getErrorHandler, setErrorHandler`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected final Log logger

  - ### Constructor Detail

    - #### JCacheAspectSupport

          public JCacheAspectSupport()

  - ### Method Detail

    - #### setCacheOperationSource

          public void setCacheOperationSource(JCacheOperationSource cacheOperationSource)

      Set the CacheOperationSource for this cache aspect.

    - #### getCacheOperationSource

          public JCacheOperationSource getCacheOperationSource()

      Return the CacheOperationSource for this cache aspect.

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Description copied from interface: `InitializingBean`
      Invoked by the containing `BeanFactory` after it has set all bean properties and satisfied `BeanFactoryAware`, `ApplicationContextAware` etc.

      This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`

    - #### execute

          @Nullable
          protected Object execute(CacheOperationInvoker invoker,
                                             Object target,
                                             Method method,
                                             Object[] args)

    - #### invokeOperation

          @Nullable
          protected Object invokeOperation(CacheOperationInvoker invoker)

      Execute the underlying operation (typically in case of cache miss) and return the result of the invocation. If an exception occurs it will be wrapped in a `ThrowableWrapper`: the exception can be handled or modified but it must be wrapped in a `ThrowableWrapper` as well.
      Parameters:
        `invoker` - the invoker handling the operation being cached
      Returns:
        the result of the invocation
      See Also:
        `CacheOperationInvoker.invoke()`