org.castor.cache.distributed
Class AbstractDistributedCache<K,V>

java.lang.Object
  extended by org.castor.cache.AbstractBaseCache<K,V>
      extended by org.castor.cache.distributed.AbstractDistributedCache<K,V>
Type Parameters:
K - the type of keys maintained by this cache
V - the type of cached values
All Implemented Interfaces:
Map<K,V>, Cache<K,V>
Direct Known Subclasses:
CoherenceCache, EHCache, FKCache, GigaspacesCache, JCache, JcsCache, OsCache

public abstract class AbstractDistributedCache<K,V>
extends AbstractBaseCache<K,V>

Base implementation of all distributed cache types.

Since:
1.0
Version:
$Revision: 9040 $ $Date: 2011-08-16 08:26:59 +0200 (Di, 16 Aug 2011) $
Author:
Werner Guttmann, Ralf Joachim

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
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
AbstractDistributedCache()
           
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<K,V>> entrySet()
          
 V get(Object key)
          
protected  Map<K,V> getCache()
          Get the cache instance.
protected  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  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.
 boolean isEmpty()
          
 Set<K> keySet()
          
 V put(K key, V value)
          
 void putAll(Map<? extends K,? extends V> map)
          
 V remove(Object key)
          
protected  void setCache(Map<K,V> cache)
          Set the cache instance.
 int size()
          
 Collection<V> values()
          
 
Methods inherited from class org.castor.cache.AbstractBaseCache
close, expire, expireAll, getName, initialize
 
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
equals, hashCode
 

Constructor Detail

AbstractDistributedCache

public AbstractDistributedCache()
Method Detail

getCache

protected final Map<K,V> getCache()
Get the cache instance.

Returns:
The cache instance.

setCache

protected final void setCache(Map<K,V> cache)
Set the cache instance.

Parameters:
cache - The cache instance.

size

public int size()


isEmpty

public boolean isEmpty()


containsKey

public boolean containsKey(Object key)


containsValue

public boolean containsValue(Object value)


get

public V get(Object key)


put

public V put(K key,
             V value)


remove

public V remove(Object key)


putAll

public void putAll(Map<? extends K,? extends V> map)


clear

public void clear()


keySet

public Set<K> keySet()


values

public Collection<V> values()


entrySet

public Set<Map.Entry<K,V>> entrySet()


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.


Copyright © 2012. All Rights Reserved.