|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.psepr.jClient.PsEPRConnection
public class PsEPRConnection
Connection to the PsEPR infrastructure.
There are several parameters needed to build an active connection:
PsEPRServiceIdentity pServiceID = new PsEPRServiceIdentity();
try {
if ((fromService == null) || (fromServicePassword == null)) {
if (verbose > 0 ) {
System.out.println("Using configuration default service/password");
}
pServiceID.useDefaultIdentity();
}
else {
pServiceID.setSimpleIdentity(fromService, fromServicePassword);
}
}
catch (Exception e) {
System.out.println("Could not create identity -- either params bad or default service in param file is bad.");
return;
}
try {
pConn = new PsEPRConnection(pServiceID);
}
catch (Exception e) {
pConn = null;
System.out.println("PsEPRConnection exception: "+e.toString());
}
if (pConn == null) {
System.out.println("Connection failed");
return;
}
...
myPCon.disconnect();
If there are more parameters that an application wants to set up, the calling sequence can be:
PsEPRServiceIdentity SI = new PsEPRServiceIdentity(serviceName, servicePassword);
try {
PsEPRConnection myPCon = new PsEPRConnection();
myPCon.setIdentity(SI);
myPCon.setInstance(instance);
...
myPCon.connect();
}
catch (PsEPRException e) {
// connection failed
}
...
myPCon.disconnect();
Once the connection is successfully created, leases and other actions are available.
PayloadParser myPP = new myClassImplementingPayloadParser(); EventReceiver myPR = new myClassImplementingEventReceiver(); myPLease = myPCon.getLease(channelName, myPP, myQM); ... myPConn.releaseLease(myPLease);
| Field Summary | |
|---|---|
java.lang.String |
connectionStateClosed
|
java.lang.String |
connectionStateConnected
|
java.lang.String |
connectionStateConnecting
|
java.lang.String |
connectionStateDisconnected
|
java.lang.String |
connectionStateInstantiated
|
java.lang.String |
connectionStateReconnecting
|
int |
connectionTimeout
|
boolean |
isConnected
|
int |
reconnectionRetries
|
int |
reconnectionRetriesLeft
|
| Constructor Summary | |
|---|---|
PsEPRConnection()
Create a new, unconnected connection. |
|
PsEPRConnection(PsEPRServiceIdentity servID)
Create a connection by creating a random instance string. |
|
PsEPRConnection(PsEPRServiceIdentity servID,
java.lang.String instanceName)
Create a connection with the basic parameters. |
|
| Method Summary | |
|---|---|
void |
close()
Disconnect the connection. |
void |
connect()
|
void |
connectionClosed()
method for ConnectionListener interface. |
void |
connectionClosedOnError(java.lang.Exception e)
method for ConnectionListener interface. |
void |
forceReconnection()
Force the connection to disconnect from the current server and try another. |
java.lang.String |
getConnectionState()
|
PsEPRLease |
getLease(java.lang.String chan,
PayloadParser xpp,
EventReceiver xpr)
Get a lease on a channel for a certain payload type. |
PsEPRLease |
getLease(java.lang.String chan,
PayloadParser xpp,
EventReceiver xpr,
LeaseManager lm)
Get a lease on a channel for a certain payload type. |
PsEPRLease |
getLease(java.lang.String chan,
PayloadParser xpp,
EventReceiver xpr,
long xdur)
Get a lease on a channel for a certain payload type. |
LeaseCollection |
getLeaseCollection()
Return the collection of all of the outstanding leases. |
int |
getMessageExpiration()
Get/set the Jabber message expiration time. |
int |
getReconnectionRetries()
Get/set the number of maximum retries for this connection |
int |
getReconnectionRetriesLeft()
Get/set the number of retries left on this connection. |
PsEPRRouter |
getRouter()
Return the router structure for this connection. |
PsEPRServiceIdentity |
getServiceIdentity()
|
java.lang.String |
getServiceInstance()
|
void |
insertEvent(PsEPREvent ev)
Insert and event into the receiption stream. |
void |
processPacket(org.jivesoftware.smack.packet.Packet pack)
Method called when a packet is received. |
void |
releaseAllLeases()
Release all leases. |
void |
releaseLease(PsEPRLease ls)
Release the specified lease. |
void |
sendEvent(PsEPREvent ev)
Send a constructed PsEPREvent to the network. |
void |
setMessageExpiration(int si)
|
void |
setReconnectionRetries(int si)
|
void |
setReconnectionRetriesLeft(int si)
|
void |
setServiceIdentity(PsEPRServiceIdentity si)
|
void |
setServiceInstance(java.lang.String si)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public boolean isConnected
public int reconnectionRetriesLeft
public int reconnectionRetries
public int connectionTimeout
public final java.lang.String connectionStateInstantiated
public final java.lang.String connectionStateConnecting
public final java.lang.String connectionStateConnected
public final java.lang.String connectionStateReconnecting
public final java.lang.String connectionStateDisconnected
public final java.lang.String connectionStateClosed
| Constructor Detail |
|---|
public PsEPRConnection()
public PsEPRConnection(PsEPRServiceIdentity servID)
servID -
public PsEPRConnection(PsEPRServiceIdentity servID,
java.lang.String instanceName)
servID - instanceName - | Method Detail |
|---|
public int getReconnectionRetries()
public void setReconnectionRetries(int si)
public int getReconnectionRetriesLeft()
public void setReconnectionRetriesLeft(int si)
public int getMessageExpiration()
public void setMessageExpiration(int si)
public PsEPRServiceIdentity getServiceIdentity()
public void setServiceIdentity(PsEPRServiceIdentity si)
public java.lang.String getServiceInstance()
public void setServiceInstance(java.lang.String si)
public java.lang.String getConnectionState()
public LeaseCollection getLeaseCollection()
public PsEPRRouter getRouter()
public void close()
public void connect()
public void forceReconnection()
public PsEPRLease getLease(java.lang.String chan,
PayloadParser xpp,
EventReceiver xpr)
chan - channel to listen toxpp - payload parser. Specifies the namespace to listen forxpr - event receiver for the events with payloads of the namspace
public PsEPRLease getLease(java.lang.String chan,
PayloadParser xpp,
EventReceiver xpr,
long xdur)
chan - channel to listen toxpp - payload parser. Specifies the namespace to listen forxpr - event receiver for the events with payloads of the namspacexdur - duration of the lease in seconds
public PsEPRLease getLease(java.lang.String chan,
PayloadParser xpp,
EventReceiver xpr,
LeaseManager lm)
chan - channel to listen toxpp - payload parser. Specifies the namespace to listen forxpr - event receiver for the events with payloads of the namspacelm - lease manager for handling the lease on the channel
public void releaseLease(PsEPRLease ls)
ls - lease to release.public void releaseAllLeases()
public void sendEvent(PsEPREvent ev)
ev - The contructed event object to sendpublic void insertEvent(PsEPREvent ev)
ev - The event to insertpublic void connectionClosed()
connectionClosed in interface org.jivesoftware.smack.ConnectionListenerpublic void connectionClosedOnError(java.lang.Exception e)
connectionClosedOnError in interface org.jivesoftware.smack.ConnectionListenerpublic void processPacket(org.jivesoftware.smack.packet.Packet pack)
processPacket in interface org.jivesoftware.smack.PacketListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||