com.sun.jini.reggie
Class ServiceLease

java.lang.Object
  extended by com.sun.jini.lease.AbstractLease
      extended by com.sun.jini.reggie.RegistrarLease
          extended by com.sun.jini.reggie.ServiceLease
All Implemented Interfaces:
Serializable, Lease, ReferentUuid
Direct Known Subclasses:
ConstrainableServiceLease

 class ServiceLease
extends RegistrarLease

A ServiceLease is a proxy for a service registration lease at a registrar. Clients only see instances via the Lease interface.

Author:
Sun Microsystems, Inc.

Field Summary
private static String LEASE_TYPE
          The type of the lease used in toString() calls.
private static long serialVersionUID
           
(package private)  ServiceID serviceID
          The service id assigned at registration.
 
Fields inherited from class com.sun.jini.reggie.RegistrarLease
leaseID, registrarID, server
 
Fields inherited from class com.sun.jini.lease.AbstractLease
expiration, serialFormat
 
Fields inherited from interface net.jini.core.lease.Lease
ABSOLUTE, ANY, DURATION, FOREVER
 
Constructor Summary
ServiceLease(Registrar server, ServiceID registrarID, ServiceID serviceID, Uuid leaseID, long expiration)
          Constructor for use by getInstance(), ConstrainableServiceLease.
 
Method Summary
 void cancel()
          Used by the lease holder to indicate that it is no longer interested in the resource or information held by the lease.
protected  long doRenew(long duration)
          Do the actual renew.
(package private) static ServiceLease getInstance(Registrar server, ServiceID registrarID, ServiceID serviceID, Uuid leaseID, long expiration)
          Returns ServiceLease or ConstrainableServiceLease instance, depending on whether given server implements RemoteMethodControl.
(package private)  String getLeaseType()
          Returns the type of the lease.
(package private)  Object getRegID()
          Returns the service ID, or the event ID as a Long.
(package private)  ServiceID getServiceID()
          Returns the service ID
private  void readObject(ObjectInputStream in)
          Reads the service ID, encoded as specified by the ServiceID.writeBytes method.
private  void readObjectNoData()
          Throws InvalidObjectException, since data for this class is required.
private  void writeObject(ObjectOutputStream out)
          Writes the service ID, encoded as specified by the ServiceID.writeBytes method.
 
Methods inherited from class com.sun.jini.reggie.RegistrarLease
canBatch, createLeaseMap, equals, getReferentUuid, getRegistrar, getRegistrarID, hashCode, setExpiration, toString
 
Methods inherited from class com.sun.jini.lease.AbstractLease
getExpiration, getSerialFormat, renew, setSerialFormat
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

LEASE_TYPE

private static final String LEASE_TYPE
The type of the lease used in toString() calls.

See Also:
Constant Field Values

serviceID

transient ServiceID serviceID
The service id assigned at registration.

Constructor Detail

ServiceLease

ServiceLease(Registrar server,
             ServiceID registrarID,
             ServiceID serviceID,
             Uuid leaseID,
             long expiration)
Constructor for use by getInstance(), ConstrainableServiceLease.

Method Detail

getInstance

static ServiceLease getInstance(Registrar server,
                                ServiceID registrarID,
                                ServiceID serviceID,
                                Uuid leaseID,
                                long expiration)
Returns ServiceLease or ConstrainableServiceLease instance, depending on whether given server implements RemoteMethodControl.


cancel

public void cancel()
            throws UnknownLeaseException,
                   RemoteException
Description copied from interface: Lease
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.

Throws:
UnknownLeaseException - the lease being cancelled is unknown to the lease grantor
RemoteException

doRenew

protected long doRenew(long duration)
                throws UnknownLeaseException,
                       RemoteException
Do the actual renew.

Specified by:
doRenew in class AbstractLease
Throws:
UnknownLeaseException
RemoteException

getServiceID

ServiceID getServiceID()
Returns the service ID


getRegID

Object getRegID()
Description copied from class: RegistrarLease
Returns the service ID, or the event ID as a Long.

Specified by:
getRegID in class RegistrarLease

getLeaseType

String getLeaseType()
Description copied from class: RegistrarLease
Returns the type of the lease.

Specified by:
getLeaseType in class RegistrarLease

writeObject

private void writeObject(ObjectOutputStream out)
                  throws IOException
Writes the service ID, encoded as specified by the ServiceID.writeBytes method.

Throws:
IOException

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Reads the service ID, encoded as specified by the ServiceID.writeBytes method.

Throws:
IOException
ClassNotFoundException

readObjectNoData

private void readObjectNoData()
                       throws ObjectStreamException
Throws InvalidObjectException, since data for this class is required.

Throws:
ObjectStreamException


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