Package org.castor.cache
Class AbstractBaseCache
java.lang.Object
org.castor.cache.AbstractBaseCache
- Direct Known Subclasses:
AbstractDistributedCache
,AbstractHashbelt
,CountLimited
,EHCache
,JcsCache
,NoCache
,OsCache
,TimeLimited
,Unlimited
Base implementation of all LRU cache types.
- Since:
- 1.0
- Version:
- $Revision: 8102 $ $Date: 2006-05-05 13:53:54 -0600 (Fri, 05 May 2006) $
- Author:
- Werner Guttmann, Ralf Joachim
-
Nested Class Summary
-
Field Summary
Fields inherited from interface org.castor.cache.Cache
DEFAULT_DEBUG, DEFAULT_NAME, DEFAULT_TYPE, PARAM_DEBUG, PARAM_NAME, PARAM_TYPE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Life-cycle method to allow custom resource cleanup for a cache implementation.final void
Remove the mapping identified by key from the cache.final void
Removes all mappings from the cache.final String
getName()
Get virtual name of this cache.void
initialize
(Properties params) Lyfe-cycle method to allow custom initialization of cache implementations.protected final Object
invokeMethod
(Object target, String name, Class<?>[] types, Object[] arguments) Invoke method with given name and arguments having parameters of types specified on the given target.protected final Object
invokeStaticMethod
(Class<?> target, String name, Class<?>[] types, 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 java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Constructor Details
-
AbstractBaseCache
public AbstractBaseCache()
-
-
Method Details
-
initialize
Lyfe-cycle method to allow custom initialization of cache implementations.- Specified by:
initialize
in interfaceCache
- 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. -
getName
Get virtual name of this cache. Castor sets the cache name to the class name of the objects stored in the cache. -
expire
Remove the mapping identified by key from the cache. -
expireAll
public final void expireAll()Removes all mappings from the cache. -
invokeStaticMethod
protected final Object invokeStaticMethod(Class<?> target, String name, Class<?>[] types, Object[] arguments) throws NoSuchMethodException, IllegalAccessException, 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:
NoSuchMethodException
- If a matching method is not found or if the name is "<init>"or "<clinit>".IllegalAccessException
- If this Method object enforces Java language access control and the underlying method is inaccessible.InvocationTargetException
- If the underlying method throws an exception.
-
invokeMethod
protected final Object invokeMethod(Object target, String name, Class<?>[] types, Object[] arguments) throws NoSuchMethodException, IllegalAccessException, 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:
NoSuchMethodException
- If a matching method is not found or if the name is "<init>"or "<clinit>".IllegalAccessException
- If this Method object enforces Java language access control and the underlying method is inaccessible.InvocationTargetException
- If the underlying method throws an exception.
-