org.psepr.jClient
Class LeaseManager

java.lang.Object
  extended by org.psepr.jClient.LeaseManager
All Implemented Interfaces:
EventReceiver, PayloadParser
Direct Known Subclasses:
SimpleLeaseManager

public abstract class LeaseManager
extends java.lang.Object
implements PayloadParser, EventReceiver

The template for a lease manager. The canonical example of a lease manager is the SimpleLeaseManager but this structure lets a user implement complex lease strategies if necessary.

Lease managers have to be loaded with information about the channel they are operating on and then they are started. This process is because creating the lease manager doesn't happen at the same time as the creation of the connection structures for the lease. So, from the lease managers point of view, the steps are:

  1. instance of the LeaseManager is created
  2. LeaseManager is passed to the connection
  3. the connection loads LeaseManager with the connection
  4. LeaseManager.start() is called
  5. the lease manager registers its listeners and sends out the lease
  6. communication happens
  7. eventually LeaseManager.stop() is called

* @author Robert.Adams@intel.com


Constructor Summary
LeaseManager()
           
LeaseManager(PsEPRConnection pConn, java.lang.String chan, java.lang.String type)
           
 
Method Summary
abstract  void forceRenegotiation()
           
 PsEPRConnection getConnection()
           
abstract  boolean getLeaseActive()
           
abstract  java.lang.String getLeaseID()
          Return the unique identifier for the lease
 java.lang.String getNamespace()
           
 java.lang.String getType()
           
 Payload parsePayload(java.lang.String ns, org.xmlpull.v1.XmlPullParser parser)
          Called with a payload to parse.
 boolean receiveEvent(PsEPREvent pE)
          Called to see if I want to process this event.
abstract  void release()
          Release the lease.
 void setConnection(PsEPRConnection conn)
           
abstract  void setLeaseWindow(long xx)
          Set the duration of the lease.
 void setNamespace(java.lang.String ns)
           
 void setType(java.lang.String tp)
           
abstract  void start()
          Start the lease.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeaseManager

public LeaseManager()

LeaseManager

public LeaseManager(PsEPRConnection pConn,
                    java.lang.String chan,
                    java.lang.String type)
Method Detail

getConnection

public PsEPRConnection getConnection()

setConnection

public void setConnection(PsEPRConnection conn)

getType

public java.lang.String getType()

setType

public void setType(java.lang.String tp)

getNamespace

public java.lang.String getNamespace()
Specified by:
getNamespace in interface PayloadParser

setNamespace

public void setNamespace(java.lang.String ns)
Specified by:
setNamespace in interface PayloadParser

getLeaseActive

public abstract boolean getLeaseActive()

setLeaseWindow

public abstract void setLeaseWindow(long xx)
Set the duration of the lease.

Parameters:
xx -

getLeaseID

public abstract java.lang.String getLeaseID()
Return the unique identifier for the lease

Returns:

forceRenegotiation

public abstract void forceRenegotiation()

start

public abstract void start()
Start the lease.


release

public abstract void release()
Release the lease.


parsePayload

public Payload parsePayload(java.lang.String ns,
                            org.xmlpull.v1.XmlPullParser parser)
Called with a payload to parse. If the namespace matches, we should parse it as one of our own.

Specified by:
parsePayload in interface PayloadParser
Parameters:
ns - the namespace specified in the payload element
parser - the parser positioned at the payload element
Returns:
null if namespace is not a lease message otherwise the parsed payload

receiveEvent

public boolean receiveEvent(PsEPREvent pE)
Called to see if I want to process this event. If it's not a lease, it's not for me.

Specified by:
receiveEvent in interface EventReceiver
Parameters:
pE - the event structure
Returns:
false if I didn't process the element