|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sage.accpac.sm.GUIDMap
@ThreadSafe public final class GUIDMap
A map between object references and GUIDS to support stateful Internet
operation.
An object of this class holds a map between object references and GUIDS for
those object references. This is to support stateful operation in Internet
operation. Typically a class will use a single static GUIDMap for its
objects. However I am in the process of changing this to the GUIDMap class
holding the singleton.
When a Reference is registered a corresponding textual GUID is returned,
which can be passed around the Internet for example as a cookie or using URL
rewriting. That textual GUID can later be converted back to a Java reference
to the object. Unlike typical Bean-based concepts this technique assumes that
the Java object is to remain in memory; there is no desire to serialise the
object itself nor persist it in a database etc. since typically the object is
large and heavily linked into other objects.
The GUIDs used are reasonably random, based on Marc A. Mnich's RandomGUID.
This reduces the risks of spoofing and other attacks.
The caller provides a Java reference to an Object and requests a GUID for it;
see getGUID(java.lang.Object)
.
At a later time a caller provides the GUID and requests the original object;
see getOfGUID(java.lang.String)
.
From time to time the map will scan itself and will discard any references
that have not been recently requested. This is automatic. To support
different access frequencies getGUID(java.lang.Object)
can be given a non-default
timeout.
The caller may explicitly remove an entry from the map using
removeGUID(java.lang.String)
.
Method Summary | |
---|---|
java.lang.String |
getGUID(java.lang.Object o)
Register the object and return a corresponding GUID. |
static GUIDMap |
getInstance()
Get a reference to the singleton map. |
java.lang.Object |
getOfGUID(java.lang.String g)
Get back the object reference of the given GUID. |
void |
removeGUID(java.lang.String g)
Remove the given GUID from the map. |
void |
run()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final void run()
run
in interface java.lang.Runnable
public java.lang.String getGUID(java.lang.Object o)
getOfGUID(java.lang.String)
at a later time to get back the same reference.
o
- The reference to the object to be remembered.
getOfGUID(java.lang.String)
.public static GUIDMap getInstance()
public java.lang.Object getOfGUID(java.lang.String g)
getGUID(java.lang.Object)
.
g
- The guid returned previously
getGUID(java.lang.Object)
, or a null reference if the guid does not refer
to an object. This may be because the GUID was not as returned, or
because the object has been unregistered due to it not being
accessed recently, or for various other reasons.public void removeGUID(java.lang.String g)
g
- The guid returned previously
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |