org.exolab.castor.persist.cache
Class AbstractBaseCache

java.lang.Object
  extended by org.exolab.castor.persist.cache.AbstractBaseCache
All Implemented Interfaces:
Cache
Direct Known Subclasses:
CoherenceCache, CountLimited, FKCache, JCache, JcsCache, NoCache, TimeLimited, Unlimited

public abstract class AbstractBaseCache
extends java.lang.Object
implements Cache

Base implementation of all LRU cache types.

Author:
Werner Guttmann

Constructor Summary
AbstractBaseCache()
           
 
Method Summary
abstract  void close()
          Life-cycle method to allow custom resource cleanup for a cache implementation
abstract  boolean contains(java.lang.Object key)
          Indicates whether the cache holds value object mapped to the specified key.
protected  void dispose(java.lang.Object obj)
          This method is called when an object is disposed.
abstract  java.util.Enumeration elements()
          Returns an enumeration of the values in this LRU map.
 void expire(java.lang.Object key)
          Remove the object identified by key from the cache.
abstract  java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 java.lang.String getCacheType()
          Indicates the type of this cache.
 int getCapacity()
          Indicates the cache capacity.
 java.lang.String getClassName()
          Indicates the class name of objects stored in this cache.
protected  java.lang.Object invokeMethod(java.lang.Object target, java.lang.String name, java.lang.Class[] argumentTypes, java.lang.Object[] arguments)
           
protected  boolean invokeMethodReturnBoolean(java.lang.Object target, java.lang.String name, java.lang.Class[] argumentTypes, java.lang.Object[] arguments)
           
protected  int invokeMethodReturnInt(java.lang.Object target, java.lang.String name, java.lang.Class[] argumentTypes, java.lang.Object[] arguments)
           
protected  java.lang.Object invokeMethodWithExceptions(java.lang.Object target, java.lang.String name, java.lang.Class[] argumentTypes, java.lang.Object[] arguments)
           
protected  java.lang.Object invokeStaticMethodWithExceptions(java.lang.Class target, java.lang.String name, java.lang.Class[] argumentTypes, java.lang.Object[] arguments)
           
abstract  java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
abstract  java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this hashtable.
 void setCacheType(java.lang.String cacheType)
          Sets the type of this cache instance.
 void setCapacity(int capacity)
          Sets the cache capacity.
 void setClassName(java.lang.String className)
          Sets the class name of objects cached here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exolab.castor.persist.cache.Cache
clear, containsKey, containsValue, entrySet, initialize, isEmpty, keySet, putAll, size, values
 

Constructor Detail

AbstractBaseCache

public AbstractBaseCache()
Method Detail

put

public abstract java.lang.Object put(java.lang.Object key,
                                     java.lang.Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key, before it is diposed by the least-recently-used map.

Specified by:
put in interface Cache
Parameters:
key - the hashtable key.
value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - if the key or value is null.

get

public abstract java.lang.Object get(java.lang.Object key)
Returns the value to which the specified key is mapped in this hashtable.

Specified by:
get in interface Cache
Parameters:
key - - a key in the hashtable.
Returns:
the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

remove

public abstract java.lang.Object remove(java.lang.Object key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Specified by:
remove in interface Cache
Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

elements

public abstract java.util.Enumeration elements()
Returns an enumeration of the values in this LRU map. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Specified by:
elements in interface Cache
Returns:
an enumeration of the values in this hashtable.
See Also:
Enumeration

expire

public void expire(java.lang.Object key)
Remove the object identified by key from the cache.

Specified by:
expire in interface Cache
Parameters:
key - the key that needs to be removed.

dispose

protected void dispose(java.lang.Object obj)
This method is called when an object is disposed. Override this method if you interested in the disposed object.

Parameters:
o - - the disposed object

contains

public abstract boolean contains(java.lang.Object key)
Indicates whether the cache holds value object mapped to the specified key.

Specified by:
contains in interface Cache
Parameters:
key - - A key identifying a value object.
Returns:
True if the cache holds a value object for the specified key, false otherwise.

getCacheType

public java.lang.String getCacheType()
Indicates the type of this cache.

Specified by:
getCacheType in interface Cache
Returns:
the cache type.

setCacheType

public void setCacheType(java.lang.String cacheType)
Sets the type of this cache instance.

Specified by:
setCacheType in interface Cache
Parameters:
cacheType - the type of this cache.

getCapacity

public int getCapacity()
Indicates the cache capacity.

Specified by:
getCapacity in interface Cache
Returns:
the cache capacity.

setCapacity

public void setCapacity(int capacity)
Sets the cache capacity.

Specified by:
setCapacity in interface Cache
Parameters:
capacity - the cache capacity.

getClassName

public java.lang.String getClassName()
Indicates the class name of objects stored in this cache.

Specified by:
getClassName in interface Cache
Returns:
The class name.
See Also:
Cache.getClassName()

setClassName

public void setClassName(java.lang.String className)
Sets the class name of objects cached here.

Specified by:
setClassName in interface Cache
Parameters:
className - The class name.
See Also:
Cache.setClassName(String)

invokeStaticMethodWithExceptions

protected java.lang.Object invokeStaticMethodWithExceptions(java.lang.Class target,
                                                            java.lang.String name,
                                                            java.lang.Class[] argumentTypes,
                                                            java.lang.Object[] arguments)
                                                     throws java.lang.NoSuchMethodException,
                                                            java.lang.IllegalAccessException,
                                                            java.lang.reflect.InvocationTargetException
Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

invokeMethodWithExceptions

protected java.lang.Object invokeMethodWithExceptions(java.lang.Object target,
                                                      java.lang.String name,
                                                      java.lang.Class[] argumentTypes,
                                                      java.lang.Object[] arguments)
                                               throws java.lang.NoSuchMethodException,
                                                      java.lang.IllegalAccessException,
                                                      java.lang.reflect.InvocationTargetException
Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

invokeMethod

protected java.lang.Object invokeMethod(java.lang.Object target,
                                        java.lang.String name,
                                        java.lang.Class[] argumentTypes,
                                        java.lang.Object[] arguments)

invokeMethodReturnBoolean

protected boolean invokeMethodReturnBoolean(java.lang.Object target,
                                            java.lang.String name,
                                            java.lang.Class[] argumentTypes,
                                            java.lang.Object[] arguments)

invokeMethodReturnInt

protected int invokeMethodReturnInt(java.lang.Object target,
                                    java.lang.String name,
                                    java.lang.Class[] argumentTypes,
                                    java.lang.Object[] arguments)

close

public abstract void close()
Description copied from interface: Cache
Life-cycle method to allow custom resource cleanup for a cache implementation

Specified by:
close in interface Cache
See Also:
Cache.close()


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com