one.world.binding
Class LeaseMaintainer

java.lang.Object
  |
  +--one.world.binding.LeaseMaintainer

public class LeaseMaintainer
extends Object

A LeaseMaintainer automatically renews a lease until it is explicitly canceled. The LeaseMaintainer class also includes a static cancel() method that can be used to cancel any lease.

Version:
$Revision: 1.10 $

Inner Class Summary
static class LeaseMaintainer.Cancel
          The event handler for processing lease cancellation.
 
Field Summary
static LeaseMaintainer.Cancel CANCEL
          The event handler for processing lease cancellations.
 
Constructor Summary
LeaseMaintainer(BindingRequest request, EventHandler factory, Timer timer)
          Constructs a new LeaseMaintainer.
LeaseMaintainer(EventHandler lease, long duration, EventHandler notify, Object closure, Timer timer)
          Constructs a new lease maintainer.
 
Method Summary
 void cancel()
          Cancels the lease asynchronously.
static void cancel(EventHandler lease)
          Cancel the lease managed by the specified event handler.
 void cancel(Operation operation)
          Cancels the lease using an operation.
 void cancel(Operation operation, Object closure)
          Cancels the lease using an operation.
protected  void finalize()
          Finalize this lease maintainer.
 EventHandler getLease()
          Gets the lease.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CANCEL

public static final LeaseMaintainer.Cancel CANCEL
The event handler for processing lease cancellations.
Constructor Detail

LeaseMaintainer

public LeaseMaintainer(BindingRequest request,
                       EventHandler factory,
                       Timer timer)
Constructs a new LeaseMaintainer. All events generated in response to the binding request will be passed on to the request source.
Parameters:
request - The binding request for the desired resource.
factory - The event handler to ask for the resource.
timer - A timer component.

LeaseMaintainer

public LeaseMaintainer(EventHandler lease,
                       long duration,
                       EventHandler notify,
                       Object closure,
                       Timer timer)
Constructs a new lease maintainer. The other constructor is prefereable because it has a more conservative idea of when the lease started and thus is more able to keep the lease from expiring. However, this constructor is sometimes necessary.
Parameters:
lease - The lease to maintain.
duration - The initial lease duration.
notify - The event handler to be notified of any exceptions.
closure - The closure to use for any such notifications.
timer - A timer component.
Method Detail

finalize

protected void finalize()
Finalize this lease maintainer.
Overrides:
finalize in class Object

cancel

public void cancel()
Cancels the lease asynchronously.

cancel

public void cancel(Operation operation)
Cancels the lease using an operation. Note that this method sets the Operation.request handler; do not use the operation concurrently for anything else.
Parameters:
operation - The operation to use.

cancel

public void cancel(Operation operation,
                   Object closure)
Cancels the lease using an operation. Note that this method sets the Operation.request handler; do not use the operation concurrently for anything else.
Parameters:
operation - The operation to use.
closure - The closure to use for the lease cancellation event.

getLease

public EventHandler getLease()
Gets the lease.
Returns:
The managed lease.

cancel

public static void cancel(EventHandler lease)
Cancel the lease managed by the specified event handler. This method sends a cancel lease event to the specified event handler managing a lease and asynchronously processes the response.

Calling this method is equivalent to calling

   lease.handle(new
     LeaseEvent(CANCEL, null, LeaseEvent.CANCEL,
                null, null, 0));
 

The specified event handler must be an event handler managing a lease.

Parameters:
lease - The event handler managing the lease to cancel.
See Also:
LeaseMaintainer.Cancel, CANCEL


(C) Copyright 2001 UW CSE