net.captp.jcomm
Class RemoteHandler

java.lang.Object
  |
  +--net.captp.jcomm.RemoteHandler
All Implemented Interfaces:
ProxyHandler
Direct Known Subclasses:
FarHandler, LookupHandler, RemotePromiseHandler

abstract class RemoteHandler
extends Object
implements ProxyHandler

Handles the tail-ends of remote references.

There is a 3x2 taxonomy of RemoteHandlers. The first distinction is between a) handlers in the Imports table (or "imported handlers"), for which the position is positive, b) handlers in the questions table (or "question handlers"), for which the position is negative, and c) the handler of the other side's NonceLocator, for which the position is zero.

The second distinction is between handlers for resolved remote references, represented by the concrete subclass FarHandler, and handlers for remote references that aren't yet resolved, represented by the concrete subclass RemotePromiseHandler. As a special case, the handler at zero for the other side's NonceLocator is a RemotePromiseHandler, since shutdown attempts may cause it to be retargeted at a newly incarnated NonceLocator from the other side, which may have a new identity.

Author:
Mark S. Miller

Field Summary
private  FlexList myBreakageReactors
           
(package private)  CapTPConnection myConn
          Connection to the vat I point into
private  int myPos
          My outgoing position.
(package private)  ProxyResolver myResolver
          The Resolver of our Proxy, which also revives the Proxy on demand.
private  int myWireCount
          Only relevant if myPos > 0.
 
Constructor Summary
(package private) RemoteHandler(CapTPConnection connection, int pos, Object optIdentity)
           
 
Method Summary
(package private)  void countWireRef()
           
(package private)  int getPos()
           
 SealedBox handleOptSealedDispatch(Brand brand)
          How should my ref respond to an __optSealedDispatch request?
 void handleResolution(Object newTarget)
          Enabled: My Ref no longer needs me, as it's become equivalent to newTarget.
 Ref handleSendAll(String verb, Object[] args)
          Enabled: My Ref is asking me to deliver the message to the other side, and return a promise for the result.
 void handleSendAllOnly(String verb, Object[] args)
          Enabled: My Ref is asking me to deliver the message to the other side and ignore the result.
private  Throwable handleWhenBroken(Object reactor)
          Handles this special case separately, so subclasses can override separately.
private  Throwable handleWhenMoreResolved(Object reactor)
          Handles this special case separately, so subclasses can override separately.
 void reactToGC()
          Enabled: One of my Refs was GCed, and I have no current Ref.
 boolean sameConnection(Object other)
          Enabled: Are 'other' and the remote reference handled by 'this' part of the same comm system, and do they both connect to the same remote vat?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.erights.e.elib.ref.ProxyHandler
isFresh
 

Field Detail

myConn

final CapTPConnection myConn
Connection to the vat I point into


myPos

private final int myPos
My outgoing position.

If < 0, in the Questions table. If == 0, the special RemotePromiseHandler for the other side's NonceLocator. If > 0, in the Imports table.


myWireCount

private int myWireCount
Only relevant if myPos > 0. A count for all wire references that we haven't yet accounted for to the other side.


myResolver

final ProxyResolver myResolver
The Resolver of our Proxy, which also revives the Proxy on demand.


myBreakageReactors

private final FlexList myBreakageReactors
Constructor Detail

RemoteHandler

RemoteHandler(CapTPConnection connection,
              int pos,
              Object optIdentity)
Parameters:
connection - The CapTPConnection to communicate via
pos - The Imports or Questions map pos of the object
optIdentity - null, or the sameness identity of the far reference.
Method Detail

handleOptSealedDispatch

public SealedBox handleOptSealedDispatch(Brand brand)
How should my ref respond to an __optSealedDispatch request?

Specified by:
handleOptSealedDispatch in interface ProxyHandler

handleWhenMoreResolved

private Throwable handleWhenMoreResolved(Object reactor)
Handles this special case separately, so subclasses can override separately.

The default implementation up here tries to deliver-only the __whenMoreResolved, but if that throws an exception back at us, ie, if the __whenMoreResolved message seems to be unable to get through, we report a broken reference (broken by that problen) to the reactor as the resolution, and return that problem.


handleWhenBroken

private Throwable handleWhenBroken(Object reactor)
Handles this special case separately, so subclasses can override separately.

The default implementation up here stores the reactor in myBreakageReactors and always returns null.


handleSendAllOnly

public void handleSendAllOnly(String verb,
                              Object[] args)
Description copied from interface: ProxyHandler
Enabled: My Ref is asking me to deliver the message to the other side and ignore the result.

If the underlying transport mechanism is shut down or otherwise not accepting messages, then it should throw a problem explaining why this message wasn't queued.

Specified by:
handleSendAllOnly in interface ProxyHandler

handleSendAll

public Ref handleSendAll(String verb,
                         Object[] args)
Description copied from interface: ProxyHandler
Enabled: My Ref is asking me to deliver the message to the other side, and return a promise for the result.

If the underlying transport mechanism is shut down or otherwise not accepting messages, then it should either throw a problem explaining why this message wasn't queued, or return a reference that's immediately broken by this problem.

Specified by:
handleSendAll in interface ProxyHandler

handleResolution

public void handleResolution(Object newTarget)
Description copied from interface: ProxyHandler
Enabled: My Ref no longer needs me, as it's become equivalent to newTarget.

Specified by:
handleResolution in interface ProxyHandler

reactToGC

public void reactToGC()
Description copied from interface: ProxyHandler
Enabled: One of my Refs was GCed, and I have no current Ref.

Specified by:
reactToGC in interface ProxyHandler

getPos

int getPos()

countWireRef

void countWireRef()

sameConnection

public boolean sameConnection(Object other)
Description copied from interface: ProxyHandler
Enabled: Are 'other' and the remote reference handled by 'this' part of the same comm system, and do they both connect to the same remote vat?

Specified by:
sameConnection in interface ProxyHandler


comments?