Top Description Fields Constructors Methods
org.springframework.cache.interceptor

public Class CacheProxyFactoryBean

extends AbstractSingletonProxyFactoryBean
implements BeanFactoryAware, SmartInitializingSingleton
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.Aware
Annotations
@SuppressWarnings:serial
Imports
org.springframework.aop.Pointcut, org.springframework.aop.framework.AbstractSingletonProxyFactoryBean, org.springframework.aop.support.DefaultPointcutAdvisor, org.springframework.beans.factory.BeanFactory, .BeanFactoryAware, .SmartInitializingSingleton, org.springframework.cache.CacheManager

Proxy factory bean for simplified declarative caching handling. This is a convenient alternative to a standard AOP org.springframework.aop.framework.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.

Authors
Costin Leau, Juergen Hoeller
Since
3.1
See Also
org.springframework.aop.framework.ProxyFactoryBean, CacheInterceptor

Field Summary

Modifier and TypeField and Description
private final CacheInterceptor
private Pointcut

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterSingletonsInstantiated()

Implements org.springframework.beans.factory.SmartInitializingSingleton.afterSingletonsInstantiated.

Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.
protected Object
createMainInterceptor()

Implements abstract org.springframework.aop.framework.AbstractSingletonProxyFactoryBean.createMainInterceptor.

Create the "main" interceptor for this proxy factory bean.
public void
setBeanFactory(BeanFactory
owning BeanFactory (never null). The bean can immediately call methods on the factory.
beanFactory
)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Callback that supplies the owning factory to a bean instance.
public void
setCacheManager(CacheManager cacheManager)

Set the CacheManager to use to create a default CacheResolver.

public void
setCacheOperationSources(CacheOperationSource... cacheOperationSources)

Set one or more sources to find cache operations.

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.

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.

public void
setPointcut(Pointcut pointcut)

Set a pointcut, i.e. a bean that triggers conditional invocation of the CacheInterceptor depending on the method and attributes passed.

Inherited from org.springframework.aop.framework.AbstractSingletonProxyFactoryBean:
afterPropertiesSetcreateTargetSourcegetObjectgetObjectTypeisSingletonpostProcessProxyFactorysetAdvisorAdapterRegistrysetBeanClassLoadersetPostInterceptorssetPreInterceptorssetProxyClassLoadersetProxyInterfacessetTarget

Field Detail

cacheInterceptorback to summary
private final CacheInterceptor cacheInterceptor
pointcutback to summary
private Pointcut pointcut

Constructor Detail

CacheProxyFactoryBeanback to summary
public CacheProxyFactoryBean()

Method Detail

afterSingletonsInstantiatedback to summary
public void afterSingletonsInstantiated()

Implements org.springframework.beans.factory.SmartInitializingSingleton.afterSingletonsInstantiated.

Doc from org.springframework.beans.factory.SmartInitializingSingleton.afterSingletonsInstantiated.

Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already. ListableBeanFactory#getBeansOfType calls within this method won't trigger accidental side effects during bootstrap.

Note

This callback won't be triggered for singleton beans lazily initialized on demand after BeanFactory bootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.

Annotations
@Override
createMainInterceptorback to summary
protected Object createMainInterceptor()

Implements abstract org.springframework.aop.framework.AbstractSingletonProxyFactoryBean.createMainInterceptor.

Doc from org.springframework.aop.framework.AbstractSingletonProxyFactoryBean.createMainInterceptor.

Create the "main" interceptor for this proxy factory bean. Typically an Advisor, but can also be any type of Advice.

Pre-interceptors will be applied before, post-interceptors will be applied after this interceptor.

Annotations
@Override
setBeanFactoryback to summary
public void setBeanFactory(BeanFactory beanFactory)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Doc from org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Callback that supplies the owning factory to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean#afterPropertiesSet() or a custom init-method.

Parameters
beanFactory:BeanFactory

owning BeanFactory (never null). The bean can immediately call methods on the factory.

Annotations
@Override
setCacheManagerback to summary
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
CacheInterceptor#setCacheManager
setCacheOperationSourcesback to summary
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources)

Set one or more sources to find cache operations.

See Also
CacheInterceptor#setCacheOperationSources
setCacheResolverback to summary
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
CacheInterceptor#setCacheResolver
setKeyGeneratorback to summary
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
CacheInterceptor#setKeyGenerator
setPointcutback to summary
public void setPointcut(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
setPreInterceptors, setPostInterceptors