org.ehcache
Interface CacheManager

All Known Subinterfaces:
PersistentCacheManager
All Known Implementing Classes:
EhcacheManager

public interface CacheManager

A CacheManager that manages Cache as well as associated Service


Method Summary
 void close()
          Releases all data held in Cache instances managed by this CacheManager, as well as all Service this instance provides to managed Cache instances.
<K,V> Cache<K,V>
createCache(java.lang.String alias, CacheConfiguration<K,V> config)
          Creates a Cache in this CacheManager according to the specified CacheConfiguration.
<K,V> Cache<K,V>
getCache(java.lang.String alias, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
          Retrieves the Cache associated with the given alias, if one is known.
 RuntimeConfiguration getRuntimeConfiguration()
          Returns the current RuntimeConfiguration used by this CacheManager
 Status getStatus()
          Returns the current Status for this CacheManager
 void init()
          Attempts at having this CacheManager go to Status.AVAILABLE, starting all Service instances managed by this CacheManager, as well as all Cache pre registered with it.
 void removeCache(java.lang.String alias)
          Removes the Cache associated with the alias provided, if oe is known.
 

Method Detail

createCache

<K,V> Cache<K,V> createCache(java.lang.String alias,
                             CacheConfiguration<K,V> config)
Creates a Cache in this CacheManager according to the specified CacheConfiguration.

Type Parameters:
K - the type of the keys used to access data within this cache
V - the type of the values held within this cache
Parameters:
alias - the alias under which the cache will be created
config - the configuration of the cache to create
Returns:
the created and initialized Cache
Throws:
java.lang.IllegalArgumentException - If there is already a cache registered with the given alias.
java.lang.IllegalStateException - If the cache creation fails

getCache

<K,V> Cache<K,V> getCache(java.lang.String alias,
                          java.lang.Class<K> keyType,
                          java.lang.Class<V> valueType)
Retrieves the Cache associated with the given alias, if one is known.

Type Parameters:
K - the type of the keys used to access data within this cache
V - the type of the values held within this cache
Parameters:
alias - the alias under which to look the Cache up
keyType - the Cache key class
valueType - the Cache value class
Returns:
the Cache associated with the given alias, null if no association exists
Throws:
java.lang.IllegalArgumentException - If the keyType or valueType do not match the ones with which the Cache was created

removeCache

void removeCache(java.lang.String alias)
Removes the Cache associated with the alias provided, if oe is known.

When the cache is removed, it will release all resources it used.

Parameters:
alias - the alias for which to remove the Cache

init

void init()
Attempts at having this CacheManager go to Status.AVAILABLE, starting all Service instances managed by this CacheManager, as well as all Cache pre registered with it.

Should this throw, while the CacheManager isn't yet Status.AVAILABLE, it will go back to Status.UNINITIALIZED properly (i.e. closing all services it already started, but which in turn may fail too).

Throws:
java.lang.IllegalStateException - if the CacheManager isn't in Status.UNINITIALIZED state
StateTransitionException - if the CacheManager couldn't be made Status.AVAILABLE
java.lang.RuntimeException - if any exception is thrown, but still results in the CacheManager transitioning to Status.AVAILABLE

close

void close()
Releases all data held in Cache instances managed by this CacheManager, as well as all Service this instance provides to managed Cache instances.

Should this throw, while the CacheManager isn't yet Status.UNINITIALIZED, it will keep on trying to go to Status.UNINITIALIZED properly (i.e. closing all other services it didn't yet stop).

Throws:
StateTransitionException - if the CacheManager couldn't be cleanly made Status.UNINITIALIZED, wrapping the first exception encountered
java.lang.RuntimeException - if any exception is thrown, like from Listeners

getStatus

Status getStatus()
Returns the current Status for this CacheManager

Returns:
the current Status

getRuntimeConfiguration

RuntimeConfiguration getRuntimeConfiguration()
Returns the current RuntimeConfiguration used by this CacheManager

Returns:
the configuration instance backing this CacheManager up