SolarMetric Kodo JDO 2.4.3 generated on March 27 2003

com.solarmetric.kodo.runtime.datacache.plugins
Class TangosolCache

java.lang.Object
  |
  +--com.solarmetric.kodo.runtime.datacache.plugins.TangosolCache
All Implemented Interfaces:
Configurable, DataCache

public class TangosolCache
extends Object
implements DataCache, Configurable

A PersistenceManagerFactory cache that delegates to a Tangosol Coherence cache. This cache can be used to share data among PersistenceManagers created from a single PersistenceManagerFactory. Batch updates are performed atomically.


Field Summary
protected  com.tangosol.net.NamedCache cache
           
 
Constructor Summary
TangosolCache()
           
 
Method Summary
 void batchUpdate(Map additions, Map updates, Collection deletes, Object origin)
          ### We should probably lock the underlying cache here.
 void clear()
          Remove all data from this cache.
 void close()
          Close this cache, dropping all hard references and releasing any resources that this cache maintains.
 boolean containsKey(Object key)
          Returns true if this cache contains data corresponding to key; otherwise returns false.
 void endConfiguration()
          Invoked upon completion of configuration of this object
 Object get(Object key)
          Return the cached object for the given key.
 boolean getDistributedCache()
          Returns true if this cache will use a distributed Tangosol cache; otherwise returns false.
 com.tangosol.net.NamedCache getTangosolCache()
          Returns the underlying NamedCache that this TangosolCache is using.
 String getTangosolCacheName()
          Returns the name of the Tangosol cache to use.
protected  com.tangosol.net.NamedCache newCache()
          Returns a new NamedCache for use as the underlying data cache.
 boolean pin(Object key)
          Coherence doesn't have a concept of expiring data, so pinning is meaningless.
 Object put(Object key, Object value)
          Set the cached value for the given key.
 Object remove(Object key)
          Remove the value stored under the given key.
 void setTangosolCacheName(String name)
          Sets the name of the Tangosol cache to use.
 void setTangosolCacheType(String type)
          If distributed, this cache implementation will use a distibuted cache.
 void startConfiguration()
          Invoked before configuration is begun on this object
 boolean unpin(Object key)
          Coherence doesn't have a concept of expiring data, so unpinning is meaningless.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected com.tangosol.net.NamedCache cache
Constructor Detail

TangosolCache

public TangosolCache()
Method Detail

getTangosolCache

public com.tangosol.net.NamedCache getTangosolCache()
Returns the underlying NamedCache that this TangosolCache is using. This is not an unmodifiable view on the map, so care should be taken with this reference. Implementations should probably not mess with the contents of the cache, but should only use this reference to obtain cache metrics.

newCache

protected com.tangosol.net.NamedCache newCache()
Returns a new NamedCache for use as the underlying data cache. This implementation returns a NamedCache obtained by invoking CacheFactory.getDistributedCache(java.lang.String) if the TangosolCacheType DataCache property is set to distributed or unset, or by invoking CacheFactory.getReplicatedCache(java.lang.String) if set to replicated. It uses the name specified by the TangosolCacheName property, or "kodo" if unset. To implement a more sophisticated caching strategy, override this method.

batchUpdate

public void batchUpdate(Map additions,
                        Map updates,
                        Collection deletes,
                        Object origin)
### We should probably lock the underlying cache here.
Specified by:
batchUpdate in interface DataCache
Following copied from interface: com.solarmetric.kodo.runtime.datacache.DataCache
Parameters:
origin - the object that initiated this cache update. This can be useful for implementations in which many sources share a single cache, which in turn communicates back to the sources on cache updates.

get

public Object get(Object key)
Description copied from interface: DataCache
Return the cached object for the given key. Modifying the returned object may or may not change the cached value; the DataCache.put(java.lang.Object, java.lang.Object) method should be used to re-cache any changed objects.
Specified by:
get in interface DataCache
Following copied from interface: com.solarmetric.kodo.runtime.datacache.DataCache
Returns:
the object matching the given key, or null if none

put

public Object put(Object key,
                  Object value)
Description copied from interface: DataCache
Set the cached value for the given key. This does not result in an update of other caches. Rather, it should only be used for loading clean data into the cache. Meaningful changes to the state of the cache should be made via the DataCache.batchUpdate(java.util.Map, java.util.Map, java.util.Collection, java.lang.Object) method.
Specified by:
put in interface DataCache
Following copied from interface: com.solarmetric.kodo.runtime.datacache.DataCache
Returns:
The previously cached value, or null if the key was not previously cached. See Map.put(java.lang.Object, java.lang.Object) for more information.

remove

public Object remove(Object key)
Description copied from interface: DataCache
Remove the value stored under the given key. This does not result in an update of other caches. Rather, it should only be used for removing data into the cache. Meaningful changes to the state of the cache should be made via the batchUpdate method.
Specified by:
remove in interface DataCache
Following copied from interface: com.solarmetric.kodo.runtime.datacache.DataCache
Returns:
The previously cached value, or null if the key was not previously cached. See Map.remove(java.lang.Object) for more information.

clear

public void clear()
Description copied from interface: DataCache
Remove all data from this cache. This does not result in an update of other caches. Rather, it should only be used for clearing the cache. Meaningful changes to the state of the cache should be made via the batchUpdate method.
Specified by:
clear in interface DataCache

pin

public boolean pin(Object key)
Coherence doesn't have a concept of expiring data, so pinning is meaningless. This method is equivalent to invoking Map.containsKey(java.lang.Object).
Specified by:
pin in interface DataCache
Following copied from interface: com.solarmetric.kodo.runtime.datacache.DataCache
Returns:
true if key's value was pinned into the cache; false if the key is not in the cache.

unpin

public boolean unpin(Object key)
Coherence doesn't have a concept of expiring data, so unpinning is meaningless. This method is equivalent to invoking Map.containsKey(java.lang.Object).
Specified by:
unpin in interface DataCache
Following copied from interface: com.solarmetric.kodo.runtime.datacache.DataCache
Returns:
true if key's value was unpinned from the cache; false if the key is not in the cache.

close

public void close()
Description copied from interface: DataCache
Close this cache, dropping all hard references and releasing any resources that this cache maintains.
Specified by:
close in interface DataCache

containsKey

public boolean containsKey(Object key)
Description copied from interface: DataCache
Returns true if this cache contains data corresponding to key; otherwise returns false.
Specified by:
containsKey in interface DataCache

setTangosolCacheType

public void setTangosolCacheType(String type)
If distributed, this cache implementation will use a distibuted cache. If replicated, this cache implementation will use a replicated cache.

getDistributedCache

public final boolean getDistributedCache()
Returns true if this cache will use a distributed Tangosol cache; otherwise returns false.

setTangosolCacheName

public void setTangosolCacheName(String name)
Sets the name of the Tangosol cache to use.

getTangosolCacheName

public final String getTangosolCacheName()
Returns the name of the Tangosol cache to use.

startConfiguration

public void startConfiguration()
Description copied from interface: Configurable
Invoked before configuration is begun on this object
Specified by:
startConfiguration in interface Configurable

endConfiguration

public void endConfiguration()
Description copied from interface: Configurable
Invoked upon completion of configuration of this object
Specified by:
endConfiguration in interface Configurable

SolarMetric Kodo JDO 2.4.3 generated on March 27 2003

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.