|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.psepr.jClient.LeaseHandler
public class LeaseHandler
Create a single lease and keep an eye on it and call back if it fails.
When one calls for a lease, it may take a while to aquire same and, later, the connectin could drop or the server could not be replying to the lease so the application must take some action.
Using this routine to create a lease also creates a watcher thread that keeps checking to make sure the lease is still alive. If the lease goes inactive, the PsEPR connection is forced to reconnect and the lease will get renegotiated.
If the lease cannot be restored, an optional routine that implements the
LeaseWatcher interface is called with an error string.
Code using this routine looks like:
// pConn == an aquired PsEPRConnection (seePsEPRConnectionLeaseHandler inLease = null; try { // get some parser for the payloads PayloadParser xParser = new PayloadGeneric(); // ask for the lease (notice noLeaseManagerspecified inLease = new LeaseHandler(pConn, "/", xParser, eQueue, null); // wait for the lease to be active inLease.waitForLease(); } catch (PsEPRException e) { System.out.println("GetLease failed:"+e.toString()); pConn.close(); return; } catch (Exception e) { // who knows why this would ever happen System.out.println("GetLease exception:"+e.toString()); pConn.close(); return; }
| Constructor Summary | |
|---|---|
LeaseHandler()
|
|
LeaseHandler(PsEPRConnection con,
java.lang.String chan,
PayloadParser pp,
EventReceiver eq,
LeaseWatcher lw)
|
|
| Method Summary | |
|---|---|
void |
connect()
Do a manual connect after setting all the correct parameters |
void |
disconnect()
Disconnect the lease from the connection |
java.lang.String |
getChannel()
|
PsEPRConnection |
getConnection()
|
EventReceiver |
getEventReceiver()
|
PsEPRLease |
getLease()
|
LeaseWatcher |
getLeaseWatcher()
|
PayloadParser |
getPayloadParser()
|
void |
setChannel(java.lang.String xx)
|
void |
setConnection(PsEPRConnection xx)
|
void |
setEventReceiver(EventReceiver xx)
|
void |
setLeaseWatcher(LeaseWatcher xx)
|
void |
setPayloadParser(PayloadParser xx)
|
void |
waitForLease()
Wait until the lease is active. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LeaseHandler()
public LeaseHandler(PsEPRConnection con,
java.lang.String chan,
PayloadParser pp,
EventReceiver eq,
LeaseWatcher lw)
throws PsEPRException
PsEPRException| Method Detail |
|---|
public PsEPRConnection getConnection()
public void setConnection(PsEPRConnection xx)
public java.lang.String getChannel()
public void setChannel(java.lang.String xx)
public PayloadParser getPayloadParser()
public void setPayloadParser(PayloadParser xx)
public EventReceiver getEventReceiver()
public void setEventReceiver(EventReceiver xx)
public LeaseWatcher getLeaseWatcher()
public void setLeaseWatcher(LeaseWatcher xx)
public PsEPRLease getLease()
public void connect()
throws PsEPRException
PsEPRExceptionpublic void disconnect()
public void waitForLease()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||