public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware, SmartInitializingSingleton
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.
ProxyFactoryBean
,
CacheInterceptor
,
Serialized FormConstructor and Description |
---|
CacheProxyFactoryBean() |
Modifier and Type | Method and 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 java.lang.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.
|
afterPropertiesSet, createTargetSource, getObject, getObjectType, isSingleton, postProcessProxyFactory, setAdvisorAdapterRegistry, setBeanClassLoader, setPostInterceptors, setPreInterceptors, setProxyClassLoader, setProxyInterfaces, setTarget
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources)
public void setPointcut(Pointcut pointcut)
CacheInterceptor
depending on the method and attributes passed.
Note: Additional interceptors are always invoked.
public void setBeanFactory(BeanFactory beanFactory)
BeanFactoryAware
Invoked after the population of normal bean properties
but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (never null
).
The bean can immediately call methods on the factory.BeanInitializationException
public void afterSingletonsInstantiated()
SmartInitializingSingleton
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.
afterSingletonsInstantiated
in interface SmartInitializingSingleton
protected java.lang.Object createMainInterceptor()
AbstractSingletonProxyFactoryBean
Pre-interceptors will be applied before, post-interceptors will be applied after this interceptor.
createMainInterceptor
in class AbstractSingletonProxyFactoryBean