javax.util.jcache
Class CacheLoader

java.lang.Object
  extended by javax.util.jcache.CacheLoader
All Implemented Interfaces:
Serializable

Deprecated. Will be removed and replaced with an interface.

public abstract class CacheLoader
extends Object
implements Serializable

This class loads object into the cache with the aid of the abstract load method. Should be extended by the user to implement custom loaders, such as Database queries, Directory searches, File extraction, Net searches etc.

Author:
Frank Karlstrøm
See Also:
Serialized Form

Constructor Summary
CacheLoader()
          Deprecated.  
 
Method Summary
 File createDiskObject(Object handle, Attributes attributes, String extension)
          Deprecated. is called from the load object to create a disk object.
 File createDiskObject(Object handle, String extension)
          Deprecated. is called from the load object to create a disk object.
 OutputStream createStream(Object handle)
          Deprecated. should be called from the load method to create a StreamAccess object.
 OutputStream createStream(Object handle, Attributes attributes)
          Deprecated. should be called from the load method to create a StreamAccess object.
 CacheException exceptionHandler(String msg, Exception exception)
          Deprecated. this method is called from the load method to convert any non CacheExceptions into CacheExceptions, with the base exception set to the original exception.
protected  Object getName(Object handle)
          Deprecated. returns the name associated with object being loaded.
protected  String getRegion(Object handle)
          Deprecated. return the name of the region for the object being loaded.
abstract  Object load(Object handle, Object arguments)
          Deprecated. this method must be implemented by the user to load objects into the cache.
 void log(String msg)
          Deprecated. is called from the load method to record a message in the cache's log.
protected  Object netSearch(Object handle, int timeout)
          Deprecated. will search other caches for the object to be loaded.
 void setAttributes(Object handle, Attributes attributes)
          Deprecated. will cause the attributes associated with the object being loaded to be set to values provided in attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheLoader

public CacheLoader()
Deprecated. 
Method Detail

load

public abstract Object load(Object handle,
                            Object arguments)
                     throws CacheException
Deprecated. 
this method must be implemented by the user to load objects into the cache. This will typically be a database-call or directory call, or extracting information from a file. This method returns a reference to the newly loaded object. If the object being loaded is a StreamAccess object or a disk object, the OutputStream object created by the createStream method, or the File created by the createDiskObject method should be returned.

Parameters:
handle - is supplied by the cache and is used by the netSearch and setAttributes methods to access information about the object being searched for.
arguments - is the object pass to the cache in the get method.
Returns:
a reference to the newly created object.
Throws:
CacheException

setAttributes

public final void setAttributes(Object handle,
                                Attributes attributes)
                         throws CacheException
Deprecated. 
will cause the attributes associated with the object being loaded to be set to values provided in attributes. If the attributes is null, default attributes are assumed.

Parameters:
handle - handle is the object passed into the load method.
attributes - the attributes to set.
Throws:
CacheException - if an error occurs.

getName

protected final Object getName(Object handle)
                        throws CacheException
Deprecated. 
returns the name associated with object being loaded. This method is only available to be called by application overrides of the load method.

Parameters:
handle - the handle to the object being loaded.
Returns:
the name associated with the object being loaded.
Throws:
CacheException - if some strange unexpected exception occur.

getRegion

protected final String getRegion(Object handle)
                          throws CacheException
Deprecated. 
return the name of the region for the object being loaded. This method is only available to be called from applications overriding the load method.

Parameters:
handle - the handle to the object being loaded.
Returns:
the region for the object being loaded.
Throws:
CacheException - if strange unexpected exceptions occur.
NullObjectException - if an object is discovered with required variables which is null.

netSearch

protected final Object netSearch(Object handle,
                                 int timeout)
                          throws CacheException
Deprecated. 
will search other caches for the object to be loaded. This method is only available to be called from applications overriding the load method. If the search is successfull, a reference to a local copy of the object is returned.

