Class java.lang.Ref
All Packages This Package Previous Next
Class java.lang.Ref
java.lang.Object
|
+----java.lang.Ref
-
public class
Ref
-
extends Object
A "Ref" is an indirect reference to an object that the garbage collector
knows about. The application overrides the reconstitute() method with one
that will construct the object based on information in the Ref, often by
reading from a file. The get() method retains a cache of the last call to
reconstitute() in the Ref. When space gets tight, the garbage collector
will clear old Ref cache entries when there are no other pointers to the
object.
-
Version:
-
1.5, 16 Feb 1995
-
Ref()
-
Constructs a new Ref.
-
check()
-
-
flush()
-
Flushes the cached object.
-
get()
-
Returns a pointer to the object referenced by this Ref.
-
reconstitute()
-
Returns a pointer to the object referenced by this ref by
reconstituting it from some external source.
-
setThing(Object)
-
Ref
public Ref()
-
Constructs a new Ref.
get
public Object get()
-
Returns a pointer to the object referenced by this Ref. If the object
has been thrown away by the garbage collector, it will be
reconstituted. Does everything necessary to ensure that the garbage
collector throws things away in LRU order. Applications should never
need to override this method. get() effectively caches calls to
reconstitute().
reconstitute
public abstract Object reconstitute()
-
Returns a pointer to the object referenced by this ref by
reconstituting it from some external source. It shouldn't bother with
caching since get() will deal with that.
In normal usage, Ref will always be subclassed. The subclass will add
the instance variables necessary for reconstitute() to work. It will
also add a constructor to set them up, and write a version of
reconstitute().
flush
public void flush()
-
Flushes the cached object. Forces the next invocation of get() to
invoke reconstitute().
setThing
public void setThing(Object thing)
check
public Object check()
All Packages This Package Previous Next