|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.fc.cache.ReferenceCache
The ReferenceCache
uses a cache table to configure
Persistable
-to-Cache
mappings. At a minimum,
service.properties
should could contain the following:
wt.services/rsc/default/ObjectReferenceCacheTable/null/wt.admin.AdministrativeDomain/0=DomainCache
wt.services/rsc/default/ObjectReferenceCacheTable/null/wt.fc.Persistable/0=DefaultCache
wt.services/rsc/default/ObjectReferenceCacheTable/null/wt.inf.container.WTContainer/5=ContainerCache
wt.services/rsc/default/ObjectReferenceCacheTable/ReportInterval/null/0=0
wt.services/rsc/default/ObjectReferenceCacheTable/Size/null/0=200
Supported API: false
Extendable: false
Nested Class Summary | |
static class |
ReferenceCache.ObjectReferenceCacheMessenger
Signals remote method servers of a modified Persistable by
istening for changes to the local cache |
(package private) class |
ReferenceCache.ObjectReferenceCacheTable
An extension of CacheTable that maintains a mapping of
Long oids to their corresponding cache. |
private static class |
ReferenceCache.RemotePlaceholder
A utility class that allows the cache to signal whether a remote call is necessary when an object is added to the local cache |
private static class |
ReferenceCache.Singleton
Provides thread-safe lazy initialization of the cache |
Field Summary | |
private ReferenceCache.ObjectReferenceCacheTable |
cacheTable
Maintains the local caches of Persistable s |
private static String |
CLASSNAME
|
private static boolean |
DEBUG
|
private static DebugWriter |
LOG
|
private ReferenceCache.ObjectReferenceCacheMessenger |
messenger
Local instance of the messenger, that registers with the local caches |
private ReferenceResolver |
resolver
Used to determine what the subtypes of CachedObjectReference are |
Constructor Summary | |
private |
ReferenceCache()
Called from the thread-safe Singleton static initializer |
Method Summary | |
void |
clear()
Clears the contents of this cache. |
protected Persistable |
get(CachedObjectReference ref)
Retrieves the Persistable for the given object
reference |
static ReferenceCache |
getInstance()
Returns a reference to the cache instance |
Persistable |
getLocal(ObjectIdentifier oid)
Retrieves the Persistable for the given object identifier,
IFF the persistable is currently cached |
boolean |
isTarget(Class c)
Determines if the given persistable class should be cached by the reference cache |
void |
remove(ObjectIdentifier oid)
Notifies the cache that the given ObjectIdentifier has been removed. |
void |
remove(Persistable target)
Notifies the cache that the given Persistable has been removed. |
void |
remove(WTCollection targets)
Notifies the cache that the given collection of ObjectIdentifier
objects have been removed. |
void |
update(Persistable target)
Notifies the cache that the given Persistable has been updated. |
void |
update(Persistable copy,
Persistable read_only)
Updates the given Persistable , iff read_only
still maps to the object's oid when the transaction commits. |
void |
update(WTCollection targets)
Notifies the cache that the given collection of Persistables have been updated. |
private void |
update(WTCollection targets,
boolean local)
Private method used by both flavors of update |
void |
updateLocal(WTCollection targets)
Notifies the cache that the given collection of Persistables have been updated. |
protected void |
writeContents(Writer w)
Prints debug information to the writer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String CLASSNAME
private static final boolean DEBUG
private static final DebugWriter LOG
private final ReferenceResolver resolver
private final ReferenceCache.ObjectReferenceCacheMessenger messenger
private final ReferenceCache.ObjectReferenceCacheTable cacheTable
Persistable
s
Constructor Detail |
private ReferenceCache()
Method Detail |
public static final ReferenceCache getInstance()
public Persistable getLocal(ObjectIdentifier oid) throws WTException
Persistable
for the given object identifier,
IFF the persistable is currently cached
WTException
protected Persistable get(CachedObjectReference ref) throws WTException
Persistable
for the given object
reference
Persistable
WTException
public void update(Persistable target) throws WTException
Persistable
has been updated.
The cache will maintain a thread-local copy of the Persistable
until the current transaction is committed or rolled back
WTException
public void update(WTCollection targets) throws WTException
Persistables
have been updated.
The cache will maintain thread-local copies of the Persistable
objects
until the current transaction is committed or rolled back
WTException
public void updateLocal(WTCollection targets) throws WTException
Persistables
have been updated.
The cache will maintain thread-local copies of the Persistable
objects
until the current transaction is committed or rolled back
Unlike update
, remote caches are not signaled by this method.
Remote caches don't need to be signaled if we just want to ensure
that the object is in the local cache, or that the in-memory
state of the object is up to date.
WTException
private void update(WTCollection targets, boolean local) throws WTException
targets
- local
-
WTException
public boolean isTarget(Class c)
c
- The persistable class that you want to find out
whether or not it should be cached
public void update(Persistable copy, Persistable read_only) throws WTException
Persistable
, iff read_only
still maps to the object's oid when the transaction commits. This can be
used to keep an object's in-memory non-persistent state safely cached as
follows:
ObjectIdentifier oid = getOidOfObjectToUpdate();
// use appropriate subclass constructor
CachedObjectReference ref = CacheObjectReference.newCachedObjectReference(oid);
// call getReadOnly -before- calling getObject.
// otherwise, getReadOnly returns the cloned result of getObject
Persistable read_only = ref.getReadOnlyObject();
Persistable copy = ref.getObject();
// copy any nonpersistent state from the read only obj to the copy
copy.nonPersistentState = read_only.nonPersistentState;
// now update the copy's non-persistent state
copy.nonPersistentState += updateNonPersistentState();
// finally, update the cache as long as another thread hasn't
// added a new version of the read only object
ReferenceCache.getInstance().update(copy, read_only);
WTException
public void remove(Persistable target) throws WTException
Persistable
has been removed.
The cache will maintain thread-local knowledge of the remove
until the current transaction is committed or rolled back
WTException
public void remove(ObjectIdentifier oid) throws WTException
ObjectIdentifier
has been removed.
The cache will maintain thread-local knowledge of the remove
until the current transaction is committed or rolled back
WTException
public void remove(WTCollection targets) throws WTException
ObjectIdentifier
objects have been removed. The cache will maintain thread-local knowledge of the remove
until the current transaction is committed or rolled back
WTException
protected void writeContents(Writer w) throws IOException
IOException
public void clear() throws WTException
WTException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |