org.datanucleus.cache.coherence
Class CoherenceLevel2Cache

java.lang.Object
  extended by org.datanucleus.cache.coherence.CoherenceLevel2Cache
All Implemented Interfaces:
java.io.Serializable, org.datanucleus.cache.Level2Cache

public class CoherenceLevel2Cache
extends java.lang.Object
implements org.datanucleus.cache.Level2Cache

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.datanucleus.cache.Level2Cache
org.datanucleus.cache.Level2Cache.PinnedClass
 
Constructor Summary
CoherenceLevel2Cache(org.datanucleus.OMFContext omfCtx)
          Constructor.
 
Method Summary
 void clear()
          Method to clear the cache
 void close()
          Method to close the cache when no longer needed.
 boolean containsOid(java.lang.Object oid)
          Accessor for whether the cache contains the specified id.
 void evict(java.lang.Object oid)
          Evict the parameter instance from the second-level cache.
 void evictAll()
          Evict the parameter instances from the second-level cache.
 void evictAll(java.lang.Class pcClass, boolean subclasses)
          Evict the parameter instances from the second-level cache.
 void evictAll(java.util.Collection oids)
          Evict the parameter instances from the second-level cache.
 void evictAll(java.lang.Object[] oids)
          Evict the parameter instances from the second-level cache.
 org.datanucleus.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 Coherence.
 int getNumberOfUnpinnedObjects()
          Accessor for the number of unpinned objects - not supported by Coherence.
 int getSize()
          Accessor for the size of the cache.
 com.tangosol.net.NamedCache getTangosolCache()
          Accessor for the backing Coherence cache.
 boolean isEmpty()
          Accessor for whether the cache is empty
 boolean lock(java.lang.Object oid)
          Method to lock the underlying Coherence cache.
 boolean lock(java.lang.Object oid, int wait)
          Method to lock the underlying Coherence cache for a time period.
 void pin(java.lang.Object oid)
          Pin the parameter instance in the second-level cache.
 void pinAll(java.lang.Class cls, boolean subs)
          Pin instances in the second-level cache.
 void pinAll(java.util.Collection oids)
          Pin the parameter instances in the second-level cache.
 void pinAll(java.lang.Object[] oids)
          Pin the parameter instances in the second-level cache.
 org.datanucleus.cache.CachedPC put(java.lang.Object oid, org.datanucleus.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 Coherence cache.
 void unpin(java.lang.Object oid)
          Unpin the parameter instance from the second-level cache.
 void unpinAll(java.lang.Class cls, boolean subs)
          Unpin instances from the second-level cache.
 void unpinAll(java.util.Collection oids)
          Unpin the parameter instances from the second-level cache.
 void unpinAll(java.lang.Object[] oids)
          Unpin the parameter instances from the second-level cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoherenceLevel2Cache

public CoherenceLevel2Cache(org.datanucleus.OMFContext omfCtx)
Constructor.

Parameters:
omfCtx - OMF Context
Method Detail

close

public void close()
Method to close the cache when no longer needed. Provides a hook to release resources etc.

Specified by:
close in interface org.datanucleus.cache.Level2Cache

getTangosolCache

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

Returns:
The Coherence named cache.

clear

public void clear()
Method to clear the cache

Specified by:
clear in interface org.datanucleus.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.datanucleus.cache.Level2Cache
See Also:
Level2Cache.containsOid(java.lang.Object)

lock

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

Parameters:
oid - The key
Returns:
Success indicator

lock

public boolean lock(java.lang.Object oid,
                    int wait)
Method to lock the underlying Coherence 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 Coherence cache.

Parameters:
oid - The key
Returns:
Success indicator

get

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

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

getNumberOfPinnedObjects

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

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

getNumberOfUnpinnedObjects

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

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

getSize

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

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

isEmpty

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

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

put

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

Specified by:
put in interface org.datanucleus.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)
Evict the parameter instance from the second-level cache.

Specified by:
evict in interface org.datanucleus.cache.Level2Cache
Parameters:
oid - the object id of the instance to evict.

evictAll

public void evictAll()
Evict the parameter instances from the second-level cache. All instances in the PersistenceManager's cache are evicted from the second-level cache.

Specified by:
evictAll in interface org.datanucleus.cache.Level2Cache

evictAll

public void evictAll(java.lang.Class pcClass,
                     boolean subclasses)
Evict the parameter instances from the second-level cache.

Specified by:
evictAll in interface org.datanucleus.cache.Level2Cache
Parameters:
pcClass - the class of instances to evict
subclasses - if true, evict instances of subclasses also

evictAll

public void evictAll(java.util.Collection oids)
Evict the parameter instances from the second-level cache.

Specified by:
evictAll in interface org.datanucleus.cache.Level2Cache
Parameters:
oids - the object ids of the instance to evict.

evictAll

public void evictAll(java.lang.Object[] oids)
Evict the parameter instances from the second-level cache.

Specified by:
evictAll in interface org.datanucleus.cache.Level2Cache
Parameters:
oids - the object ids of the instance to evict.

pin

public void pin(java.lang.Object oid)
Pin the parameter instance in the second-level cache.

Specified by:
pin in interface org.datanucleus.cache.Level2Cache
Parameters:
oid - the object id of the instance to pin.

pinAll

public void pinAll(java.lang.Class cls,
                   boolean subs)
Pin instances in the second-level cache.

Specified by:
pinAll in interface org.datanucleus.cache.Level2Cache
Parameters:
cls - the class of instances to pin
subs - if true, pin instances of subclasses also

pinAll

public void pinAll(java.util.Collection oids)
Pin the parameter instances in the second-level cache.

Specified by:
pinAll in interface org.datanucleus.cache.Level2Cache
Parameters:
oids - the object ids of the instances to pin.

pinAll

public void pinAll(java.lang.Object[] oids)
Pin the parameter instances in the second-level cache.

Specified by:
pinAll in interface org.datanucleus.cache.Level2Cache
Parameters:
oids - the object ids of the instances to pin.

unpin

public void unpin(java.lang.Object oid)
Unpin the parameter instance from the second-level cache.

Specified by:
unpin in interface org.datanucleus.cache.Level2Cache
Parameters:
oid - the object id of the instance to unpin.

unpinAll

public void unpinAll(java.lang.Class cls,
                     boolean subs)
Unpin instances from the second-level cache.

Specified by:
unpinAll in interface org.datanucleus.cache.Level2Cache
Parameters:
cls - the class of instances to unpin
subs - if true, unpin instances of subclasses also

unpinAll

public void unpinAll(java.util.Collection oids)
Unpin the parameter instances from the second-level cache.

Specified by:
unpinAll in interface org.datanucleus.cache.Level2Cache
Parameters:
oids - the object ids of the instance to evict.

unpinAll

public void unpinAll(java.lang.Object[] oids)
Unpin the parameter instances from the second-level cache.

Specified by:
unpinAll in interface org.datanucleus.cache.Level2Cache
Parameters:
oids - the object ids of the instance to evict.


Copyright © 2010. All Rights Reserved.