}
if (ret == 'q')
break;
I_XmlBlasterAccess con = new XmlBlasterAccess(glob.getClone(null));
con.registerConnectionListener(new I_ConnectionStateListener() {
public void reachedAlive(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection) {
log.info("I_ConnectionStateListener: Connected");
}
public void reachedPolling(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection) {
log
.warning("I_ConnectionStateListener: No connection to xmlBlaster server, we are polling ...");
}
public void reachedDead(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection) {
log.warning("I_ConnectionStateListener: Connection from "
+ connection.getGlobal().getId()
+ " to xmlBlaster is DEAD, doing exit.");
}
public void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
}
});
ConnectQos qos = new ConnectQos(glob);
if (connectPersistent) {
qos.setPersistent(connectPersistent);
}
if (connectQosClientPropertyMap != null) {
Iterator it = connectQosClientPropertyMap.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
qos.addClientProperty(key, connectQosClientPropertyMap.get(
key).toString());
}
}
//log.info("ConnectQos is " + qos.toXml());
/* ConnectReturnQos crq = */con.connect(qos, new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey,
byte[] content, UpdateQos updateQos)
throws XmlBlasterException {
try {
log.info("Received '" + updateKey.getOid() + "':"
+ new String(content, "UTF-8"));
} catch (UnsupportedEncodingException e) {
log.severe("Update failed: " + e.toString());
}
return "";
}
}); // Login to xmlBlaster, register for updates
log.info("Connect success");
if (ret == 'd') {
DisconnectQos dq = new DisconnectQos(glob);
con.disconnect(dq);
log.info("Disconnected from server, all resources released");
} else {
con.leaveServer(null);
ret = 0;
log.info("Left server, our server side session remains, bye");
}
con = null;