Methods Summary |
---|
public java.lang.Integer | addNotificationListener(javax.management.ObjectName name, javax.management.NotificationFilter filter)
if (logger.traceOn()) {
logger.trace("addNotificationListener",
"Add a listener at " + name);
}
checkState();
// Explicitly check MBeanPermission for addNotificationListener
//
checkMBeanPermission(name, "addNotificationListener");
try {
Boolean instanceOf = (Boolean)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws InstanceNotFoundException {
return new Boolean(
mbeanServer.isInstanceOf(name,
broadcasterClass));
}
});
if (!instanceOf.booleanValue()) {
throw new IllegalArgumentException("The specified MBean [" +
name + "] is not a " +
"NotificationBroadcaster " +
"object.");
}
} catch (PrivilegedActionException e) {
throw (InstanceNotFoundException) extractException(e);
}
final Integer id = getListenerID();
synchronized(listenerList) {
listenerList.add(new ListenerInfo(id, name, filter));
}
return id;
|
private void | checkMBeanPermission(javax.management.ObjectName name, java.lang.String actions)Explicitly check the MBeanPermission for
the current access control context.
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
AccessControlContext acc = AccessController.getContext();
ObjectInstance oi = null;
try {
oi = (ObjectInstance) AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run()
throws InstanceNotFoundException {
return mbeanServer.getObjectInstance(name);
}
});
} catch (PrivilegedActionException e) {
throw (InstanceNotFoundException) extractException(e);
}
String classname = oi.getClassName();
MBeanPermission perm = new MBeanPermission(classname,
null,
name,
actions);
sm.checkPermission(perm, acc);
}
|
private void | checkState()
synchronized(terminationLock) {
if (terminated) {
throw new IOException("The connection has been terminated.");
}
}
|
private static java.lang.Exception | extractException(java.lang.Exception e)Iterate until we extract the real exception
from a stack of PrivilegedActionExceptions.
while (e instanceof PrivilegedActionException) {
e = ((PrivilegedActionException)e).getException();
}
return e;
|
public javax.management.remote.NotificationResult | fetchNotifs(long startSequenceNumber, long timeout, int maxNotifications)
if (logger.traceOn()) {
logger.trace("fetchNotifs", "Fetching notifications, the " +
"startSequenceNumber is " + startSequenceNumber +
", the timeout is " + timeout +
", the maxNotifications is " + maxNotifications);
}
NotificationResult nr = null;
final long t = Math.min(connectionTimeout, timeout);
try {
nr = notifBuffer.fetchNotifications(listenerList,
startSequenceNumber,
t, maxNotifications);
} catch (InterruptedException ire) {
nr = new NotificationResult(0L, 0L, new TargetedNotification[0]);
}
if (logger.traceOn()) {
logger.trace("fetchNotifs", "Forwarding the notifs: "+nr);
}
return nr;
|
private java.lang.Integer | getListenerID()
synchronized(listenerCounterLock) {
return new Integer(listenerCounter++);
}
|
public void | removeNotificationListener(javax.management.ObjectName name, java.lang.Integer[] listenerIDs)
if (logger.traceOn()) {
logger.trace("removeNotificationListener",
"Remove some listeners from " + name);
}
checkState();
// Explicitly check MBeanPermission for removeNotificationListener
//
checkMBeanPermission(name, "removeNotificationListener");
Exception re = null;
for (int i = 0 ; i < listenerIDs.length ; i++) {
try {
removeNotificationListener(name, listenerIDs[i]);
} catch (Exception e) {
// Give back the first exception
//
if (re != null) {
re = e;
}
}
}
if (re != null) {
throw re;
}
|
public void | removeNotificationListener(javax.management.ObjectName name, java.lang.Integer listenerID)
if (logger.traceOn()) {
logger.trace("removeNotificationListener",
"Remove the listener " + listenerID + " from " + name);
}
checkState();
if (name != null && !name.isPattern()) {
if (!mbeanServer.isRegistered(name)) {
throw new InstanceNotFoundException("The MBean " + name +
" is not registered.");
}
}
synchronized(listenerList) {
if (!listenerList.remove(new ListenerInfo(listenerID,name,null))) {
throw new ListenerNotFoundException("Listener not found!");
}
}
|
public void | terminate()
if (logger.traceOn()) {
logger.trace("terminate", "Be called.");
}
synchronized(terminationLock) {
if (terminated) {
return;
}
terminated = true;
synchronized(listenerList) {
listenerList.clear();
}
}
if (logger.traceOn()) {
logger.trace("terminate", "Terminated.");
}
|