public abstract class AbstractWeakReference extends Object implements PersistitReference
An abstract superclass for implementations of PersistitReference
that
implement weak reference semantics. A concrete subclass implements the
method:
which should return the Object associated with the supplied id, orpublic Object lookup(Object id)
null
if there is none. The meaning of the identifier, and the
mechanism used to look up and deserialize the associated object (the
referent), are implementation-specific.
This implementation differs from AbstractReference
in that the
referent object is referenced through a
java.lang.ref.WeakReference
. Thus the garbage collector may
choose to discard the referent value, in which case the get
method will simply look it up again on demand.
Modifier and Type | Field and Description |
---|---|
protected Object |
_id |
protected boolean |
_knownNull |
protected WeakReference |
_weakReference |
Modifier | Constructor and Description |
---|---|
protected |
AbstractWeakReference()
No-arg constructor supplied for object serialization/deserialization.
|
protected |
AbstractWeakReference(Object id)
Construct a reference using the persistent identity of an object.
|
protected |
AbstractWeakReference(Object id,
Object referent)
Construct a reference to the referent Object with the supplied persistent
identifier.
|
Modifier and Type | Method and Description |
---|---|
Object |
get()
Gets the referent object.
|
protected abstract Object |
lookup(Object id)
Look up and instantiate an object using its persistent identifier.
|
protected Object _id
protected transient WeakReference _weakReference
protected boolean _knownNull
protected AbstractWeakReference()
protected AbstractWeakReference(Object id, Object referent)
lookup
on the
persistent identifier. the object that would be returned by the lookupid
- The persistent identifier. The value of the id must be
associated with a unique referent object, and must be stable
over time.referent
- The object identified by the idprotected AbstractWeakReference(Object id)
get
method will cause the
object to be looked up and instantiated.id
- public Object get()
get
in interface PersistitReference
Copyright © 2025 Open Identity Platform Community. All rights reserved.