org.datanucleus.cache
Class JavaxCacheLevel2Cache

java.lang.Object
  extended by org.datanucleus.cache.AbstractLevel2Cache
      extended by org.datanucleus.cache.JavaxCacheLevel2Cache
All Implemented Interfaces:
Serializable, Level2Cache

public class JavaxCacheLevel2Cache
extends AbstractLevel2Cache

Simple implementation of a plugin for use of javax.cache (v0.61+) product with DataNucleus.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.datanucleus.cache.Level2Cache
Level2Cache.PinnedClass
 
Field Summary
 
Fields inherited from class org.datanucleus.cache.AbstractLevel2Cache
cacheName, clearAtClose, LOCALISER, maxSize, nucleusCtx, timeout
 
Constructor Summary
JavaxCacheLevel2Cache(NucleusContext nucleusCtx)
          Constructor.
 
Method Summary
 void close()
          Method to close the cache when no longer needed.
 boolean containsOid(Object oid)
          Accessor for whether the cache contains the specified id.
 void evict(Object oid)
          Evict the parameter instance from the second-level cache.
 void evictAll()
          Evict the parameter instances from the second-level cache.
 void evictAll(Class pcClass, boolean subclasses)
          Evict the parameter instances from the second-level cache.
 void evictAll(Collection oids)
          Evict the parameter instances from the second-level cache.
 void evictAll(Object[] oids)
          Evict the parameter instances from the second-level cache.
 CachedPC get(Object oid)
          Accessor for an object in the cache.
 Map<Object,CachedPC> getAll(Collection oids)
          Accessor for a collection of objects from the cache.
 int getSize()
          Accessor for the size of the cache.
 boolean isEmpty()
          Accessor for whether the cache is empty
 CachedPC put(Object oid, CachedPC pc)
          Method to add an object to the cache under its id
 void putAll(Map<Object,CachedPC> objs)
          Method to put several objects into the cache.
 
Methods inherited from class org.datanucleus.cache.AbstractLevel2Cache
getNumberOfPinnedObjects, getNumberOfUnpinnedObjects, pin, pinAll, pinAll, pinAll, unpin, unpinAll, unpinAll, unpinAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaxCacheLevel2Cache

public JavaxCacheLevel2Cache(NucleusContext nucleusCtx)
Constructor.

Parameters:
nucleusCtx - Context
Method Detail

close

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


containsOid

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

Parameters:
oid - The object id
Returns:
Whether it is in the cache
See Also:
Level2Cache.containsOid(java.lang.Object)

get

public CachedPC get(Object oid)
Accessor for an object in the cache.

Parameters:
oid - The Object ID
Returns:
The L2 cacheable object
See Also:
Level2Cache.get(java.lang.Object)

getAll

public Map<Object,CachedPC> getAll(Collection oids)
Description copied from interface: Level2Cache
Accessor for a collection of objects from the cache.

Specified by:
getAll in interface Level2Cache
Overrides:
getAll in class AbstractLevel2Cache
Parameters:
oids - The Object IDs
Returns:
Map of the objects, keyed by the oids that are found

getSize

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

Returns:
Number of objects
See Also:
Level2Cache.getSize()

isEmpty

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

Specified by:
isEmpty in interface Level2Cache
Overrides:
isEmpty in class AbstractLevel2Cache
Returns:
Whether it is empty.
See Also:
Level2Cache.isEmpty()

put

public CachedPC put(Object oid,
                    CachedPC pc)
Method to add an object to the cache under its id

Parameters:
oid - The identity
pc - The cacheable object
Returns:
The value previously associated with this oid

putAll

public void putAll(Map<Object,CachedPC> objs)
Description copied from interface: Level2Cache
Method to put several objects into the cache.

Specified by:
putAll in interface Level2Cache
Overrides:
putAll in class AbstractLevel2Cache
Parameters:
objs - Map of cacheable object keyed by its oid.

evict

public void evict(Object oid)
Evict the parameter instance from the second-level cache.

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.


evictAll

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

Parameters:
oids - the object ids of the instance to evict.

evictAll

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

Parameters:
oids - the object ids of the instance to evict.

evictAll

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

Parameters:
pcClass - the class of instances to evict
subclasses - if true, evict instances of subclasses also


Copyright © 2013. All Rights Reserved.