org.javagroups.service.lease
Class LeaseRequestHeader

java.lang.Object
  |
  +--org.javagroups.Header
        |
        +--org.javagroups.service.lease.LeaseRequestHeader
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, java.io.Serializable

public class LeaseRequestHeader
extends Header

Message header that represents lease request. Request has type. Requests for new lease or renew lease contain desired lease duration and entity requesting the lease, cancel requests does not contain lease duration, only entity cancelling lease. Resource identifier is sent as message payload.

Author:
Roman Rokytskyy (rrokytskyy@acm.org)
See Also:
Serialized Form

Field Summary
static int CANCEL_LEASE_REQUEST
           
static java.lang.String HEADER_KEY
           
static int NEW_LEASE_REQUEST
           
static int RENEW_LEASE_REQUEST
           
 
Fields inherited from class org.javagroups.Header
HDR_OVERHEAD
 
Constructor Summary
LeaseRequestHeader()
          Constructs empty header.
LeaseRequestHeader(int headerType, long duration, boolean isAbsolute, java.lang.Object tenant)
          Create lease request header of the specified type with specified duration.
 
Method Summary
 long getDuration()
          Get requested duration of a lease.
 java.lang.Object getTenant()
          Get identifier of an object that requests the lease.
 int getType()
          Get type of lease request.
 boolean isAbsolute()
          Check if duration is relative or absolute.
 void readExternal(java.io.ObjectInput in)
          Read state of this object from object input stream.
 void writeExternal(java.io.ObjectOutput out)
          Write state of this object into object output stream.
 
Methods inherited from class org.javagroups.Header
size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEADER_KEY

public static final java.lang.String HEADER_KEY
See Also:
Constant Field Values

NEW_LEASE_REQUEST

public static final int NEW_LEASE_REQUEST
See Also:
Constant Field Values

RENEW_LEASE_REQUEST

public static final int RENEW_LEASE_REQUEST
See Also:
Constant Field Values

CANCEL_LEASE_REQUEST

public static final int CANCEL_LEASE_REQUEST
See Also:
Constant Field Values
Constructor Detail

LeaseRequestHeader

public LeaseRequestHeader()
Constructs empty header. Only for Externalizable implementation. If object was created using this method, there is no other way to initialize this object except using readExternal(ObjectInput) method.


LeaseRequestHeader

public LeaseRequestHeader(int headerType,
                          long duration,
                          boolean isAbsolute,
                          java.lang.Object tenant)
Create lease request header of the specified type with specified duration.

Method Detail

getType

public int getType()
Get type of lease request.


getDuration

public long getDuration()
Get requested duration of a lease. If type of lease request is CANCEL_LEASE_REQUEST value is ignored.

Returns:
requested duration of lease in milliseconds.

isAbsolute

public boolean isAbsolute()
Check if duration is relative or absolute. If type of lease reques is CANCEL_LEASE_REQUEST value is ignored.

Returns:
true if duration is absolute, otherwise false.

getTenant

public java.lang.Object getTenant()
Get identifier of an object that requests the lease.

Returns:
object identifying entity that requests lease.

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read state of this object from object input stream. Format of data in the stream is:
  1. headerType - int;
  2. duration - long (not applicable for lease ;
  3. isAbsolute - boolean;
  4. tenant - Object.

java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write state of this object into object output stream. Format of data in the stream is:
  1. headerType - int;
  2. duration - long;
  3. isAbsolute - boolean;
  4. tenant - Object.

java.io.IOException


Copyright ? 2001,2002 www.javagroups.com . All Rights Reserved.