Class CacheProxyFactoryBean

java.lang.Object
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.AbstractSingletonProxyFactoryBean
org.springframework.cache.interceptor.CacheProxyFactoryBean
All Implemented Interfaces:
Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean<Object>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.SmartInitializingSingleton

public class CacheProxyFactoryBean extends org.springframework.aop.framework.AbstractSingletonProxyFactoryBean implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.SmartInitializingSingleton
Proxy factory bean for simplified declarative caching handling. This is a convenient alternative to a standard AOP ProxyFactoryBean with a separate CacheInterceptor definition.

This class is designed to facilitate declarative cache demarcation: namely, wrapping a singleton target object with a caching proxy, proxying all the interfaces that the target implements. Exists primarily for third-party framework integration. Users should favor the cache: XML namespace @Cacheable annotation. See the declarative annotation-based caching section of the Spring reference documentation for more information.

Since:
3.1
Author:
Costin Leau, Juergen Hoeller
See Also:
  • Field Summary

    Fields inherited from interface org.springframework.beans.factory.FactoryBean

    OBJECT_TYPE_ATTRIBUTE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected Object
     
    void
    setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
     
    void
    Set the CacheManager to use to create a default CacheResolver.
    void
    Set one or more sources to find cache operations.
    void
    Set the default CacheResolver that this cache aspect should delegate to if no specific cache resolver has been set for the operation.
    void
    Set the default KeyGenerator that this cache aspect should delegate to if no specific key generator has been set for the operation.
    void
    setPointcut(org.springframework.aop.Pointcut pointcut)
    Set a pointcut, i.e.

    Methods inherited from class org.springframework.aop.framework.AbstractSingletonProxyFactoryBean

    afterPropertiesSet, createTargetSource, getObject, getObjectType, isSingleton, postProcessProxyFactory, setAdvisorAdapterRegistry, setBeanClassLoader, setPostInterceptors, setPreInterceptors, setProxyClassLoader, setProxyInterfaces, setTarget

    Methods inherited from class org.springframework.aop.framework.ProxyConfig

    copyDefault, copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CacheProxyFactoryBean

      public CacheProxyFactoryBean()
  • Method Details

    • setCacheOperationSources

      public void setCacheOperationSources(CacheOperationSource... cacheOperationSources)
      Set one or more sources to find cache operations.
      See Also:
    • setKeyGenerator

      public void setKeyGenerator(KeyGenerator keyGenerator)
      Set the default KeyGenerator that this cache aspect should delegate to if no specific key generator has been set for the operation.

      The default is a SimpleKeyGenerator.

      Since:
      5.0.3
      See Also:
    • setCacheResolver

      public void setCacheResolver(CacheResolver cacheResolver)
      Set the default CacheResolver that this cache aspect should delegate to if no specific cache resolver has been set for the operation.

      The default resolver resolves the caches against their names and the default cache manager.

      Since:
      5.0.3
      See Also:
    • setCacheManager

      public void setCacheManager(CacheManager cacheManager)
      Set the CacheManager to use to create a default CacheResolver. Replace the current CacheResolver, if any.
      Since:
      5.0.3
      See Also:
    • setPointcut

      public void setPointcut(org.springframework.aop.Pointcut pointcut)
      Set a pointcut, i.e. a bean that triggers conditional invocation of the CacheInterceptor depending on the method and attributes passed.

      Note: Additional interceptors are always invoked.

      See Also:
      • AbstractSingletonProxyFactoryBean.setPreInterceptors(Object[])
      • AbstractSingletonProxyFactoryBean.setPostInterceptors(Object[])
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
    • afterSingletonsInstantiated

      public void afterSingletonsInstantiated()
      Specified by:
      afterSingletonsInstantiated in interface org.springframework.beans.factory.SmartInitializingSingleton
    • createMainInterceptor

      protected Object createMainInterceptor()
      Specified by:
      createMainInterceptor in class org.springframework.aop.framework.AbstractSingletonProxyFactoryBean