Methods Summary |
---|
public void | close()When the server-side connector webapp is shutdown by the servlet container,
the ServerNotificationManager calls this method.
All pending notifications are dropped.
exiting = true;
synchronized (que) {
que.notify();
}
try {
dispatchThr.join();
} catch (InterruptedException intre) {
}
try {
out.close();
} catch (IOException ioe) {
// XXX: Log it
}
|
public void | fireNotification(com.sun.enterprise.admin.jmx.remote.notification.NotificationWrapper wrapr)Called by the ServerNotificationManager whenever a notification needs to be
sent to the client.
if (que.size() < bufsiz) {
synchronized (que) {
que.add(wrapr);
que.notify();
}
}
|
public void | fireWaitNotif()Sends an empty notification to the client.
An empty notification is sent every 10 seconds.
if (!hasIOExceptionOccurred() && (que.size() < bufsiz) && !dispatching && isIdle()) {
synchronized (que) {
que.add(new NotificationWrapper(NotificationWrapper.WAIT, null, null));
que.notify();
}
}
|
public boolean | hasIOExceptionOccurred()Returns true if an IOException had occurred while dispatching a notification
to the client.
If true, then the connection to the client may have dropped.
If true, the ServerNotificationManager suspends this connection, waiting for
the client to reconnect.
return isIOException;
|
private boolean | isDisconnected(java.io.IOException ioe)
if (ioe instanceof ClosedChannelException ||
ioe instanceof SocketException ||
ioe instanceof ConnectException ||
ioe instanceof ConnectIOException)
return true;
return false;
|
public boolean | isExiting()
return exiting;
|
private boolean | isIdle()
boolean ret = ((System.currentTimeMillis() - lastNotifTime) >= DefaultConfiguration.NOTIF_WAIT_INTERVAL);
return ret;
|
public void | reinit(java.io.OutputStream out)Reinitialized this connection and restarts the dispatch thread.
This method is called everytime the client reconnects to the server
because the connection had dropped.
this.out = out;
isIOException = false;
dispatchThr = new Thread(this);
dispatchThr.start();
|
public void | run()The notifications dispatch thread.
The dispatch thread sends all pending notifications in the buffer to the client.
The dispatch thread exits, whenever an IOException occurs during actual dispatch
or whenever this connection is being closed (after a call to close())
/* XXX: Even when we are exiting should we send the remaining notifications?
* OR just drop the remaining notifications ?
*
* Currently we drop all the remaining notifications!!
*/
while (!isExiting() && !hasIOExceptionOccurred()) {
synchronized (que) {
while (que.isEmpty() && !isExiting() && !hasIOExceptionOccurred()) {
try {
que.wait();
} catch (InterruptedException intre) {
}
}
}
if (isExiting() || hasIOExceptionOccurred())
break;
dispatching = true;
while (!que.isEmpty() && !isExiting() && !hasIOExceptionOccurred()) {
NotificationWrapper wrapr = (NotificationWrapper) que.remove();
try {
sendNotificationMsg(wrapr);
} catch (IOException ioe) {
if (isExiting())
break;
// XXX: Log it; drop the notification
if (!isDisconnected(ioe))
break;
isIOException = true;
synchronized (this) {
this.notify();
}
break;
}
}
lastNotifTime = System.currentTimeMillis();
dispatching = false;
}
|
private void | sendNotificationMsg(com.sun.enterprise.admin.jmx.remote.notification.NotificationWrapper wrapr)
ObjectOutputStream objout = new ObjectOutputStream(out);
objout.writeObject(wrapr);
objout.flush();
|