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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      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.
      java.lang.String getName()
      Gets the name of a CacheLoader
      Status getStatus()  
      void init()
      Notifies providers to initialise themselves.
      java.lang.Object load​(java.lang.Object key)
      loads an object.
      java.lang.Object load​(java.lang.Object key, java.lang.Object argument)
      Load using both a key and an argument.
      java.util.Map loadAll​(java.util.Collection keys)
      loads multiple object.
      java.util.Map loadAll​(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 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

        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 for
        argument - 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 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

        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.
      • 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