com.sun.jini.landlord
Class LandlordLeaseMap

java.lang.Object
  extended by com.sun.jini.lease.AbstractLeaseMap
      extended by com.sun.jini.landlord.LandlordLeaseMap
All Implemented Interfaces:
Map, LeaseMap
Direct Known Subclasses:
ConstrainableLandlordLeaseMap

public class LandlordLeaseMap
extends AbstractLeaseMap

Implementation of LeaseMap for LandlordLease.

Since:
2.0
Author:
Sun Microsystems, Inc.
See Also:
LandlordLease, LeaseMap

Field Summary
private  Landlord landlord
          The landlord which this map will talk to.
private  Uuid landlordUuid
          The Uuid of the landlord.
 
Fields inherited from class com.sun.jini.lease.AbstractLeaseMap
map
 
Constructor Summary
LandlordLeaseMap(Landlord landlord, Uuid landlordUuid, Lease lease, long duration)
          Create a new LandlordLeaseMap.
 
Method Summary
 void cancelAll()
          Cancels all leases in the LeaseMap.
 boolean canContainKey(Object key)
          Returns true if the given object is a Lease which can be renewed and cancelled in a batch with other leases in the map.
(package private)  Landlord landlord()
          Return the landlord.
 void renewAll()
          Renews all leases in the LeaseMap, using their current values as the renewal durations.
 
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

landlord

private final Landlord landlord
The landlord which this map will talk to.


landlordUuid

private final Uuid landlordUuid
The Uuid of the landlord. Used to determine if a lease can be placed in this map.

Constructor Detail

LandlordLeaseMap

LandlordLeaseMap(Landlord landlord,
                 Uuid landlordUuid,
                 Lease lease,
                 long duration)
Create a new LandlordLeaseMap.

Parameters:
landlord - Owner of the resource lease is for.
landlordUuid - a universally unique id that has been assigned to the server granting of the lease. Ideally the Uuid landlord.getUuid would return if landlord implemented ReferentUuid. Used to determine when two leases can be batched together.
lease - first lease to be placed in the map. It is assumed that canContainKey(lease) would be true. Must work with the landlord protocol.
duration - the duration the lease should be renewed for if renewAll is called
Throws:
NullPointerException - if landlord or landlordUuid is null.
Method Detail

canContainKey

public boolean canContainKey(Object key)
Description copied from interface: LeaseMap
Returns true if the given object is a Lease which can be renewed and cancelled in a batch with other leases in the map. Whether or not two Lease objects can be batched is an implementation detail determined by the objects.

Parameters:
key - an object that should be a lease
Returns:
true if the lease can be renewed and cancelled in a a batch with other leases
See Also:
Lease.canBatch(net.jini.core.lease.Lease)

cancelAll

public void cancelAll()
               throws LeaseMapException,
                      RemoteException
Description copied from interface: LeaseMap
Cancels all leases in the LeaseMap. If all cancels are successful, returns normally (leaving all leases in the map). Otherwise, removes all leases that failed to cancel from the LeaseMap, and throws LeaseMapException.

Throws:
LeaseMapException
RemoteException

renewAll

public void renewAll()
              throws LeaseMapException,
                     RemoteException
Description copied from interface: LeaseMap
Renews all leases in the LeaseMap, using their current values as the renewal durations. If all renewals are successful, returns normally. Otherwise, removes all leases that failed to renew from the LeaseMap, and throws LeaseMapException.

Throws:
LeaseMapException
RemoteException

landlord

Landlord landlord()
Return the landlord.



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