Class CacheProxyFactoryBean
- All Implemented Interfaces:
Serializable, Aware, BeanClassLoaderAware, BeanFactoryAware, FactoryBean<Object>, InitializingBean, 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.
- Since:
- 3.1
- Author:
- Costin Leau, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.protected ObjectCreate the "main" interceptor for this proxy factory bean.voidsetBeanFactory(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.voidsetCacheManager(CacheManager cacheManager) Set theCacheManagerto use to create a defaultCacheResolver.voidsetCacheOperationSources(CacheOperationSource... cacheOperationSources) Set one or more sources to find cache operations.voidsetCacheResolver(CacheResolver cacheResolver) Set the defaultCacheResolverthat this cache aspect should delegate to if no specific cache resolver has been set for the operation.voidsetKeyGenerator(KeyGenerator keyGenerator) Set the defaultKeyGeneratorthat this cache aspect should delegate to if no specific key generator has been set for the operation.voidsetPointcut(Pointcut pointcut) Set a pointcut, i.e.Methods inherited from class AbstractSingletonProxyFactoryBean
afterPropertiesSet, createTargetSource, getObject, getObjectType, isSingleton, postProcessProxyFactory, setAdvisorAdapterRegistry, setBeanClassLoader, setPostInterceptors, setPreInterceptors, setProxyClassLoader, setProxyInterfaces, setTargetMethods inherited from class ProxyConfig
copyDefault, copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString
-
Constructor Details
-
CacheProxyFactoryBean
public CacheProxyFactoryBean()
-
-
Method Details
-
setCacheOperationSources
Set one or more sources to find cache operations.- See Also:
-
setKeyGenerator
Set the defaultKeyGeneratorthat 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
Set the defaultCacheResolverthat 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
Set theCacheManagerto use to create a defaultCacheResolver. Replace the currentCacheResolver, if any.- Since:
- 5.0.3
- See Also:
-
setPointcut
Set a pointcut, i.e. a bean that triggers conditional invocation of theCacheInterceptordepending on the method and attributes passed.Note: Additional interceptors are always invoked.
- See Also:
-
setBeanFactory
Description copied from interface:BeanFactoryAwareCallback 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:
setBeanFactoryin interfaceBeanFactoryAware- Parameters:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- See Also:
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()Description copied from interface:SmartInitializingSingletonInvoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.ListableBeanFactory.getBeansOfType(Class)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
BeanFactorybootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.- Specified by:
afterSingletonsInstantiatedin interfaceSmartInitializingSingleton
-
createMainInterceptor
Description copied from class:AbstractSingletonProxyFactoryBeanCreate 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:
createMainInterceptorin classAbstractSingletonProxyFactoryBean
-