context.arch.discoverer.lease
Class Lease

java.lang.Object
  extended bycontext.arch.discoverer.lease.Lease

public class Lease
extends java.lang.Object

This class keeps information about the lease of a context component when it registers to the discoverer. A lease is defined by the component for a given duration defined as un number of timeslots.

Author:
Agathe
See Also:
context.arch.discoverer.lease.CTKCalendar

Field Summary
protected  java.lang.Integer componentIndex
          The index of the component owning this lease
static int DEFAULT_DURATION
          This constant is the default duration for a component when it does not specify a lease.
protected  java.util.Calendar end
          The date of unregistration of the context component
static java.lang.String LEASE
          This tag is used to encapsulate a lease dataobject
static java.lang.String LEASE_END
          This tag is used by the context component to stop its lease
static java.lang.String LEASE_END_NOTIFICATION
          This tag is used by the discoverer to inform the context component of the end of its lease.
static java.lang.String LEASE_ERROR
          This tag is used to specify an error
static java.lang.String LEASE_RENEWAL
          This tag is used by the context component to extend its lease
protected  int nbRenewal
          The number of lease renewal the context component has done
protected  int nbTimeSlots
          This number specify the duration of the lease as a number of timeslots
protected  java.util.Calendar start
          The date of first registration of the context component
static int TIME_SLOT_MILLIS
          This constant defines the smallest time slot.
static java.lang.String TIMESLOTS
          This tag is used to specify the lease number of time slots
 
Constructor Summary
Lease()
          Creates new Lease with the default duration
Lease(int numberOfTimeSlots)
          Creates new Lease with the specified number of timeslots
 
Method Summary
static Lease dataObjectToLease(DataObject dataObject)
          This method allows to convert a DataObject to a Lease object
 java.lang.Integer getComponentIndex()
          Returns the component index information
 java.util.Calendar getEndDate()
           
 java.util.Calendar getStartDate()
           
 void setComponentIndex(java.lang.Integer index)
          Set the component index information
 void setStartDate()
          This method allows to put the current date/time as the start date of the lease.
 void setStartDate(java.util.Calendar date)
          This method allows to set the start date of the lease and then update the end date
 DataObject toDataObject()
          This method returns the DataObject version of the Lease object
 long toMinutes()
          This method returns the duration of the lease in minutes
 java.lang.String toString()
          Returns a printable version of a Lease object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_DURATION

public static final int DEFAULT_DURATION
This constant is the default duration for a component when it does not specify a lease. 72 corresponds to 12 hours lease

See Also:
Constant Field Values

TIME_SLOT_MILLIS

public static final int TIME_SLOT_MILLIS
This constant defines the smallest time slot. A lease is defined as a multiple of this time slot. This corresponds to 10 minutes.

See Also:
Constant Field Values

LEASE

public static final java.lang.String LEASE
This tag is used to encapsulate a lease dataobject

See Also:
Constant Field Values

LEASE_END_NOTIFICATION

public static final java.lang.String LEASE_END_NOTIFICATION
This tag is used by the discoverer to inform the context component of the end of its lease. Then the component may reply with a lease renewal or accepts the term and returns a LEASE_END.

See Also:
Constant Field Values

LEASE_RENEWAL

public static final java.lang.String LEASE_RENEWAL
This tag is used by the context component to extend its lease

See Also:
Constant Field Values

LEASE_END

public static final java.lang.String LEASE_END
This tag is used by the context component to stop its lease

See Also:
Constant Field Values

TIMESLOTS

public static final java.lang.String TIMESLOTS
This tag is used to specify the lease number of time slots

See Also:
Constant Field Values

LEASE_ERROR

public static final java.lang.String LEASE_ERROR
This tag is used to specify an error

See Also:
Constant Field Values

start

protected java.util.Calendar start
The date of first registration of the context component


end

protected java.util.Calendar end
The date of unregistration of the context component


nbRenewal

protected int nbRenewal
The number of lease renewal the context component has done


componentIndex

protected java.lang.Integer componentIndex
The index of the component owning this lease


nbTimeSlots

protected int nbTimeSlots
This number specify the duration of the lease as a number of timeslots

Constructor Detail

Lease

public Lease()
Creates new Lease with the default duration


Lease

public Lease(int numberOfTimeSlots)
Creates new Lease with the specified number of timeslots

Method Detail

toDataObject

public DataObject toDataObject()
This method returns the DataObject version of the Lease object

Returns:
DataObject The data object version

toString

public java.lang.String toString()
Returns a printable version of a Lease object

Returns:
String The printable version of the object

toMinutes

public long toMinutes()
This method returns the duration of the lease in minutes

Returns:
long The minutes number of the lease

setComponentIndex

public void setComponentIndex(java.lang.Integer index)
Set the component index information

Parameters:
index - The index of the component description owning the lease

getComponentIndex

public java.lang.Integer getComponentIndex()
Returns the component index information

Returns:
Integer The index of the component description owning the lease

setStartDate

public void setStartDate()
This method allows to put the current date/time as the start date of the lease.


setStartDate

public void setStartDate(java.util.Calendar date)
This method allows to set the start date of the lease and then update the end date

Parameters:
date - The Calendar object

getStartDate

public java.util.Calendar getStartDate()

getEndDate

public java.util.Calendar getEndDate()

dataObjectToLease

public static Lease dataObjectToLease(DataObject dataObject)
This method allows to convert a DataObject to a Lease object

Parameters:
dataObject - The dataObject containing lease information
Returns:
Lease The lease object