ehcache

net.sf.ehcache.management
Class Cache

java.lang.Object
  extended by net.sf.ehcache.management.Cache
All Implemented Interfaces:
CacheMBean

public class Cache
extends java.lang.Object
implements CacheMBean

A JMX MBean implementation for Cache

Since:
1.3
Version:
$Id: Cache.java 524 2007-07-30 11:24:40Z gregluck $
Author:
Greg Luck

Constructor Summary
Cache(Ehcache cache)
          A constructor for JCache.
 
Method Summary
(package private) static javax.management.ObjectName createObjectName(java.lang.String cacheManagerName, java.lang.String cacheName)
          Creates an object name using the scheme "net.sf.ehcache:type=Cache,CacheManager=,name="
 void flush()
          Flushes all cache items from memory to the disk store, and from the DiskStore to disk.
 CacheConfiguration getCacheConfiguration()
          Gets the JMX read-only CacheConfiguration
 java.lang.String getName()
          Gets the cache name.
(package private)  javax.management.ObjectName getObjectName()
           
 CacheStatistics getStatistics()
          Gets the JMX cache statistics
 java.lang.String getStatus()
          Gets the status attribute of the Cache.
 void removeAll()
          Removes all cached items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache(Ehcache cache)
      throws CacheException
A constructor for JCache. JCache is an adaptor for an Ehcache, and therefore requires an Ehcace in its constructor.

The ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the Ehcache object into CacheManager.addCache(java.lang.String) to specify parameters other than the defaults.

Only the CacheManager can initialise them.

Parameters:
cache - An ehcache
Throws:
CacheException
Method Detail

createObjectName

static javax.management.ObjectName createObjectName(java.lang.String cacheManagerName,
                                                    java.lang.String cacheName)
Creates an object name using the scheme "net.sf.ehcache:type=Cache,CacheManager=,name="


removeAll

public void removeAll()
               throws java.lang.IllegalStateException,
                      CacheException
Removes all cached items.

Specified by:
removeAll in interface CacheMBean
Throws:
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException

flush

public void flush()
           throws java.lang.IllegalStateException,
                  CacheException
Flushes all cache items from memory to the disk store, and from the DiskStore to disk.

Specified by:
flush in interface CacheMBean
Throws:
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException

getStatus

public java.lang.String getStatus()
Gets the status attribute of the Cache.

Specified by:
getStatus in interface CacheMBean
Returns:
The status value as a String from the Status enum class

getName

public java.lang.String getName()
Gets the cache name.

Specified by:
getName in interface CacheMBean

getCacheConfiguration

public CacheConfiguration getCacheConfiguration()
Gets the JMX read-only CacheConfiguration

Specified by:
getCacheConfiguration in interface CacheMBean

getStatistics

public CacheStatistics getStatistics()
Gets the JMX cache statistics

Specified by:
getStatistics in interface CacheMBean

getObjectName

javax.management.ObjectName getObjectName()
Returns:
the object name for this MBean

ehcache