com.sun.jini.reggie
Class RegistrarLease

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

abstract class RegistrarLease
extends AbstractLease
implements ReferentUuid

The base class for lease proxies.

Author:
Sun Microsystems, Inc.

Field Summary
(package private)  Uuid leaseID
          The internal lease id.
(package private)  ServiceID registrarID
          The registrar's service ID.
private static long serialVersionUID
           
(package private)  Registrar server
          The registrar.
 
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
RegistrarLease(Registrar server, ServiceID registrarID, Uuid leaseID, long expiration)
          Simple constructor.
 
Method Summary
 boolean canBatch(Lease lease)
          Two leases can be batched if they are both RegistrarLeases and have the same server.
 LeaseMap createLeaseMap(long duration)
          Creates a lease map.
 boolean equals(Object obj)
          Returns true if lease Uuids match, false otherwise.
(package private) abstract  String getLeaseType()
          Returns the type of the lease.
 Uuid getReferentUuid()
          Returns the lease Uuid.
(package private) abstract  Object getRegID()
          Returns the service ID, or the event ID as a Long.
(package private)  Registrar getRegistrar()
          Returns the registrar.
(package private)  ServiceID getRegistrarID()
          Returns the registrar's service ID.
 int hashCode()
          Returns the lease Uuid's hash code.
private  void readObject(ObjectInputStream in)
          Reads the default serializable field values for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method.
private  void readObjectNoData()
          Throws InvalidObjectException, since data for this class is required.
(package private)  void setExpiration(long expiration)
          Sets the expiration.
 String toString()
          Returns a string created from the proxy class name, the registrar's service ID, the id of the lessee or event (depending on the subclass), and the result of the underlying server proxy's toString method.
private  void writeObject(ObjectOutputStream out)
          Writes the default serializable field values for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method.
 
Methods inherited from class com.sun.jini.lease.AbstractLease
doRenew, getExpiration, getSerialFormat, renew, setSerialFormat
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.jini.core.lease.Lease
cancel
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

server

final Registrar server
The registrar.


registrarID

transient ServiceID registrarID
The registrar's service ID.


leaseID

final Uuid leaseID
The internal lease id.

Constructor Detail

RegistrarLease

RegistrarLease(Registrar server,
               ServiceID registrarID,
               Uuid leaseID,
               long expiration)
Simple constructor.

Method Detail

createLeaseMap

public LeaseMap createLeaseMap(long duration)
Creates a lease map.

Specified by:
createLeaseMap in interface 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

canBatch

public boolean canBatch(Lease lease)
Two leases can be batched if they are both RegistrarLeases and have the same server.

Specified by:
canBatch in interface 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

getReferentUuid

public Uuid getReferentUuid()
Returns the lease Uuid.

Specified by:
getReferentUuid in interface ReferentUuid
Returns:
the Uuid associated with the resource this proxy represents. Will not return null.

hashCode

public int hashCode()
Returns the lease Uuid's hash code.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Returns true if lease Uuids match, false otherwise.

Overrides:
equals in class Object

toString

public String toString()
Returns a string created from the proxy class name, the registrar's service ID, the id of the lessee or event (depending on the subclass), and the result of the underlying server proxy's toString method.

Overrides:
toString in class Object
Returns:
String

getRegistrar

Registrar getRegistrar()
Returns the registrar.


getRegistrarID

ServiceID getRegistrarID()
Returns the registrar's service ID.


getRegID

abstract Object getRegID()
Returns the service ID, or the event ID as a Long.


getLeaseType

abstract String getLeaseType()
Returns the type of the lease.


setExpiration

void setExpiration(long expiration)
Sets the expiration.


writeObject

private void writeObject(ObjectOutputStream out)
                  throws IOException
Writes the default serializable field values for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method.

Throws:
IOException

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Reads the default serializable field values for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method. Verifies that the deserialized field values are non-null.

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.