if (event.startsWith(ContextNode.LOGGING_MARKER_TAG+"/severe/")
|| event.startsWith("logging/error/")) {
// We want to be notified if a log.error() is called, this will
// notify our LogableDevice.log() method
XbNotifyHandler.instance().register(Level.SEVERE.intValue(), this);
if (this.loggingSet == null) this.loggingSet = new TreeSet();
this.loggingSet.add(event);
}
// "logging/warning/*"
else if (event.startsWith(ContextNode.LOGGING_MARKER_TAG+"/warning/")
|| event.startsWith("logging/warn/")) {
XbNotifyHandler.instance().register(Level.WARNING.intValue(), this);
if (this.loggingSet == null) this.loggingSet = new TreeSet();
this.loggingSet.add(event);
}
// "service/RunlevelManager/event/startupRunlevel8", "service/RunlevelManager/event/shutdownRunlevel7"
else if (event.startsWith(this.engineGlob.getRunlevelManager().getContextNode().getRelativeName()+"/event/")) {
log.fine("Register event = " + event);
this.engineGlob.getRunlevelManager().addRunlevelListener(this);
if (this.runlevelSet == null) this.runlevelSet = new TreeSet();
this.runlevelSet.add(event);
}
else if (isConnectionStateEvent(event)) {
// client/[subjectId]/session/[publicSessionId]/event/connectionState
ClusterManager clusterManager = requestBroker.getServerScope().getClusterManager();
if (clusterManager == null) {
log.warning("Configuration of '" + event + "' is ignored, no cluster manager available");
continue;
}
if (!clusterManager.isReady()) {
log.warning("Configuration of '" + event + "' is ignored, cluster manager is not ready");
continue;
}
int index = event.lastIndexOf("/event/");
if (index == -1) {
log.warning("Configuration of '" + event + "' is ignored, wrong syntax");
continue;
}
// strip "event/connectionState"
String name = event.substring(0, index);
ClusterNode[] nodes = clusterManager.getClusterNodes();
for (int ic=0; ic<nodes.length; ic++) {
ClusterNode node = nodes[ic];
SessionName destination = node.getSessionName();
if (destination != null && destination.matchRelativeName(name)) {
node.registerConnectionListener(this);
}
}
}
else if (isCallbackStateEvent(event)) {
//else if (event.endsWith("/event/callbackState") || event.endsWith("/event/callbackAlive") || event.endsWith("/event/callbackPolling") || event.endsWith("/event/callbackDead")) {
// OK: "client/joe/session/1/event/callbackState"
// Not yet supported: "client/joe/session/1/event/callbackAlive", "client/joe/session/1/event/callbackPolling"
int index = event.lastIndexOf("/event/");
if (index == -1) {
log.warning("Configuration of '" + event + "' is ignored, wrong syntax");
continue;
}
String name = event.substring(0, index);
SessionName sessionName = new SessionName(this.engineGlob, name);
this.requestBroker.getAuthenticate().addClientListener(this);
if (this.callbackSessionStateSet == null) this.callbackSessionStateSet = new TreeSet();
if (event.startsWith(ContextNode.SUBJECT_MARKER_TAG+ContextNode.SEP+"*"+ContextNode.SEP) ||
event.endsWith(ContextNode.SESSION_MARKER_TAG+ContextNode.SEP+"*"+"/event/callbackState")) {
// "client/*/session/1/event/callbackState" or "client/joe/session/*/event/callbackState"
if (this.pendingCallbackSessionInfoSet == null) this.pendingCallbackSessionInfoSet = new TreeSet();
this.pendingCallbackSessionInfoSet.add(name);
this.callbackSessionStateSet.add(name);
SubjectInfo[] subs = null;
log.fine("Register existing wildcard callback session state event = " + event);
if (event.startsWith(ContextNode.SUBJECT_MARKER_TAG+ContextNode.SEP+"*"+ContextNode.SEP) &&
!event.endsWith(ContextNode.SESSION_MARKER_TAG+ContextNode.SEP+"*"+"/event/callbackState")) {
subs = this.requestBroker.getAuthenticate().getSubjectInfoArr();
for (int sj=0; sj<subs.length; sj++) {
SubjectInfo subjectInfo = subs[sj];
if (!wildcardMatch(sessionName.getLoginName(), subjectInfo.getLoginName()))
continue;
SessionInfo[] ses = subjectInfo.getSessions();
for (int se=0; se<ses.length; se++) {
if (!wildcardMatch(sessionName.getPublicSessionId(), ses[se].getPublicSessionId()))
continue;
DispatchManager mgr = ses[se].getDispatchManager();
if (mgr != null) {
mgr.addConnectionStatusListener(this);
}
}
}
}
}
else {
log.fine("Register callback session state event = " + event);
SessionInfo sessionInfo = this.requestBroker.getAuthenticate().getSessionInfo(sessionName);
DispatchManager mgr = null;
if (sessionInfo != null)
mgr = sessionInfo.getDispatchManager();
if (mgr != null) {
mgr.addConnectionStatusListener(this);
}
else {
if (this.pendingCallbackSessionInfoSet == null) this.pendingCallbackSessionInfoSet = new TreeSet();
this.pendingCallbackSessionInfoSet.add(sessionName.getAbsoluteName());
}
this.callbackSessionStateSet.add(sessionName.getRelativeName());
}
}
else if (isConnectionQueueEvent(event)) {
// client/[subjectId]/session/[publicSessionId]/queue/connection/event/threshold.90%
// TODO: register in xmlBlasterAccess of each ClusterNode client
log.severe("Event " + event + " is not implemented");
}
else if (isQueueEvent(event)) {
if (queueEventHandler == null) {
queueEventHandler = new QueueEventHandler(serverScope, this);
}
queueEventHandler.registerEventType(this, event);
}
else if (isPersistenceEvent(event)) {
if (mapEventHandler == null) {
mapEventHandler = new MapEventHandler(serverScope, this);
}
mapEventHandler.registerEventType(this, event);
}
else if (event.startsWith(ContextNode.SUBJECT_MARKER_TAG+ContextNode.SEP)) {
// REGEX: "client/.*/session/.*/event/.*"
// "client/joe/session/1/event/connect", "client/*/session/*/event/disconnect"
// "client/joe/session/1/event/subscribe"
log.fine("Register login/logout event = " + event);
if (event.endsWith("/event/subscribe") || event.endsWith("/event/unSubscribe"))
this.requestBroker.addSubscriptionListener(this);
else if (event.endsWith("/event/remoteProperties"))
this.requestBroker.addRemotePropertiesListener(this); // I_RemotePropertiesListener
else
this.requestBroker.getAuthenticate().addClientListener(this);
if (this.clientSet == null) this.clientSet = new TreeSet();
this.clientSet.add(event);
}
else if (event.startsWith(ContextNode.TOPIC_MARKER_TAG+ContextNode.SEP)) {
// "topic/hello/event/alive", "topic/hello/event/subscribe" ...
log.fine("Register topic event = " + event);
if (event.endsWith("/event/subscribe") || event.endsWith("/event/unSubscribe"))
this.requestBroker.addSubscriptionListener(this);
else
this.engineGlob.getTopicAccessor().addTopicListener(this);
if (this.topicSet == null) this.topicSet = new TreeSet();
this.topicSet.add(event);
}
else if (event.startsWith("heartbeat")) {
// "heartbeat.360000
log.fine("Register heartbeat event = " + event);