|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.cache.DefaultLevel2Cache
public class DefaultLevel2Cache
Default implementation of a Level 2 cache for JPOX.
Operates with 2 maps internally. One stores all pinned objects that have been selected to be retained by user's application. The other stores all other objects. This second map is the default location where objects are placed when being added here. The second (unpinned) map stores weak references meaning that they can get garbage collected as necessary by the JVM.
Maintains collections of the classes and the identities that are to be pinned if they ever are put into the cache. These are defined by the pinAll(), pin() methods.
All mutating methods, and the get method have been synchronized to prevent conflicts.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jpox.cache.Level2Cache |
|---|
Level2Cache.PinnedClass |
| Nested classes/interfaces inherited from interface javax.jdo.datastore.DataStoreCache |
|---|
javax.jdo.datastore.DataStoreCache.EmptyDataStoreCache |
| Field Summary | |
|---|---|
protected java.util.Map |
pinnedCache
Pinned objects cache. |
protected java.util.Collection |
pinnedClasses
Collection of pinned classes whose objects should be pinned if they ever reach the cache. |
protected java.util.Collection |
pinnedIds
Collection of ids whose objects should be pinned if they ever reach the cache. |
protected java.util.Map |
unpinnedCache
Unpinned objects cache. |
| Constructor Summary | |
|---|---|
protected |
DefaultLevel2Cache()
Constructor. |
|
DefaultLevel2Cache(java.util.Properties props)
Constructor. |
| Method Summary | |
|---|---|
void |
clear()
Method to clear the cache. |
boolean |
containsOid(java.lang.Object oid)
Method to check if an object with the specified id is in the cache |
void |
evict(java.lang.Object oid)
Method to evict an object from the cache. |
void |
evictAll()
Method to evict all objects from the L2 cache. |
void |
evictAll(java.lang.Class pcClass,
boolean subclasses)
Method to evict all objects of the given types from the cache. |
void |
evictAll(java.util.Collection oids)
Method to evict the objects with the specified ids. |
void |
evictAll(java.lang.Object[] oids)
Method to evict the objects with the specified ids. |
CachedPC |
get(java.lang.Object oid)
Accessor for an object from the cache. |
int |
getNumberOfPinnedObjects()
Accessor for the number of pinned objects in the cache. |
int |
getNumberOfUnpinnedObjects()
Accessor for the number of unpinned objects in the cache. |
int |
getSize()
Accessor for the total number of objects in the L2 cache. |
boolean |
isEmpty()
Accessor for whether the cache is empty. |
void |
pin(java.lang.Object oid)
Method to pin an object to the cache. |
void |
pinAll(java.lang.Class cls,
boolean subs)
Method to pin all objects of the given types. |
void |
pinAll(java.util.Collection oids)
Method to pin all of the supplied objects |
void |
pinAll(java.lang.Object[] oids)
Method to pin all of the supplied objects |
CachedPC |
put(java.lang.Object oid,
CachedPC pc)
Method to put an object in the cache. |
void |
unpin(java.lang.Object oid)
Method to unpin an object |
void |
unpinAll(java.lang.Class cls,
boolean subs)
Method to unpin all objects of the specified types. |
void |
unpinAll(java.util.Collection oids)
Method to unpin all of the supplied objects |
void |
unpinAll(java.lang.Object[] oids)
Method to unpin all of the specified objects |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Collection pinnedClasses
protected java.util.Collection pinnedIds
protected java.util.Map pinnedCache
protected java.util.Map unpinnedCache
| Constructor Detail |
|---|
protected DefaultLevel2Cache()
public DefaultLevel2Cache(java.util.Properties props)
props - Any properties to control the cache| Method Detail |
|---|
public void evict(java.lang.Object oid)
evict in interface javax.jdo.datastore.DataStoreCacheoid - The id of the object to evictpublic void evictAll()
evictAll in interface javax.jdo.datastore.DataStoreCache
public void evictAll(java.lang.Class pcClass,
boolean subclasses)
evictAll in interface javax.jdo.datastore.DataStoreCachepcClass - The class to evictsubclasses - Whether to also evict subclassespublic void evictAll(java.util.Collection oids)
evictAll in interface javax.jdo.datastore.DataStoreCacheoids - The ids of the objects to evictpublic void evictAll(java.lang.Object[] oids)
evictAll in interface javax.jdo.datastore.DataStoreCacheoids - The ids of the objects to evictpublic void pin(java.lang.Object oid)
pin in interface javax.jdo.datastore.DataStoreCacheoid - The id of the object to pin
public void pinAll(java.lang.Class cls,
boolean subs)
pinAll in interface javax.jdo.datastore.DataStoreCachecls - The classsubs - Whether to include subclassespublic void pinAll(java.util.Collection oids)
pinAll in interface javax.jdo.datastore.DataStoreCacheoids - The Object ids to pinpublic void pinAll(java.lang.Object[] oids)
pinAll in interface javax.jdo.datastore.DataStoreCacheoids - The object ids to pinpublic void unpin(java.lang.Object oid)
unpin in interface javax.jdo.datastore.DataStoreCacheoid - The object id
public void unpinAll(java.lang.Class cls,
boolean subs)
unpinAll in interface javax.jdo.datastore.DataStoreCachecls - Base classsubs - Whether to include subclassespublic void unpinAll(java.util.Collection oids)
unpinAll in interface javax.jdo.datastore.DataStoreCacheoids - The object ids to unpinpublic void unpinAll(java.lang.Object[] oids)
unpinAll in interface javax.jdo.datastore.DataStoreCacheoids - The object ids to unpinpublic void clear()
clear in interface Level2Cachepublic CachedPC get(java.lang.Object oid)
get in interface Level2Cacheoid - The Object ID
public int getNumberOfPinnedObjects()
getNumberOfPinnedObjects in interface Level2Cachepublic int getNumberOfUnpinnedObjects()
getNumberOfUnpinnedObjects in interface Level2Cachepublic int getSize()
getSize in interface Level2Cache
public CachedPC put(java.lang.Object oid,
CachedPC pc)
put in interface Level2Cacheoid - The Object id for this objectpc - The cacheable object
public boolean containsOid(java.lang.Object oid)
containsOid in interface Level2Cacheoid - The object ID
public boolean isEmpty()
isEmpty in interface Level2Cache
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||