com.sun.jini.jeri.internal.runtime
Class ImplRefManager

java.lang.Object
  extended by com.sun.jini.jeri.internal.runtime.ImplRefManager

final class ImplRefManager
extends Object

Manages references to remote object implementations (impls) used by ObjectTable targets. The managed reference for a particular impl is represented by an instance of the inner class ImplRef. All of the targets for current exports of an impl are registered with its ImplRef. This class supports pinning and unpinning of an impl reference by its registered targets (to control whether the reference is strong or weak); automatic, asynchronous invocation of an impl's Unreferenced.unreferenced() method, when appropriate; and asynchronous notifications of all registered targets when a (weakly referenced) impl has been garbage collected.

Author:
Sun Microsystems, Inc.

Nested Class Summary
(package private)  class ImplRefManager.ImplRef
          A managed reference to a remote object implementation (impl).
private  class ImplRefManager.Reaper
          Waits for notifications that weak references in the table have been cleared (and thus referenced impls have been garbage collected).
 
Field Summary
private  boolean interruptible
          true if reaper thread may be interrupted
private  Object lock
          lock guarding all mutable instance state (below).
private static Logger logger
           
private  Thread reaper
          thread to process garbage collected impls
private  ReferenceQueue reapQueue
          queue notified when weak refs to impls are cleared
private  Map<Reference,ImplRefManager.ImplRef> weakImplTable
          maps WeakKey(impl) to ImplRef(WeakKey(impl))
 
Constructor Summary
ImplRefManager()
           
 
Method Summary
(package private)  ImplRefManager.ImplRef getImplRef(Remote impl, Target target)
          Returns the ImplRef for the specified impl (creating it if necessary), registering the supplied target with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final Logger logger

reapQueue

private final ReferenceQueue reapQueue
queue notified when weak refs to impls are cleared


lock

private final Object lock
lock guarding all mutable instance state (below). Note that if both this lock and the lock for an ImplRef instance need to be acquired together, then this lock must be acquired first.


weakImplTable

private final Map<Reference,ImplRefManager.ImplRef> weakImplTable
maps WeakKey(impl) to ImplRef(WeakKey(impl))


reaper

private Thread reaper
thread to process garbage collected impls


interruptible

private boolean interruptible
true if reaper thread may be interrupted

Constructor Detail

ImplRefManager

ImplRefManager()
Method Detail

getImplRef

ImplRefManager.ImplRef getImplRef(Remote impl,
                                  Target target)
Returns the ImplRef for the specified impl (creating it if necessary), registering the supplied target with it. If the target goes away on its own accord (i.e. without the impl getting garbage collected, such as by being unexported), it must invoke the returned ImplRef's release(Target) method passing itself (REMIND: perhaps this requirement could be avoided by using weak reference notifications).



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.