Top Description Methods
net.sf.ehcache.extension

public Interface CacheExtension

Imports
net.sf.ehcache.CacheException, .Ehcache, .Status

This is a general purpose mechanism to allow generic extensions to a Cache.

CacheExtensions are tied into the Cache lifecycle. For that reason this interface has the lifecycle methods.

CacheExtensions are created using the CacheExtensionFactory which has a createCacheCacheExtension() method which takes as a parameter a Cache and properties. It can thus call back into any public method on Cache, including, of course, the load methods.

CacheExtensions are suitable for timing services, where you want to create a timer to perform cache operations. The other way of adding Cache behaviour is to decorate a cache. See net.sf.ehcache.constructs.blocking.BlockingCache for an example of how to do this.

Because a CacheExtension holds a reference to a Cache, the CacheExtension can do things such as registering a CacheEventListener or even a CacheManagerEventListener, all from within a CacheExtension, creating more opportunities for customisation.

Author
Greg Luck
Version
$Id: CacheExtension.java 10789 2018-04-26 02:08:13Z adahanne $

Method Summary

Modifier and TypeMethod and Description
public CacheExtension

Returns:

a clone
clone
(Ehcache
the cache extended
cache
)

Creates a clone of this extension.

public void
dispose()

Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.

public Status

Returns:

the status of the extension
getStatus
()

public void
init()

Notifies providers to initialise themselves.

Method Detail

cloneback to summary
public CacheExtension clone(Ehcache cache) throws CloneNotSupportedException

Creates a clone of this extension. This method will only be called by ehcache before a cache is initialized.

Implementations should throw CloneNotSupportedException if they do not support clone but that will stop them from being used with defaultCache.

Parameters
cache:Ehcache

the cache extended

Returns:CacheExtension

a clone

Exceptions
CloneNotSupportedException:
if the extension could not be cloned.
disposeback to summary
public void dispose() throws CacheException

Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.

Cache operations are illegal when this method is called. The cache itself is partly disposed when this method is called.

getStatusback to summary
public Status getStatus()
Returns:Status

the status of the extension

initback to summary
public void init()

Notifies providers to initialise themselves.

This method is called during the Cache's initialise method after it has changed it's status to alive. Cache operations are legal in this method.