org.castor.cache
Class AbstractBaseCache

java.lang.Object
  extended by org.castor.cache.AbstractBaseCache
All Implemented Interfaces:
java.util.Map<java.lang.Object,java.lang.Object>, Cache
Direct Known Subclasses:
AbstractDistributedCache, AbstractHashbelt, CountLimited, EHCache, JcsCache, NoCache, OsCache, TimeLimited, Unlimited

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

Base implementation of all LRU cache types.

Since:
1.0
Version:
$Revision: 7950 $ $Date: 2006-05-05 13:53:54 -0600 (Fri, 05 May 2006) $
Author:
Werner Guttmann, Ralf Joachim

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from interface org.castor.cache.Cache
DEFAULT_DEBUG, DEFAULT_NAME, DEFAULT_TYPE, PARAM_DEBUG, PARAM_NAME, PARAM_TYPE
 
Constructor Summary
AbstractBaseCache()
           
 
Method Summary
 void close()
          Life-cycle method to allow custom resource cleanup for a cache implementation.
 void expire(java.lang.Object key)
          Remove the mapping identified by key from the cache.
 void expireAll()
          Removes all mappings from the cache.
 java.lang.String getName()
          Get virtual name of this cache.
 void initialize(java.util.Properties params)
          Lyfe-cycle method to allow custom initialization of cache implementations.
protected  java.lang.Object invokeMethod(java.lang.Object target, java.lang.String name, java.lang.Class<?>[] types, java.lang.Object[] arguments)
          Invoke method with given name and arguments having parameters of types specified on the given target.
protected  java.lang.Object invokeStaticMethod(java.lang.Class<?> target, java.lang.String name, java.lang.Class<?>[] types, java.lang.Object[] arguments)
          Invoke static method with given name and arguments having parameters of types specified on the given target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.castor.cache.Cache
getType
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

AbstractBaseCache

public AbstractBaseCache()
Method Detail

initialize

public void initialize(java.util.Properties params)
                throws CacheAcquireException
Lyfe-cycle method to allow custom initialization of cache implementations.

Specified by:
initialize in interface Cache
Parameters:
params - Parameters to initialize the cache (e.g. name, capacity).
Throws:
CacheAcquireException - If cache can not be initialized.

close

public void close()
Life-cycle method to allow custom resource cleanup for a cache implementation.

Specified by:
close in interface Cache

getName

public final java.lang.String getName()
Get virtual name of this cache. Castor sets the cache name to the class name of the objects stored in the cache.

Specified by:
getName in interface Cache
Returns:
The cache name.

expire

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

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

expireAll

public final void expireAll()
Removes all mappings from the cache.

Specified by:
expireAll in interface Cache

invokeStaticMethod

protected final java.lang.Object invokeStaticMethod(java.lang.Class<?> target,
                                                    java.lang.String name,
                                                    java.lang.Class<?>[] types,
                                                    java.lang.Object[] arguments)
                                             throws java.lang.NoSuchMethodException,
                                                    java.lang.IllegalAccessException,
                                                    java.lang.reflect.InvocationTargetException
Invoke static method with given name and arguments having parameters of types specified on the given target.

Parameters:
target - The target object to invoke the method on.
name - The name of the method to invoke.
types - The types of the parameters.
arguments - The parameters.
Returns:
The result of the method invokation.
Throws:
java.lang.NoSuchMethodException - If a matching method is not found or if the name is "<init>"or "<clinit>".
java.lang.IllegalAccessException - If this Method object enforces Java language access control and the underlying method is inaccessible.
java.lang.reflect.InvocationTargetException - If the underlying method throws an exception.

invokeMethod

protected final java.lang.Object invokeMethod(java.lang.Object target,
                                              java.lang.String name,
                                              java.lang.Class<?>[] types,
                                              java.lang.Object[] arguments)
                                       throws java.lang.NoSuchMethodException,
                                              java.lang.IllegalAccessException,
                                              java.lang.reflect.InvocationTargetException
Invoke method with given name and arguments having parameters of types specified on the given target.

Parameters:
target - The target object to invoke the method on.
name - The name of the method to invoke.
types - The types of the parameters.
arguments - The parameters.
Returns:
The result of the method invokation.
Throws:
java.lang.NoSuchMethodException - If a matching method is not found or if the name is "<init>"or "<clinit>".
java.lang.IllegalAccessException - If this Method object enforces Java language access control and the underlying method is inaccessible.
java.lang.reflect.InvocationTargetException - If the underlying method throws an exception.


Copyright © 2011. All Rights Reserved.