org.springframework.cache.support
Class CompositeCacheManager

java.lang.Object
  extended by org.springframework.cache.support.CompositeCacheManager
All Implemented Interfaces:
InitializingBean, CacheManager

public class CompositeCacheManager
extends Object
implements InitializingBean, CacheManager

Composite CacheManager implementation that iterates over a given collection of CacheManager instances. Allows NoOpCacheManager to be automatically added to the list for handling the cache declarations without a backing store.

Since:
3.1
Author:
Costin Leau, Juergen Hoeller

Constructor Summary
CompositeCacheManager()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 Cache getCache(String name)
          Return the cache associated with the given name.
 Collection<String> getCacheNames()
          Return a collection of the caches known by this cache manager.
 void setCacheManagers(Collection<CacheManager> cacheManagers)
           
 void setFallbackToNoOpCache(boolean fallbackToNoOpCache)
          Indicate whether a NoOpCacheManager should be added at the end of the manager lists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeCacheManager

public CompositeCacheManager()
Method Detail

setCacheManagers

public void setCacheManagers(Collection<CacheManager> cacheManagers)

setFallbackToNoOpCache

public void setFallbackToNoOpCache(boolean fallbackToNoOpCache)
Indicate whether a NoOpCacheManager should be added at the end of the manager lists. In this case, any getCache requests not handled by the configured cache managers will be automatically handled by the NoOpCacheManager (and hence never return null).


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

getCache

public Cache getCache(String name)
Description copied from interface: CacheManager
Return the cache associated with the given name.

Specified by:
getCache in interface CacheManager
Parameters:
name - cache identifier (must not be null)
Returns:
associated cache, or null if none is found

getCacheNames

public Collection<String> getCacheNames()
Description copied from interface: CacheManager
Return 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.