org.springframework.cache.support
Class AbstractCacheManager

java.lang.Object
  extended by org.springframework.cache.support.AbstractCacheManager
All Implemented Interfaces:
InitializingBean, CacheManager
Direct Known Subclasses:
EhCacheCacheManager, MapCacheManager, SimpleCacheManager

public abstract class AbstractCacheManager
extends Object
implements CacheManager, InitializingBean

Abstract base class implementing the common CacheManager methods. Useful for 'static' environments where the backing caches do not change.

Author:
Costin Leau

Constructor Summary
AbstractCacheManager()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
<K,V> Cache<K,V>
getCache(String name)
          Returns the cache associated with the given name.
protected  ConcurrentMap<String,Cache<?,?>> getCacheMap()
          Returns the internal cache map.
 Collection<String> getCacheNames()
          Returns a collection of the caches known by this cache manager.
protected abstract  Collection<Cache<?,?>> loadCaches()
          Loads the caches into the cache manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCacheManager

public AbstractCacheManager()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

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.

Specified by:
afterPropertiesSet in interface InitializingBean

loadCaches

protected abstract Collection<Cache<?,?>> loadCaches()
Loads the caches into the cache manager. Occurs at startup. The returned collection should not be null.

Parameters:
caches - the collection of caches handled by the manager

getCacheMap

protected final ConcurrentMap<String,Cache<?,?>> getCacheMap()
Returns the internal cache map.

Returns:
internal cache map

getCache

public <K,V> Cache<K,V> getCache(String name)
Description copied from interface: CacheManager
Returns the cache associated with the given name.

Specified by:
getCache in interface CacheManager
Parameters:
name - cache identifier - cannot be null
Returns:
associated cache or null if none is found

getCacheNames

public Collection<String> getCacheNames()
Description copied from interface: CacheManager
Returns a collection of the caches known by this cache manager.

Specified by:
getCacheNames in interface CacheManager
Returns:
names of caches known by the cache manager.