public abstract class AbstractCacheManager extends Object implements CacheManager, InitializingBean
CacheManager
methods.
Useful for 'static' environments where the backing caches do not change.Constructor and Description |
---|
AbstractCacheManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
addCache(Cache cache) |
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
protected Cache |
decorateCache(Cache cache)
Decorate the given Cache object if necessary.
|
Cache |
getCache(String name)
Return the cache associated with the given name.
|
Collection<String> |
getCacheNames()
Return a collection of the cache names known by this manager.
|
protected Cache |
getMissingCache(String name)
Return a missing cache with the specified
name or null if
such cache does not exist or could not be created on the fly. |
protected abstract Collection<? extends Cache> |
loadCaches()
Load the initial caches for this cache manager.
|
protected Cache |
lookupCache(String name)
Check for a registered cache of the given name.
|
public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
protected abstract Collection<? extends Cache> loadCaches()
Called by afterPropertiesSet()
on startup.
The returned collection may be empty but must not be null
.
public Cache getCache(String name)
CacheManager
getCache
in interface CacheManager
name
- the cache identifier (must not be null
)null
if none foundpublic Collection<String> getCacheNames()
CacheManager
getCacheNames
in interface CacheManager
protected final void addCache(Cache cache)
protected final Cache lookupCache(String name)
getCache(String)
, this method does not trigger
the lazy creation of missing caches via getMissingCache(String)
.name
- the cache identifier (must not be null
)null
if none foundgetCache(String)
,
getMissingCache(String)
protected Cache decorateCache(Cache cache)
cache
- the Cache object to be added to this CacheManagerprotected Cache getMissingCache(String name)
name
or null
if
such cache does not exist or could not be created on the fly.
Some caches may be created at runtime in the native provided. If a lookup by name does not yield any result, a subclass gets a chance to register such a cache at runtime. The returned cache will be automatically added to this instance.
name
- the name of the cache to retrievenull
if no such cache exists or could be
createdgetCache(String)