net.sf.ehcache
public final class CacheManager extends Object
Version: $Id: CacheManager.java 52 2006-04-24 14:50:03Z gregluck $
Constructor Summary | |
---|---|
CacheManager(Configuration configuration)
An constructor for CacheManager, which takes a configuration object, rather than one created by parsing
an ehcache.xml file. | |
CacheManager(String configurationFileName)
An ordinary constructor for CacheManager.
| |
CacheManager(URL configurationURL)
An ordinary constructor for CacheManager.
| |
CacheManager(InputStream configurationInputStream)
An ordinary constructor for CacheManager.
| |
CacheManager()
Constructor. |
Method Summary | |
---|---|
void | addCache(String cacheName)
Adds a Cache based on the defaultCache with the given name.
|
void | addCache(Cache cache)
Adds a Cache to the CacheManager.
|
boolean | cacheExists(String cacheName)
Checks whether a cache exists.
|
static CacheManager | create()
A factory method to create a singleton CacheManager with default config, or return it if it exists.
|
static CacheManager | create(String configurationFileName)
A factory method to create a singleton CacheManager with a specified configuration.
|
static CacheManager | create(URL configurationFileURL)
A factory method to create a singleton CacheManager from an URL.
|
static CacheManager | create(InputStream inputStream)
A factory method to create a singleton CacheManager from a java.io.InputStream.
|
Cache | getCache(String name)
Gets a Cache
|
CacheManagerEventListener | getCacheManagerEventListener()
Gets the CacheManager event listener.
|
String[] | getCacheNames()
Returns a list of the current cache names.
|
CacheManagerPeerListener | getCachePeerListener()
When CacheManage is configured as part of a cluster, a CacheManagerPeerListener will
be registered in it. |
CacheManagerPeerProvider | getCachePeerProvider()
Gets the CacheManagerPeerProvider
For distributed caches, the peer provider finds other cache managers and their caches in the same cluster
|
static CacheManager | getInstance()
A factory method to create a singleton CacheManager with default config, or return it if it exists.
|
Status | getStatus()
Gets the status attribute of the Cache
|
void | removalAll()
Removes all caches using CacheManager for each cache. |
void | removeCache(String cacheName)
Remove a cache from the CacheManager. |
void | setCacheManagerEventListener(CacheManagerEventListener cacheManagerEventListener)
Sets the CacheManager event listener. |
void | shutdown()
Shuts down the CacheManager.
|
Parameters: configuration
Throws: CacheException
Parameters: configurationFileName an xml configuration file available through a file name. The configuration
File is created
using new File(configurationFileName)
Throws: CacheException
See Also: create
URL url = this.getClass().getResource("/ehcache-2.xml");Note that Class#getResource will look for resources in the same package unless a leading "/" is used, in which case it will look in the root of the classpath. You can also load a resource using other class loaders. e.g. Thread#getContextClassLoader()
Parameters: configurationURL an xml configuration available through a URL.
Throws: CacheException
Since: 1.2
See Also: create
Parameters: configurationInputStream an xml configuration file available through an inputstream
Throws: CacheException
See Also: create
Throws: CacheException
Parameters: cacheName the name for the cache
Throws: ObjectExistsException if the cache already exists CacheException if there was an error creating the cache.
Parameters: cache
Throws: IllegalStateException if the cache is not STATUS_UNINITIALISED before this method is called. ObjectExistsException if the cache already exists in the CacheManager CacheException if there was an error adding the cache to the CacheManager
Parameters: cacheName the cache name to check for
Returns: true if it exists
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: the singleton CacheManager
Throws: CacheException if the CacheManager cannot be created
Parameters: configurationFileName an xml file compliant with the ehcache.xsd schema The configuration will be read, Caches created and required stores initialized. When the CacheManager is no longer required, call shutdown to free resources.
URL url = this.getClass().getResource("/ehcache-2.xml");Note that Class#getResource will look for resources in the same package unless a leading "/" is used, in which case it will look in the root of the classpath. You can also load a resource using other class loaders. e.g. Thread#getContextClassLoader()
Parameters: configurationFileURL an URL to an xml file compliant with the ehcache.xsd schema The configuration will be read, Caches created and required stores initialized. When the CacheManager is no longer required, call shutdown to free resources.
Parameters: inputStream InputStream of xml compliant with the ehcache.xsd schema The configuration will be read, Caches created and required stores initialized. When the CacheManager is no longer required, call shutdown to free resources.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: null if none
Returns: an array of Strings
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: the listener, or null if one does not exist
CacheManagerPeerProvider
For distributed caches, the peer provider finds other cache managers and their caches in the same cluster
Returns: the provider, or null if one does not exist
Returns: the singleton CacheManager
Throws: CacheException if the CacheManager cannot be created
Returns: The status value from the Status enum class
Parameters: cacheName the cache name
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Parameters: cacheManagerEventListener the listener to set.