Class ManagedReference<T>

java.lang.Object
org.codehaus.groovy.util.ManagedReference<T>
Type Parameters:
T - the referent type
All Implemented Interfaces:
Finalizable

public class ManagedReference<T> extends Object implements Finalizable
Reference wrapper that couples a referent with a ReferenceManager cleanup lifecycle.
  • Constructor Details

    • ManagedReference

      public ManagedReference(ReferenceType type, ReferenceManager rmanager, T value)
      Creates a managed reference using the supplied reference kind and manager.
      Parameters:
      type - the reference implementation to create
      rmanager - the manager that processes collected references
      value - the referent to store
    • ManagedReference

      public ManagedReference(ReferenceBundle bundle, T value)
      Creates a managed reference using the supplied bundle.
      Parameters:
      bundle - the reference bundle describing the type and manager to use
      value - the referent to store
  • Method Details

    • get

      public final T get()
      Returns the current referent.
      Returns:
      the referent, or null if it is no longer available
    • clear

      public final void clear()
      Clears the referent and lets the manager process any queued stale entries.
    • finalizeReference

      public void finalizeReference()
      Performs any cleanup required after the associated reference has been cleared.
      Specified by:
      finalizeReference in interface Finalizable