|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.psepr.jClient.ConnectionHandler
public class ConnectionHandler
This class makes a connection to the PsEPR system. It wraps up some of the stuff around retrying and identity defaulting to create a simple connection.
Usual use of this class is:
ConnectionHandler connH = new ConnectionHandler();
connH.setSendService("PsEPRServiceName");
connH.setSendPassword("PsEPRServicePassword);
( or connH.setIdentity(new PsEPRServiceIdentity(params)); )
connH.start();
( optionally connH.monitorConnection(); )
...
LeaseHandler leaseH = new LeaseHandler(connh.getConnection(), ...);
...
connH.stop();
On can directly set the PsEPRServiceIdentity or you can set the
sendService and sendServicePassword and let this routine
build the PsEPRServiceIdentity. If neither are specified, it tries to
get the default service from the PsEPR config files.
It does not create a monitoring lease directly, although one can easily do
it by calling monitorConnection.
The monitorConnection routine can be passed an instance of
LeaseWatcher which will be called if the connection is lost
and cannot be restored.
This monitoring is not needed if the program does any of it's own
lease invocations.
| Constructor Summary | |
|---|---|
ConnectionHandler()
|
|
ConnectionHandler(PsEPRServiceIdentity id)
|
|
ConnectionHandler(java.lang.String srv,
java.lang.String srvPassword)
|
|
| Method Summary | |
|---|---|
PsEPRConnection |
getConnection()
|
PsEPRServiceIdentity |
getIdentity()
|
java.lang.String |
getService()
|
java.lang.String |
getServicePassword()
|
void |
init()
|
boolean |
isConnected()
return true if the PsEPR connectin is up and happy |
boolean |
isShouldMonitor()
|
void |
monitorConnection()
|
void |
monitorConnection(LeaseWatcher watcher)
Called after starting the connection to cause a lease to be added to the connection. |
boolean |
receiveEvent(PsEPREvent pEvent)
class for events on the monitoring channel. |
void |
setConnection(PsEPRConnection connection)
|
void |
setIdentity(PsEPRServiceIdentity identity)
|
void |
setService(java.lang.String sendService)
|
void |
setServicePassword(java.lang.String sendServicePassword)
|
void |
setShouldMonitor(boolean shouldMonitor)
|
void |
start()
Start the connectin to the PsEPR infrastrcuture |
void |
stop()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConnectionHandler()
public ConnectionHandler(java.lang.String srv,
java.lang.String srvPassword)
public ConnectionHandler(PsEPRServiceIdentity id)
| Method Detail |
|---|
public void init()
public PsEPRConnection getConnection()
public void setConnection(PsEPRConnection connection)
public PsEPRServiceIdentity getIdentity()
public void setIdentity(PsEPRServiceIdentity identity)
public java.lang.String getService()
public void setService(java.lang.String sendService)
public java.lang.String getServicePassword()
public void setServicePassword(java.lang.String sendServicePassword)
public boolean isShouldMonitor()
public void setShouldMonitor(boolean shouldMonitor)
public boolean isConnected()
public void start()
throws java.lang.Exception
java.lang.Exceptionpublic void stop()
public void monitorConnection()
public void monitorConnection(LeaseWatcher watcher)
Called after starting the connection to cause a lease to be added to the connection. This causes us to periodically talk to the PsEPR server and make sure it's still alive. If the lease cannot be renewed, the server must be down and we should reconnect to a different server.
A user can either call setShouldMonitor() before or after the connection
is made or can call this function directory after the call to start().
This functionality not needed if the application make it's own leases since it will notice the connection going down.
watcher - called if no connections to the server can be madepublic boolean receiveEvent(PsEPREvent pEvent)
receiveEvent in interface EventReceiverpEvent -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||