org.castor.persist.cache.distributed
Class JcsCache

java.lang.Object
  extended by org.exolab.castor.persist.cache.AbstractBaseCache
      extended by org.castor.persist.cache.distributed.JcsCache
All Implemented Interfaces:
Cache

public class JcsCache
extends AbstractBaseCache

JCS (Java Caching System) implementation of Castor JDO Cache. For more details of JCS, see http://jakarta.apache.org/jcs

Version:
$Revision: 1.1 $ $Date: 2005/08/04 07:31:15 $
Author:
Tim Telcik
See Also:
org.apache.jcs.JCS

Constructor Summary
JcsCache()
          Constructor
 
Method Summary
 void clear()
          Removes all mappings from this map.
 void close()
          Life-cycle method to allow custom resource cleanup for a cache implementation
 boolean contains(java.lang.Object key)
          Indicates whether the cache holds a valuze object for the specified key.
 boolean containsKey(java.lang.Object key)
          Returns true if this map contains a mapping for the specified key
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more keys to the specified value.
 java.util.Enumeration elements()
          Returns an enumeration of the values in this LRU map.
 java.util.Set entrySet()
          Returns a set view of the keys contained in this map.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this Map.
 void initialize()
          Initializes this cache instance.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 java.util.Set keySet()
          Returns a collection view of the values contained in this map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this Map.
 void putAll(java.util.Map aMap)
          Copies all of the mappings from the specified map to this map (optional operation).
 java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this Map.
 int size()
          Returns the number of key-value mappings in this map.
 java.util.Collection values()
           
 
Methods inherited from class org.exolab.castor.persist.cache.AbstractBaseCache
dispose, expire, getCacheType, getCapacity, getClassName, invokeMethod, invokeMethodReturnBoolean, invokeMethodReturnInt, invokeMethodWithExceptions, invokeStaticMethodWithExceptions, setCacheType, setCapacity, setClassName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcsCache

public JcsCache()
Constructor

Throws:
CacheAcquireException - If this cache implementation cannot be instantiated successfully.
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value in this Map. 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.

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

get

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

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

remove

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

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

elements

public 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
Specified by:
elements in class AbstractBaseCache
Returns:
an enumeration of the values in this Map.
See Also:
Enumeration

contains

public boolean contains(java.lang.Object key)
Indicates whether the cache holds a valuze object for the specified key.

Specified by:
contains in interface Cache
Specified by:
contains in class AbstractBaseCache
Parameters:
key - - A key identifying a value object.
Returns:
True if the cache holds a value object for the specified key, false otherwise.
See Also:
Cache.contains(java.lang.Object)

size

public int size()
         throws MethodNotImplementedException
Description copied from interface: Cache
Returns the number of key-value mappings in this map.

Throws:
MethodNotImplementedException

clear

public void clear()
           throws MethodNotImplementedException
Description copied from interface: Cache
Removes all mappings from this map.

Throws:
MethodNotImplementedException

isEmpty

public boolean isEmpty()
                throws MethodNotImplementedException
Description copied from interface: Cache
Returns true if this map contains no key-value mappings.

Returns:
True if this map contains no key-value mappings
Throws:
MethodNotImplementedException

containsKey

public boolean containsKey(java.lang.Object key)
Description copied from interface: Cache
Returns true if this map contains a mapping for the specified key

Parameters:
key - A key object.
Returns:
true if this map contains a mapping for the specified key

containsValue

public boolean containsValue(java.lang.Object value)
                      throws MethodNotImplementedException
Description copied from interface: Cache
Returns true if this map maps one or more keys to the specified value. This operation will probably require time linear to the cache size for most implementations of the Cache interface.

Parameters:
value - The object value.
Returns:
true if this map maps one or more keys to the specified value
Throws:
MethodNotImplementedException

values

public java.util.Collection values()
                            throws MethodNotImplementedException
Returns:
Throws:
MethodNotImplementedException

putAll

public void putAll(java.util.Map aMap)
Description copied from interface: Cache
Copies all of the mappings from the specified map to this map (optional operation).

Parameters:
aMap - The map to be copied.

entrySet

public java.util.Set entrySet()
                       throws MethodNotImplementedException
Description copied from interface: Cache
Returns a set view of the keys contained in this map.

Returns:
A set view of all the keys.
Throws:
MethodNotImplementedException

keySet

public java.util.Set keySet()
                     throws MethodNotImplementedException
Description copied from interface: Cache
Returns a collection view of the values contained in this map.

Returns:
A set view of all the value objects.
Throws:
MethodNotImplementedException

initialize

public void initialize()
                throws CacheAcquireException
Initializes this cache instance.

Throws:
CacheAcquireException - If the cache cannot be initialized.

close

public 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
Specified by:
close in class AbstractBaseCache
See Also:
Cache.close()


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