spring-framework / org.springframework.cache.interceptor / CacheAspectSupport

CacheAspectSupport

abstract class CacheAspectSupport : AbstractCacheInvoker, BeanFactoryAware, InitializingBean, SmartInitializingSingleton

Base class for caching aspects, such as the CacheInterceptor or an AspectJ aspect.

This enables the underlying Spring caching infrastructure to be used easily to implement an aspect for any aspect system.

Subclasses are responsible for calling methods in this class in the correct order.

Uses the Strategy design pattern. A CacheResolver implementation will resolve the actual cache(s) to use, and a CacheOperationSource is used for determining caching operations.

A cache aspect is serializable if its CacheResolver and CacheOperationSource are serializable.

Author
Costin Leau

Author
Juergen Hoeller

Author
Chris Beams

Author
Phillip Webb

Author
Sam Brannen

Author
Stephane Nicoll

Since
3.1

Constructors

<init>

CacheAspectSupport()

Base class for caching aspects, such as the CacheInterceptor or an AspectJ aspect.

This enables the underlying Spring caching infrastructure to be used easily to implement an aspect for any aspect system.

Subclasses are responsible for calling methods in this class in the correct order.

Uses the Strategy design pattern. A CacheResolver implementation will resolve the actual cache(s) to use, and a CacheOperationSource is used for determining caching operations.

A cache aspect is serializable if its CacheResolver and CacheOperationSource are serializable.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

afterSingletonsInstantiated

open fun afterSingletonsInstantiated(): Unit

getCacheOperationSource

open fun getCacheOperationSource(): CacheOperationSource

Return the CacheOperationSource for this cache aspect.

getCacheResolver

open fun getCacheResolver(): CacheResolver

Return the default CacheResolver that this cache aspect delegates to.

getKeyGenerator

open fun getKeyGenerator(): KeyGenerator

Return the default KeyGenerator that this cache aspect delegates to.

setBeanFactory

open fun setBeanFactory(beanFactory: BeanFactory): Unit

Set the containing BeanFactory for CacheManager and other service lookups.

setCacheManager

open fun setCacheManager(cacheManager: CacheManager): Unit

Set the CacheManager to use to create a default CacheResolver. Replace the current CacheResolver, if any.

setCacheOperationSources

open fun setCacheOperationSources(vararg cacheOperationSources: CacheOperationSource): Unit

Set one or more cache operation sources which are used to find the cache attributes. If more than one source is provided, they will be aggregated using a CompositeCacheOperationSource.

setCacheResolver

open fun setCacheResolver(cacheResolver: CacheResolver): Unit

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.

setKeyGenerator

open fun setKeyGenerator(keyGenerator: KeyGenerator): Unit

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