Package net.sf.ehcache.loader
Interface CacheLoader
-
public interface CacheLoaderExtends 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CacheLoaderclone(Ehcache cache)Creates a clone of this extension.voiddispose()CacheLoader instances may be doing all sorts of exotic things and need to be able to clean up on dispose.java.lang.StringgetName()Gets the name of a CacheLoaderStatusgetStatus()voidinit()Notifies providers to initialise themselves.java.lang.Objectload(java.lang.Object key)loads an object.java.lang.Objectload(java.lang.Object key, java.lang.Object argument)Load using both a key and an argument.java.util.MaploadAll(java.util.Collection keys)loads multiple object.java.util.MaploadAll(java.util.Collection keys, java.lang.Object argument)Load using both a key and an argument.
-
-
-
Method Detail
-
load
java.lang.Object load(java.lang.Object key) throws CacheExceptionloads 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
java.util.Map loadAll(java.util.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
java.lang.Object load(java.lang.Object key, java.lang.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 forargument- can be anything that makes sense to the loader- Returns:
- the Object loaded
- Throws:
CacheException
-
loadAll
java.util.Map loadAll(java.util.Collection keys, java.lang.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 forargument- 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
java.lang.String getName()
Gets the name of a CacheLoader- Returns:
- the name of this CacheLoader
-
clone
CacheLoader clone(Ehcache cache) throws java.lang.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:
java.lang.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 CacheExceptionCacheLoader instances may be doing all sorts of exotic things and need to be able to clean up on dispose. This method will be invoked whenCache.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
-
-