Class CacheProxyFactoryBean
- java.lang.Object
- org.springframework.aop.framework.ProxyConfig
- org.springframework.aop.framework.AbstractSingletonProxyFactoryBean
- org.springframework.cache.interceptor.CacheProxyFactoryBean
- All Implemented Interfaces:
Serializable
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,FactoryBean<Object>
,InitializingBean
,SmartInitializingSingleton
public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware, SmartInitializingSingleton
Proxy factory bean for simplified declarative caching handling. This is a convenient alternative to a standard AOPProxyFactoryBean
with a separateCacheInterceptor
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:
ProxyFactoryBean
,CacheInterceptor
, Serialized Form
Constructor Summary
Constructors Constructor Description CacheProxyFactoryBean()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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()
Create the "main" interceptor for this proxy factory bean.void
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.void
setCacheOperationSources(CacheOperationSource... cacheOperationSources)
Set one or more sources to find cache operations.void
setPointcut(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
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString
Constructor Detail
CacheProxyFactoryBean
public CacheProxyFactoryBean()
Method Detail
setCacheOperationSources
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources)
Set one or more sources to find cache operations.
setPointcut
public void setPointcut(Pointcut pointcut)
Set a pointcut, i.e. a bean that triggers conditional invocation of theCacheInterceptor
depending on the method and attributes passed.Note: Additional interceptors are always invoked.
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
Description copied from interface:BeanFactoryAware
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.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
BeanInitializationException
afterSingletonsInstantiated
public void afterSingletonsInstantiated()
Description copied from interface:SmartInitializingSingleton
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(java.lang.Class<T>)
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.- Specified by:
afterSingletonsInstantiated
in interfaceSmartInitializingSingleton
createMainInterceptor
protected Object createMainInterceptor()
Description copied from class:AbstractSingletonProxyFactoryBean
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.
- Specified by:
createMainInterceptor
in classAbstractSingletonProxyFactoryBean