casa.JION.lease
Class Lease

java.lang.Object
  extended by casa.JION.lease.Lease
All Implemented Interfaces:
net.jini.core.lease.Lease

public class Lease
extends java.lang.Object
implements net.jini.core.lease.Lease

The Lease interface defines a type of object that is returned to the lease holder and issued by the lease grantor. Particular instances of the Lease type will be created by the grantors of a lease, and returned to the holder of the lease as part of the return value from a call that allocates a leased resource. The call that requests a leased resource will typically include a requested duration for the lease. If the request is for a particular duration, the lease grantor is required to grant a lease of no more than the requested period of time. A lease may be granted for a period of time shorter than that requested.

Since:
1.0
Author:
Sun Microsystems, Inc.

Field Summary
 
Fields inherited from interface net.jini.core.lease.Lease
ABSOLUTE, ANY, DURATION, FOREVER
 
Constructor Summary
Lease(casa.dodwan.docware.Descriptor desc)
          Instantiates a new lease.
Lease(java.lang.String entryID, long duration)
          Instantiates a new lease.
 
Method Summary
 boolean canBatch(net.jini.core.lease.Lease lease)
          Returns a boolean indicating whether or not the lease given as a parameter can be batched (placed in the same LeaseMap) with the current lease.
 void cancel()
          Used by the lease holder to indicate that it is no longer interested in the resource or information held by the lease.
 net.jini.core.lease.LeaseMap createLeaseMap(long duration)
          Creates a Map object that can contain leases whose renewal or cancellation can be batched, and adds the current lease to that map.
 java.lang.String getEntryID()
          Gets the entry id.
 long getExpiration()
          
 int getSerialFormat()
          Returns the format that will be used to serialize the lease.
 casa.dodwan.docware.Descriptor leaseToDescriptor()
          Lease to descriptor.
static void main(java.lang.String[] args)
          The main method.
 void renew(long duration)
          Used to renew a lease for an additional period of time, specified in milliseconds.
 void setSerialFormat(int format)
          Sets the format to use when serializing the lease.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Lease

public Lease(java.lang.String entryID,
             long duration)
Instantiates a new lease.

Parameters:
entryID - the entry id
duration - the duration

Lease

public Lease(casa.dodwan.docware.Descriptor desc)
Instantiates a new lease.

Parameters:
desc - the desc
Method Detail

canBatch

public boolean canBatch(net.jini.core.lease.Lease lease)
Returns a boolean indicating whether or not the lease given as a parameter can be batched (placed in the same LeaseMap) with the current lease. Whether or not two Lease objects can be batched is an implementation detail determined by the objects.

Specified by:
canBatch in interface net.jini.core.lease.Lease
Parameters:
lease - the Lease to be evaluated
Returns:
a boolean indicating whether or not the lease given as a parameter can be batched (placed in the same LeaseMap) with the current lease

createLeaseMap

public net.jini.core.lease.LeaseMap createLeaseMap(long duration)
Creates a Map object that can contain leases whose renewal or cancellation can be batched, and adds the current lease to that map. The current lease is put in the map with the duration value given by the parameter.

Specified by:
createLeaseMap in interface net.jini.core.lease.Lease
Parameters:
duration - the duration to put into a Long and use as the value for the current lease in the created LeaseMap
Returns:
the created LeaseMap object

getExpiration

public long getExpiration()

Specified by:
getExpiration in interface net.jini.core.lease.Lease

getSerialFormat

public int getSerialFormat()
Returns the format that will be used to serialize the lease.

Specified by:
getSerialFormat in interface net.jini.core.lease.Lease
Returns:
an int representing the serial format value
See Also:
setSerialFormat(int)

cancel

public void cancel()
            throws net.jini.core.lease.UnknownLeaseException,
                   java.rmi.RemoteException
Used by the lease holder to indicate that it is no longer interested in the resource or information held by the lease. If the leased information or resource could cause a callback to the lease holder (or some other object on behalf of the lease holder), the lease grantor should not issue such a callback after the lease has been cancelled. The overall effect of a cancel call is the same as lease expiration, but instead of happening at the end of a pre-agreed duration it happens immediately.

Specified by:
cancel in interface net.jini.core.lease.Lease
Throws:
net.jini.core.lease.UnknownLeaseException - the lease being cancelled is unknown to the lease grantor
java.rmi.RemoteException

renew

public void renew(long duration)
           throws net.jini.core.lease.LeaseDeniedException,
                  net.jini.core.lease.UnknownLeaseException,
                  java.rmi.RemoteException
Used to renew a lease for an additional period of time, specified in milliseconds. This duration is not added to the original lease, but is used to determine a new expiration time for the existing lease. If the renewal is granted this is reflected in value returned by getExpiration. If the renewal fails, the lease is left intact for the same duration that was in force prior to the call to renew.

Specified by:
renew in interface net.jini.core.lease.Lease
Parameters:
duration - the requested duration in milliseconds
Throws:
net.jini.core.lease.LeaseDeniedException - the lease grantor is unable or unwilling to renew the lease
net.jini.core.lease.UnknownLeaseException - the lease being renewed is unknown to the lease grantor
java.rmi.RemoteException

setSerialFormat

public void setSerialFormat(int format)
Sets the format to use when serializing the lease.

Specified by:
setSerialFormat in interface net.jini.core.lease.Lease
Parameters:
format - DURATION or ABSOLUTE
See Also:
getSerialFormat()

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

leaseToDescriptor

public casa.dodwan.docware.Descriptor leaseToDescriptor()
Lease to descriptor.

Returns:
the descriptor

getEntryID

public java.lang.String getEntryID()
Gets the entry id.

Returns:
the entry id

main

public static void main(java.lang.String[] args)
The main method.

Parameters:
args - the arguments