Top Description Fields Constructors Methods
net.sf.ehcache.management

public Class Cache

extends Object
implements CacheMBean, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, net.sf.ehcache.management.CacheMBean
Imports
javax.management.NotCompliantMBeanException, .MalformedObjectNameException, .ObjectName, net.sf.ehcache.CacheException, .Ehcache, net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMbeanNames, net.sf.ehcache.util.CacheTransactionHelper, java.io.Serializable

A Cache implementation that supports JMX MBeans
Author
Greg Luck
Since
1.3
Version
$Id: Cache.java 10789 2018-04-26 02:08:13Z adahanne $

Field Summary

Modifier and TypeField and Description
private transient Ehcache
cache

An Ehcache backing instance

private ObjectName
private static final long

Constructor Summary

AccessConstructor and Description
public
Cache(Ehcache
An ehcache
cache
)

A constructor for JCache.

Method Summary

Modifier and TypeMethod and Description
pack-priv static ObjectName
createObjectName(String cacheManagerName, String cacheName)

Creates an object name using the scheme "net.sf.ehcache:type=Cache,CacheManager=<cachemanagername>,name=<cachename>"

public void
flush()

Implements net.sf.ehcache.management.CacheMBean.flush.

Flushes all cache items from memory to the disk store, and from the DiskStore to disk.
public CacheConfiguration
getCacheConfiguration()

Implements net.sf.ehcache.management.CacheMBean.getCacheConfiguration.

Gets the JMX read-only CacheConfiguration
public String
getName()

Implements net.sf.ehcache.management.CacheMBean.getName.

Gets the cache name.
pack-priv ObjectName

Returns:

the object name for this MBean
getObjectName
()

public CacheStatistics
getStatistics()

Implements net.sf.ehcache.management.CacheMBean.getStatistics.

Gets the JMX cache statistics
public String

Returns:

The status value as a String from the Status enum class
getStatus
()

Implements net.sf.ehcache.management.CacheMBean.getStatus.

Gets the status attribute of the Cache.
pack-priv Store
getStore()

Gets the JMX store bean

public boolean
hasAbortedSizeOf()

Implements net.sf.ehcache.management.CacheMBean.hasAbortedSizeOf.

May the cache contain elements which the SizeOf engine could not fully size?
public boolean
isTerracottaClustered()

Implements net.sf.ehcache.management.CacheMBean.isTerracottaClustered.

Is the cache configured with Terracotta clustering?
public void
removeAll()

Implements net.sf.ehcache.management.CacheMBean.removeAll.

Removes all cached items.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private transient Ehcache cache

An Ehcache backing instance

objectNameback to summary
private ObjectName objectName
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Cacheback to summary
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 net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the Ehcache object into net.sf.ehcache.CacheManager#addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.

Parameters
cache:Ehcache

An ehcache

Method Detail

createObjectNameback to summary
pack-priv static ObjectName createObjectName(String cacheManagerName, String cacheName)

Creates an object name using the scheme "net.sf.ehcache:type=Cache,CacheManager=,name="

flushback to summary
public void flush() throws IllegalStateException, CacheException

Implements net.sf.ehcache.management.CacheMBean.flush.

Flushes all cache items from memory to the disk store, and from the DiskStore to disk.

Exceptions
IllegalStateException:
if the cache is not net.sf.ehcache.Status#STATUS_ALIVE
getCacheConfigurationback to summary
public CacheConfiguration getCacheConfiguration()

Implements net.sf.ehcache.management.CacheMBean.getCacheConfiguration.

Gets the JMX read-only CacheConfiguration

getNameback to summary
public String getName()

Implements net.sf.ehcache.management.CacheMBean.getName.

Gets the cache name.

getObjectNameback to summary
pack-priv ObjectName getObjectName()
Returns:ObjectName

the object name for this MBean

getStatisticsback to summary
public CacheStatistics getStatistics()

Implements net.sf.ehcache.management.CacheMBean.getStatistics.

Gets the JMX cache statistics

getStatusback to summary
public String getStatus()

Implements net.sf.ehcache.management.CacheMBean.getStatus.

Gets the status attribute of the Cache.

Returns:String

The status value as a String from the Status enum class

getStoreback to summary
pack-priv Store getStore() throws NotCompliantMBeanException

Gets the JMX store bean

hasAbortedSizeOfback to summary
public boolean hasAbortedSizeOf()

Implements net.sf.ehcache.management.CacheMBean.hasAbortedSizeOf.

May the cache contain elements which the SizeOf engine could not fully size?

isTerracottaClusteredback to summary
public boolean isTerracottaClustered()

Implements net.sf.ehcache.management.CacheMBean.isTerracottaClustered.

Is the cache configured with Terracotta clustering?

removeAllback to summary
public void removeAll() throws IllegalStateException, CacheException

Implements net.sf.ehcache.management.CacheMBean.removeAll.

Removes all cached items.

Exceptions
IllegalStateException:
if the cache is not net.sf.ehcache.Status#STATUS_ALIVE