Top Description Methods
net.sf.ehcache.loader

public Interface CacheLoader

Imports
net.sf.ehcache.CacheException, .Ehcache, .Status, java.util.Collection, .Map

Extends JCache CacheLoader with load methods that take an argument in addition to a key This interface has exactly the same interface as in the JCache module.
Author
Greg Luck
Version
$Id$

Method Summary

Modifier and TypeMethod and Description
public CacheLoader

Returns:

a clone
clone
(Ehcache cache)

Creates a clone of this extension.

public void
dispose()

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

public String

Returns:

the name of this CacheLoader
getName
()

Gets the name of a CacheLoader

public Status

Returns:

the status of the extension
getStatus
()

public void
init()

Notifies providers to initialise themselves.

public Object

Returns:

The object that is to be stored in the cache.
load
(Object
the key identifying the object being loaded
key
)

loads an object.

public Object

Returns:

the Object loaded
load
(Object
the key to load the object for
key
,
Object
can be anything that makes sense to the loader
argument
)

Load using both a key and an argument.

public Map<K, V>

Returns:

A Map of objects that are to be stored in the cache.
loadAll
(Collection<E>
a Collection of keys identifying the objects to be loaded
keys
)

loads multiple object.

public Map<K, V>

Returns:

a map of Objects keyed by the collection of keys passed in.
loadAll
(Collection<E>
the keys to load objects for
keys
,
Object
can be anything that makes sense to the loader
argument
)

Load using both a key and an argument.

Method Detail

cloneback to summary
public CacheLoader 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.

Returns:CacheLoader

a clone

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

CacheLoader instances may be doing all sorts of exotic things and need to be able to clean up on dispose. This method will be invoked when Cache.dispose() is invoked if this CacheLoader is registered with the cache at disposal time, allowing for any necessary cleanup.

No operations may be performed on the cache this CacheLoader is registered with. The cache itself is partly disposed when this method is called, and should not be accessed.

getNameback to summary
public String getName()

Gets the name of a CacheLoader

Returns:String

the name of this CacheLoader

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.

See Also
net.sf.ehcache.Ehcache#registerCacheLoader(net.sf.ehcache.loader.CacheLoader)
loadback to summary
public Object load(Object key) throws CacheException

loads an object. Application writers should implement this method to customize the loading of cache object. This method is called by the caching service when the requested object is not in the cache.

Parameters
key:Object

the key identifying the object being loaded

Returns:Object

The object that is to be stored in the cache.

loadback to summary
public Object load(Object key, Object argument)

Load using both a key and an argument.

JCache will call through to the load(key) method, rather than this method, where the argument is null.

Parameters
key:Object

the key to load the object for

argument:Object

can be anything that makes sense to the loader

Returns:Object

the Object loaded

loadAllback to summary
public Map<K, V> loadAll(Collection<E> keys)

loads multiple object. Application writers should implement this method to customize the loading of cache object. This method is called by the caching service when the requested object is not in the cache.

Parameters
keys:Collection<E>

a Collection of keys identifying the objects to be loaded

Returns:Map<K, V>

A Map of objects that are to be stored in the cache.

loadAllback to summary
public Map<K, V> loadAll(Collection<E> keys, Object argument)

Load using both a key and an argument.

JCache will use the loadAll(key) method where the argument is null.

Parameters
keys:Collection<E>

the keys to load objects for

argument:Object

can be anything that makes sense to the loader

Returns:Map<K, V>

a map of Objects keyed by the collection of keys passed in.