org.jpox.cache
Class TangosolLevel2Cache

java.lang.Object
  extended byorg.jpox.cache.TangosolLevel2Cache
All Implemented Interfaces:
javax.jdo.datastore.DataStoreCache, org.jpox.cache.Level2Cache

public class TangosolLevel2Cache
extends java.lang.Object
implements org.jpox.cache.Level2Cache

Simple implementation of a plugin for use of Tangosols Coherence distributed caching product with JPOX. Please refer to www.tangosol.com for full details of their products. This plugin simply provides a wrapper to the Tangosol "NamedCache" to allow its use in JPOX.

Version:
$Revision: 1.9 $

Nested Class Summary
 
Nested classes inherited from class org.jpox.cache.Level2Cache
org.jpox.cache.Level2Cache.PinnedClass
 
Nested classes inherited from class javax.jdo.datastore.DataStoreCache
javax.jdo.datastore.DataStoreCache.EmptyDataStoreCache
 
Constructor Summary
TangosolLevel2Cache(java.util.Properties props)
          Constructor.
 
Method Summary
 void clear()
          Method to clear the cache
 boolean containsOid(java.lang.Object oid)
          Accessor for whether the cache contains the specified id.
 void evict(java.lang.Object oid)
           
 void evictAll()
           
 void evictAll(java.lang.Class pcClass, boolean subclasses)
           
 void evictAll(java.util.Collection oids)
           
 void evictAll(java.lang.Object[] oids)
           
 org.jpox.cache.CachedPC get(java.lang.Object oid)
          Accessor for an object in the cache.
 int getNumberOfPinnedObjects()
          Accessor for the number of pinned objects - not supported by Tangosol.
 int getNumberOfUnpinnedObjects()
          Accessor for the number of unpinned objects - not supported by Tangosol.
 int getSize()
          Accessor for the size of the cache.
 com.tangosol.net.NamedCache getTangosolCache()
          Accessor for the backing Tangosol cache.
 boolean isEmpty()
          Accessor for whether the cache is empty
 boolean lock(java.lang.Object oid)
          Method to lock the underlying Tangosol cache.
 boolean lock(java.lang.Object oid, int wait)
          Method to lock the underlying Tangosol cache for a time period.
 void pin(java.lang.Object oid)
           
 void pinAll(java.lang.Class cls, boolean subs)
           
 void pinAll(java.util.Collection oids)
           
 void pinAll(java.lang.Object[] oids)
           
 org.jpox.cache.CachedPC put(java.lang.Object oid, org.jpox.cache.CachedPC pc)
          Method to add an object to the cache under its id
 boolean unlock(java.lang.Object oid)
          Method to unlock the underlying Tangosol cache.
 void unpin(java.lang.Object oid)
           
 void unpinAll(java.lang.Class cls, boolean subs)
           
 void unpinAll(java.util.Collection oids)
           
 void unpinAll(java.lang.Object[] oids)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TangosolLevel2Cache

public TangosolLevel2Cache(java.util.Properties props)
Constructor.

Parameters:
props - Any properties to control the cache
Method Detail

getTangosolCache

public com.tangosol.net.NamedCache getTangosolCache()
Accessor for the backing Tangosol cache. This is provided so that users can add much more elaborate control over their cache in line with what Tangosol provides.

Returns:
The Tangosol named cache.

clear

public void clear()
Method to clear the cache

Specified by:
clear in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.clear()

containsOid

public boolean containsOid(java.lang.Object oid)
Accessor for whether the cache contains the specified id.

Specified by:
containsOid in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.containsOid(java.lang.Object)

lock

public boolean lock(java.lang.Object oid)
Method to lock the underlying Tangosol cache.

Parameters:
oid - The key
Returns:
Success indicator

lock

public boolean lock(java.lang.Object oid,
                    int wait)
Method to lock the underlying Tangosol cache for a time period.

Parameters:
oid - The key
wait - the time period (ms)
Returns:
Success indicator

unlock

public boolean unlock(java.lang.Object oid)
Method to unlock the underlying Tangosol cache.

Parameters:
oid - The key
Returns:
Success indicator

get

public org.jpox.cache.CachedPC get(java.lang.Object oid)
Accessor for an object in the cache.

Specified by:
get in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.get(java.lang.Object)

getNumberOfPinnedObjects

public int getNumberOfPinnedObjects()
Accessor for the number of pinned objects - not supported by Tangosol.

Specified by:
getNumberOfPinnedObjects in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.getNumberOfPinnedObjects()

getNumberOfUnpinnedObjects

public int getNumberOfUnpinnedObjects()
Accessor for the number of unpinned objects - not supported by Tangosol.

Specified by:
getNumberOfUnpinnedObjects in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.getNumberOfUnpinnedObjects()

getSize

public int getSize()
Accessor for the size of the cache.

Specified by:
getSize in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.getSize()

isEmpty

public boolean isEmpty()
Accessor for whether the cache is empty

Specified by:
isEmpty in interface org.jpox.cache.Level2Cache
See Also:
Level2Cache.isEmpty()

put

public org.jpox.cache.CachedPC put(java.lang.Object oid,
                                   org.jpox.cache.CachedPC pc)
Method to add an object to the cache under its id

Specified by:
put in interface org.jpox.cache.Level2Cache
Parameters:
oid - The identity
pc - The cacheable object
Returns:
previous value for this identity (if any)

evict

public void evict(java.lang.Object oid)
Specified by:
evict in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.evict(java.lang.Object)

evictAll

public void evictAll()
Specified by:
evictAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.evictAll()

evictAll

public void evictAll(java.lang.Class pcClass,
                     boolean subclasses)
Specified by:
evictAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.evictAll(java.lang.Class, boolean)

evictAll

public void evictAll(java.util.Collection oids)
Specified by:
evictAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.evictAll(java.util.Collection)

evictAll

public void evictAll(java.lang.Object[] oids)
Specified by:
evictAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.evictAll(java.lang.Object[])

pin

public void pin(java.lang.Object oid)
Specified by:
pin in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.pin(java.lang.Object)

pinAll

public void pinAll(java.lang.Class cls,
                   boolean subs)
Specified by:
pinAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.pinAll(java.lang.Class, boolean)

pinAll

public void pinAll(java.util.Collection oids)
Specified by:
pinAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.pinAll(java.util.Collection)

pinAll

public void pinAll(java.lang.Object[] oids)
Specified by:
pinAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.pinAll(java.lang.Object[])

unpin

public void unpin(java.lang.Object oid)
Specified by:
unpin in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.unpin(java.lang.Object)

unpinAll

public void unpinAll(java.lang.Class cls,
                     boolean subs)
Specified by:
unpinAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.unpinAll(java.lang.Class, boolean)

unpinAll

public void unpinAll(java.util.Collection oids)
Specified by:
unpinAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.unpinAll(java.util.Collection)

unpinAll

public void unpinAll(java.lang.Object[] oids)
Specified by:
unpinAll in interface javax.jdo.datastore.DataStoreCache
See Also:
DataStoreCache.unpinAll(java.lang.Object[])


Copyright © 2003-2007 Java Persistent Objects (JPOX). All Rights Reserved.