public interface PersistitReference extends Serializable
Interface for reference classes used to isolate object references during serialization.
Any subclass of java.lang.ref.Reference
implements this
interface; thus applications can use this interface, but implement it using a
subclasses of java.lang.ref.WeakReference
(for example).
The general problem this interface is intended to solve is to control and reduce the scope of serialization of an object. In a typical application some object A may need to refer to some other object B that has a large graph of connected objects. Using Java's standard serialization mechanism, serializing A also serializes B and all the objects it refers to. This set may be very large, and further, it may be semantically incorrect to serialize the state of B with A because the state of B may change independently of A.
A PersistitReference
may be used to break the serialization
relationship of B to A. Instead of having a field of A directly containing an
instance of B, the field in A would hold a PersistitReference
that in turn refers to B. Implementations of PersistitReference are intended
to implement it in such a way that only a persistent object identifier for B
is stored in the serialized form of the PersistitReference
rather than a fully serialization of B. The get
method is
intended to deserialize (if necessary) and return the object referred to be
that persistent identifier. AbstractReference
provides such an
implementation.
Modifier and Type | Method and Description |
---|---|
Object |
get() |
Object get()
Object
this Reference
refers to,
known as the referent.Copyright © 2025 Open Identity Platform Community. All rights reserved.