com.metamatrix.cache.jboss
Class JBossCache<K,V>

java.lang.Object
  extended by com.metamatrix.cache.jboss.JBossCache<K,V>
All Implemented Interfaces:
Cache<K,V>

public class JBossCache<K,V>
extends java.lang.Object
implements Cache<K,V>

Implementation of Cache using JBoss Cache


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.metamatrix.cache.Cache
Cache.Type
 
Constructor Summary
JBossCache(org.jboss.cache.Cache cacheStore, org.jboss.cache.Fqn fqn)
           
 
Method Summary
 Cache addChild(java.lang.String name)
          Add a child node to the current cache node
 void addListener(CacheListener listener)
          Listener to get the updates on this Cache
 void clear()
          Removes all the keys and their values from the Cache
 V get(K key)
          Retrieves the value for the given Key
 Cache getChild(java.lang.String name)
          Get the child cache node from the current node
 java.util.List<Cache> getChildren()
          Get child nodes under this cache node.
 java.util.Set<K> keySet()
          Returns a Set containing the data in this Cache
 V put(K key, V value)
          Associates the specified value with the specified key this cache.
 V remove(K key)
          Removes the value for this key from a Cache.
 boolean removeChild(java.lang.String name)
          Destroys the child from the current node; no-op if node not found
 void removeListener()
          Remove Listener to stop the updates on this Cache
 int size()
          Size of the cache
 java.util.Collection<V> values()
          Returns a Collection containing the data in this Cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JBossCache

public JBossCache(org.jboss.cache.Cache cacheStore,
                  org.jboss.cache.Fqn fqn)
Method Detail

get

public V get(K key)
Retrieves the value for the given Key

Specified by:
get in interface Cache<K,V>
Parameters:
key - key under which value is to be retrieved.
Returns:
returns data held under specified key in cache

put

public V put(K key,
             V value)
Associates the specified value with the specified key this cache. If the cache previously contained a mapping for this key, the old value is replaced by the specified value.

Specified by:
put in interface Cache<K,V>
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the key previously associated null with the specified key, if the implementation supports null values.

remove

public V remove(K key)
Removes the value for this key from a Cache. Returns the value to which the Key previously associated , or null if the Key contained no mapping.

Specified by:
remove in interface Cache<K,V>
Parameters:
key - key whose mapping is to be removed
Returns:
previous value associated with specified Node's key

keySet

public java.util.Set<K> keySet()
Returns a Set containing the data in this Cache

Specified by:
keySet in interface Cache<K,V>
Returns:
a Set containing the data in this Cache. If there is no data, an empty Set is returned. The Set returned is always immutable.

size

public int size()
Size of the cache

Specified by:
size in interface Cache<K,V>
Returns:
number of items in this cache

clear

public void clear()
Removes all the keys and their values from the Cache

Specified by:
clear in interface Cache<K,V>

values

public java.util.Collection<V> values()
Description copied from interface: Cache
Returns a Collection containing the data in this Cache

Specified by:
values in interface Cache<K,V>
Returns:
a Collection containing the data in this Cache. If there is no data, an empty Collection is returned.

addListener

public void addListener(CacheListener listener)
Listener to get the updates on this Cache

Specified by:
addListener in interface Cache<K,V>

removeListener

public void removeListener()
Remove Listener to stop the updates on this Cache

Specified by:
removeListener in interface Cache<K,V>

addChild

public Cache addChild(java.lang.String name)
Add a child node to the current cache node

Specified by:
addChild in interface Cache<K,V>
Parameters:
name - - name of the child
Returns:
Cache instance.

getChild

public Cache getChild(java.lang.String name)
Get the child cache node from the current node

Specified by:
getChild in interface Cache<K,V>
Returns:
null if not found

getChildren

public java.util.List<Cache> getChildren()
Get child nodes under this cache node. If none found empty set is returned

Specified by:
getChildren in interface Cache<K,V>
Returns:

removeChild

public boolean removeChild(java.lang.String name)
Destroys the child from the current node; no-op if node not found

Specified by:
removeChild in interface Cache<K,V>
Returns:
true if removed; false otehrwise


Copyright © 2009. All Rights Reserved.