org.ehcache
Class EhcacheManager

java.lang.Object
  extended by org.ehcache.EhcacheManager
All Implemented Interfaces:
CacheManager, PersistentCacheManager

public class EhcacheManager
extends java.lang.Object
implements PersistentCacheManager


Constructor Summary
EhcacheManager(Configuration config)
           
EhcacheManager(Configuration config, java.util.Collection<Service> services)
           
EhcacheManager(Configuration config, java.util.Collection<Service> services, boolean useLoaderInAtomics)
           
 
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.
 void deregisterListener(CacheManagerListener listener)
           
 void destroyCache(java.lang.String alias)
          Destroys all data persistent data associated with the aliased Cache instance managed by this CacheManager
<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 registerListener(CacheManagerListener listener)
           
 void removeCache(java.lang.String alias)
          Removes the Cache associated with the alias provided, if oe is known.
 Maintainable toMaintenance()
          Lets you manipulate the persistent data structures for this PersistentCacheManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhcacheManager

public EhcacheManager(Configuration config)

EhcacheManager

public EhcacheManager(Configuration config,
                      java.util.Collection<Service> services)

EhcacheManager

public EhcacheManager(Configuration config,
                      java.util.Collection<Service> services,
                      boolean useLoaderInAtomics)
Method Detail

getCache

public <K,V> Cache<K,V> getCache(java.lang.String alias,
                                 java.lang.Class<K> keyType,
                                 java.lang.Class<V> valueType)
Description copied from interface: CacheManager
Retrieves the Cache associated with the given alias, if one is known.

Specified by:
getCache in interface CacheManager
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

removeCache

public void removeCache(java.lang.String alias)
Description copied from interface: CacheManager
Removes the Cache associated with the alias provided, if oe is known.

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

Specified by:
removeCache in interface CacheManager
Parameters:
alias - the alias for which to remove the Cache

createCache

public <K,V> Cache<K,V> createCache(java.lang.String alias,
                                    CacheConfiguration<K,V> config)
                       throws java.lang.IllegalArgumentException
Description copied from interface: CacheManager
Creates a Cache in this CacheManager according to the specified CacheConfiguration.

Specified by:
createCache in interface CacheManager
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.

registerListener

public void registerListener(CacheManagerListener listener)

deregisterListener

public void deregisterListener(CacheManagerListener listener)

init

public 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).

Specified by:
init in interface CacheManager

getStatus

public Status getStatus()
Description copied from interface: CacheManager
Returns the current Status for this CacheManager

Specified by:
getStatus in interface CacheManager
Returns:
the current Status

close

public void close()
Description copied from interface: CacheManager
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).

Specified by:
close in interface CacheManager

getRuntimeConfiguration

public RuntimeConfiguration getRuntimeConfiguration()
Description copied from interface: CacheManager
Returns the current RuntimeConfiguration used by this CacheManager

Specified by:
getRuntimeConfiguration in interface CacheManager
Returns:
the configuration instance backing this CacheManager up

toMaintenance

public Maintainable toMaintenance()
Description copied from interface: PersistentCacheManager
Lets you manipulate the persistent data structures for this PersistentCacheManager

Specified by:
toMaintenance in interface PersistentCacheManager
Returns:
a Maintainable for this PersistentCacheManager

destroyCache

public void destroyCache(java.lang.String alias)
                  throws CachePersistenceException
Description copied from interface: PersistentCacheManager
Destroys all data persistent data associated with the aliased Cache instance managed by this CacheManager

Specified by:
destroyCache in interface PersistentCacheManager
Parameters:
alias - the Cache's alias to destroy all persistent data from
Throws:
CachePersistenceException - When something goes wrong destroying the persistent data