org.erights.e.extern.persist
Class SturdyRefMaker

java.lang.Object
  |
  +--org.erights.e.extern.persist.SturdyRefMaker

public class SturdyRefMaker
extends Object

Untamed: Enables one to make SturdyRefs for objects, even if one is in a distributed confinement box.

An instance of the object is accessible in the privileged scope under the name "makeSturdyRef".

An SturdyRefMaker isn't itself Persistent, but the relevant instance is expected to be a scalpel-key, so a persistent object holding a persistent pointer to that SturdyRefMaker will likely revive holding instead an appropriate substitute SturdyRefMaker.

Author:
Mark S. Miller

Field Summary
private  IdentityMgr myIdentityMgr
           
private  Introducer myIntroducer
           
private  FlexMap myOptSwissRetainers
           
private  ValueGuard myPersistenceGuard
           
private  Timer myTimer
           
 
Constructor Summary
SturdyRefMaker(Introducer introducer, Timer timer, IdentityMgr identityMgr, ValueGuard persistenceGuard)
          Enabled:
 
Method Summary
 void __printOn(TextWriter out)
          Enabled:
 Object[] make(Object obj)
          Enabled: optExpirationDate defaults to forever.
 Object[] make(Object obj, long optExpirationDate)
          Enabled: Produce a SturdyRef for a persistence-capable object, thereby making it persistent.
 Runnable onRevival(Object reactor, String verb, Object[] args)
          Enabled: Arrange for reactor to eventually be notified as
 SturdyRef run(Object obj)
          Enabled: Produce a persistent perpetual SturdyRef for an object.
 SturdyRef run(Object obj, long optExpirationDate)
          Enabled: Produce a non-cancellable persistent SturdyRef for an object.
 FlexMap tearOffRoots(FlexMap optOldRoots)
          Enabled: Uses the "tear-off" technique for establishing private shared state between two objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myIntroducer

private final Introducer myIntroducer

myTimer

private final Timer myTimer

myIdentityMgr

private final IdentityMgr myIdentityMgr

myPersistenceGuard

private final ValueGuard myPersistenceGuard

myOptSwissRetainers

private FlexMap myOptSwissRetainers
Constructor Detail

SturdyRefMaker

public SturdyRefMaker(Introducer introducer,
                      Timer timer,
                      IdentityMgr identityMgr,
                      ValueGuard persistenceGuard)
Enabled:

Parameters:
introducer -
timer -
identityMgr -
Method Detail

tearOffRoots

public FlexMap tearOffRoots(FlexMap optOldRoots)
Enabled: Uses the "tear-off" technique for establishing private shared state between two objects.

The "tear-off" tag can only be torn off once, and once it's torn off it's apparent that it is to all those who try to do so.

In this case, the tearing off is supposed to happen by the TimeMachine when it transitions out of the Ephemeral state. Therefore, if a tearOff hasn't happened yet, the code here assumes that we're still in the Ephemeral state and that nothing may be made persistent.

Note: If you want to make something sturdy for purposes of distribution, but not persistent, use IdentityMgr instead. This requires the Introducer to be identified, but is independent of the state of the TimeMachine.

Returns:

run

public SturdyRef run(Object obj)
              throws MalformedURLException
Enabled: Produce a persistent perpetual SturdyRef for an object.

Just run/2 with the optExpirationDate defaulting to forever.

Parameters:
obj - The object for which a SturdyRef is desired
Returns:
A new SturdyRef for the indicated object
MalformedURLException

run

public SturdyRef run(Object obj,
                     long optExpirationDate)
              throws MalformedURLException
Enabled: Produce a non-cancellable persistent SturdyRef for an object.

Equivalent to
make(obj,optExpirationDate)[0].

MalformedURLException

make

public Object[] make(Object obj)
              throws MalformedURLException
Enabled: optExpirationDate defaults to forever.

Parameters:
obj -
Returns:
MalformedURLException

make

public Object[] make(Object obj,
                     long optExpirationDate)
              throws MalformedURLException
Enabled: Produce a SturdyRef for a persistence-capable object, thereby making it persistent.

The SturdyRef will designate the object across time and space, at least until the expiration time, so long as the hosting vat (this vat) is accessible.

Parameters:
obj - The object for which a SturdyRef is desired
optExpirationDate - The date after which the SturdyRef will not longer be guaranteed to be valid. If Long.MAX_VALUE, then it's always valid.
Returns:
A pair of a new SturdyRef for the indicated object and a persistent Runnable for cancelling this persistent sturdiness.
MalformedURLException

onRevival

public Runnable onRevival(Object reactor,
                          String verb,
                          Object[] args)
                   throws MalformedURLException
Enabled: Arrange for reactor to eventually be notified as
    reactor <- verb(args...)
following future revivals.

Once this notification is no longer needed on further revivals, the notification action should use the returned persistent Runnable to cancel them.

Parameters:
reactor -
verb -
args -
Returns:
MalformedURLException

__printOn

public void __printOn(TextWriter out)
               throws IOException
Enabled:

IOException


comments?