Class AbstractCacheManager
java.lang.Object
org.springframework.cache.support.AbstractCacheManager
- All Implemented Interfaces:
InitializingBean
,CacheManager
- Direct Known Subclasses:
AbstractTransactionSupportingCacheManager
,SimpleCacheManager
Abstract base class implementing the common
CacheManager
methods.
Useful for 'static' environments where the backing caches do not change.- Since:
- 3.1
- Author:
- Costin Leau, Juergen Hoeller, Stephane Nicoll
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected Cache
decorateCache
(Cache cache) Decorate the given Cache object if necessary.Get the cache associated with the given name.Get a collection of the cache names known by this manager.protected Cache
getMissingCache
(String name) Return a missing cache with the specifiedname
, ornull
if such a cache does not exist or could not be created on demand.void
Initialize the static configuration of caches.protected abstract Collection<? extends Cache>
Load the initial caches for this cache manager.protected final Cache
lookupCache
(String name) Check for a registered cache of the given name.
-
Constructor Details
-
AbstractCacheManager
public AbstractCacheManager()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
initializeCaches
public void initializeCaches()Initialize the static configuration of caches.Triggered on startup through
afterPropertiesSet()
; can also be called to re-initialize at runtime.- Since:
- 4.2.2
- See Also:
-
loadCaches
Load the initial caches for this cache manager.Called by
afterPropertiesSet()
on startup. The returned collection may be empty but must not benull
. -
getCache
Description copied from interface:CacheManager
Get the cache associated with the given name.Note that the cache may be lazily created at runtime if the native provider supports it.
- Specified by:
getCache
in interfaceCacheManager
- Parameters:
name
- the cache identifier (must not benull
)- Returns:
- the associated cache, or
null
if such a cache does not exist or could be not created
-
getCacheNames
Description copied from interface:CacheManager
Get a collection of the cache names known by this manager.- Specified by:
getCacheNames
in interfaceCacheManager
- Returns:
- the names of all caches known by the cache manager
-
lookupCache
Check for a registered cache of the given name. In contrast togetCache(String)
, this method does not trigger the lazy creation of missing caches viagetMissingCache(String)
.- Parameters:
name
- the cache identifier (must not benull
)- Returns:
- the associated Cache instance, or
null
if none found - Since:
- 4.1
- See Also:
-
decorateCache
Decorate the given Cache object if necessary.- Parameters:
cache
- the Cache object to be added to this CacheManager- Returns:
- the decorated Cache object to be used instead, or simply the passed-in Cache object by default
-
getMissingCache
Return a missing cache with the specifiedname
, ornull
if such a cache does not exist or could not be created on demand.Caches may be lazily created at runtime if the native provider supports it. If a lookup by name does not yield any result, an
AbstractCacheManager
subclass gets a chance to register such a cache at runtime. The returned cache will be automatically added to this cache manager.- Parameters:
name
- the name of the cache to retrieve- Returns:
- the missing cache, or
null
if no such cache exists or could be created on demand - Since:
- 4.1
- See Also:
-