com.sun.jini.fiddler
Class FiddlerLeaseMap

java.lang.Object
  extended by com.sun.jini.lease.AbstractLeaseMap
      extended by com.sun.jini.fiddler.FiddlerLeaseMap
All Implemented Interfaces:
Map, LeaseMap
Direct Known Subclasses:
FiddlerLeaseMap.ConstrainableFiddlerLeaseMap

 class FiddlerLeaseMap
extends AbstractLeaseMap

When clients request a registration with the Fiddler implementation of the lookup discovery service, leases of type FiddlerLease are granted on those registrations. Under certain circumstances it may be desirable to collect multiple granted leases in a set which implements the net.jini.core.lease.LeaseMap interface.

This class is the implementation class of the LeaseMap interface that is employed by the Fiddler implementation of the lookup discovery service. When a client wishes to "batch" leases granted by that service, the are placed in an instance of this class.

Clients only see instances of this class via the LeaseMap interface.

Author:
Sun Microsystems, Inc.

Nested Class Summary
(package private) static class FiddlerLeaseMap.ConstrainableFiddlerLeaseMap
          The constrainable version of the class FiddlerLeaseMap.
 
Field Summary
(package private)  Fiddler server
          The reference to the back-end server of the lookup discovery service
(package private)  Uuid serverID
          The unique ID associated with the server referenced in this class (used to compare server references).
 
Fields inherited from class com.sun.jini.lease.AbstractLeaseMap
map
 
Constructor Summary
private FiddlerLeaseMap(Fiddler server, FiddlerLease lease, long duration)
          Constructs a new instance of FiddlerLeaseMap.
 
Method Summary
 void cancelAll()
          Cancels all leases in this map.
 boolean canContainKey(Object key)
          Examines the input parameter to determine if that parameter will be accepted or rejected by this map as a "legal" key value.
(package private) static FiddlerLeaseMap createLeaseMap(FiddlerLease lease, long duration)
          Static factory method that creates and returns an instance of FiddlerLeaseMap.
 void renewAll()
          Renews all leases in this map.
 
Methods inherited from class com.sun.jini.lease.AbstractLeaseMap
checkKey, checkValue, clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

final Fiddler server
The reference to the back-end server of the lookup discovery service


serverID

final Uuid serverID
The unique ID associated with the server referenced in this class (used to compare server references).

Constructor Detail

FiddlerLeaseMap

private FiddlerLeaseMap(Fiddler server,
                        FiddlerLease lease,
                        long duration)
Constructs a new instance of FiddlerLeaseMap.

Parameters:
server - reference to the server object through which communication occurs between the client-side and server-side of the associated service.
lease - reference to a lease to add to the map as a key value
duration - the duration of the corresponding lease. This value is the "mapped" value corresponding to the lease key.
Method Detail

createLeaseMap

static FiddlerLeaseMap createLeaseMap(FiddlerLease lease,
                                      long duration)
Static factory method that creates and returns an instance of FiddlerLeaseMap. If the lease input to this method is and instance of ConstrainableFiddlerLease, then the object returned by this method will be an instance of ConstrainableFiddlerLeaseMap. Note that because of the way the Lease class for the associated service is implemented, together with the way the canBatch method of that class is implemented, if the lease object input to this method implements ConstrainableFiddlerLease, then the server object referenced in this class will implement RemoteMethodControl as well.

Parameters:
lease - reference to a lease to add to the map as a key value
duration - the duration of the corresponding lease. This value is the "mapped" value corresponding to the lease key.
Returns:
an instance of FiddlerLeaseMap, or an instance of ConstrainableFiddlerLeaseMap if the given lease is an instance of ConstrainableFiddlerLease.

canContainKey

public boolean canContainKey(Object key)
Examines the input parameter to determine if that parameter will be accepted or rejected by this map as a "legal" key value.

This method will return true if the key parameter is the type of lease which can be "batch-wise" renewed and cancelled along with all of the other leases in the map.

For the Fiddler implementation of the lookup discovery service, two leases can be batched (placed in the same FiddlerLeaseMap) if they are both instances of FiddlerLease and they were both granted by the same Fiddler implementation of the lookup discovery service. That is, they are the same type, and they were granted by the same server.

Parameters:
key - reference to the object that this method examines to determine if this map will accept or reject it as a key
Returns:
true if this map will accept the key parameter, false otherwise
See Also:
Lease.canBatch(net.jini.core.lease.Lease)

renewAll

public void renewAll()
              throws LeaseMapException,
                     RemoteException
Renews all leases in this map. For each lease (key) in the map, the duration used to renew the lease is the lease's corresponding map value. If all renewal attempts are successful, this method returns normally; otherwise, this method removes from this map all leases that could not be renewed, and throws a LeaseMapException.

Throws:
LeaseMapException - this exception is thrown when one or more leases in the map could not be renewed.
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server. When this exception does occur, the leases in the map may or may not have been renewed successfully.

cancelAll

public void cancelAll()
               throws LeaseMapException,
                      RemoteException
Cancels all leases in this map. If all cancellation attempts are successful, this method returns normally; otherwise, this method removes from this map all leases that could not be cancelled, and throws a LeaseMapException.

Note that a lease is removed from this map only when an attempt to cancel it fails; that is, every lease that is successfully cancelled is left in the map.

Throws:
LeaseMapException - this exception is thrown when one or more leases in the map could not be cancelled.
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server. When this exception does occur, the leases in the map may or may not have been cancelled successfully.


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