ehcache

net.sf.ehcache.loader
Interface CacheLoader


public interface CacheLoader

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.

Version:
$Id$
Author:
Greg Luck

Method Summary
 CacheLoader clone(Ehcache cache)
          Creates a clone of this extension.
 void dispose()
          CacheLoader instances may be doing all sorts of exotic things and need to be able to clean up on dispose.
 String getName()
          Gets the name of a CacheLoader
 Status getStatus()
           
 void init()
          Notifies providers to initialise themselves.
 Object load(Object key)
          loads an object.
 Object load(Object key, Object argument)
          Load using both a key and an argument.
 Map loadAll(Collection keys)
          loads multiple object.
 Map loadAll(Collection keys, Object argument)
          Load using both a key and an argument.
 

Method Detail

load

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 - the key identifying the object being loaded
Returns:
The object that is to be stored in the cache.
Throws:
CacheException

loadAll

Map loadAll(Collection 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 - a Collection of keys identifying the objects to be loaded
Returns:
A Map of objects that are to be stored in the cache.
Throws:
CacheException

load

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 - the key to load the object for
argument - can be anything that makes sense to the loader
Returns:
the Object loaded
Throws:
CacheException

loadAll

Map loadAll(Collection 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 - the keys to load objects for
argument - can be anything that makes sense to the loader
Returns:
a map of Objects keyed by the collection of keys passed in.
Throws:
CacheException

getName

String getName()
Gets the name of a CacheLoader

Returns:
the name of this CacheLoader

clone

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:
a clone
Throws:
CloneNotSupportedException - if the extension could not be cloned.

init

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.

Throws:
CacheException
See Also:
Ehcache.registerCacheLoader(net.sf.ehcache.loader.CacheLoader)

dispose

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.

Throws:
CacheException

getStatus

Status getStatus()
Returns:
the status of the extension

ehcache

Copyright 2001-2016, Terracotta, Inc.