Parameters:
handle - the handle to the object being created.
timeout - the net search timeout.
Returns:
a reference to a local copy of the object.
Throws:
CacheException - if a timeout occurs, or the object is not found.
NotImplementedException - will always be thrown

createStream

public final OutputStream createStream(Object handle)
                                throws ObjectExistsException,
                                       InvalidArgumentException
Deprecated. 
should be called from the load method to create a StreamAccess object. The OutputStream returned is used to load the object into the cache. Default attributes are used. ObjectExistsExceptions occuring during this call can either be propagated to the caller , or null is returned. In both cases the cache will recognize that the object has been loaded by another cache, and return the object to the user.

Parameters:
handle - the object passed into the load method.
Returns:
an OutputStream to read the object into the cache.
Throws:
ObjectExistsException - if the object is declared as distributed, and another cache is in the progress of loading.
InvalidArgumentException - if some of the arguments are not valid in this context

createStream

public final OutputStream createStream(Object handle,
                                       Attributes attributes)
                                throws CacheException
Deprecated. 
should be called from the load method to create a StreamAccess object. The OutputStream returned is used to load the object into the cache. Default attributes are used. ObjectExistsExceptions occuring during this call can either be propagated to the caller , or null is returned. In both cases the cache will recognize that the object has been loaded by another cache, and return the object to the user.

Parameters:
handle - the object passed into the load method.
attributes - the attributes will be set on the object by this method. If null, default attributes are used.
Returns:
an OutputStream to read the object into the cache.
Throws:
CacheException - if the object is declared as distributed, and another cache is in the progress of loading, or any other strange exceptions occurs.

createDiskObject

public final File createDiskObject(Object handle,
                                   String extension)
                            throws CacheException
Deprecated. 
is called from the load object to create a disk object. The File returned can then be used to load the object into the cache. ObjectExistsExceptions occuring during this call can either be propagated to the caller , or null is returned. In both cases the cache will recognize that the object has been loaded by another cache, and return the object to the user.

Parameters:
handle - the object passed into the load method.
extension - The extension parameter is used as the extension to the file name (java, class, exe etc.) If null, no extension is added.
Returns:
a File which represent the object being created.
Throws:
CacheException - if the object is declared as distributed, and another cache is in the progress of loading, or any other strange exceptions occurs.

createDiskObject

public final File createDiskObject(Object handle,
                                   Attributes attributes,
                                   String extension)
                            throws CacheException
Deprecated. 
is called from the load object to create a disk object. The File returned can then be used to load the object into the cache. ObjectExistsExceptions occuring during this call can either be propagated to the caller , or null is returned. In both cases the cache will recognize that the object has been loaded by another cache, and return the object to the user.

Parameters:
handle - the object passed into the load method.
attributes - the attributes will be set on the object by this method. If null, default attributes are used.
extension - The extension parameter is used as the extension to the file name (java, class, exe etc.) If null, no extension is added.
Returns:
a File wich represent the object being created.
Throws:
CacheException - if the object is declared as distributed, and another cache is in the progress of loading, or any other strange exceptions occurs.

log

public final void log(String msg)
Deprecated. 
is called from the load method to record a message in the cache's log. How and where the logging occurs is dependent if the configuration of the logger in the cache.

Parameters:
msg - the message to log.

exceptionHandler

public final CacheException exceptionHandler(String msg,
                                             Exception exception)
Deprecated. 
this method is called from the load method to convert any non CacheExceptions into CacheExceptions, with the base exception set to the original exception. This allows the load method to only throw CacheExceptions without loosing important information. The exception will also be logged assuming the logging is configured and the logging severity is set sufficently high. For all CacheExceptions, if CacheException.printStackTrace() is called, and there is a base exception, the stack for the base will be printed.

Parameters:
msg - a message to provide to the CacheException.
exception - the Exception to be wrapped. If null, a default CacheException is returned.
Returns:
a CacheException wrapping the exception.


Copyright © 2002-2009 Hosted by SourceForge. All Rights Reserved.