* it by the MBean's ObjectName. Otherwise the source is unchanged.
*/
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
throws InstanceNotFoundException
{
MBeanEntry entry = registry.get(name);
if (NotificationBroadcaster.class.isInstance(entry.getResourceInstance()) == false)
throw new RuntimeOperationsException(new IllegalArgumentException("The MBean " + name + " exists but does not implement the NotificationBroadcaster interface."));
if (listener == null)
throw new RuntimeOperationsException(new IllegalArgumentException("Cannot add null listener"));
checkMBeanPermission(entry.getResourceClassName(), null, name,
"addNotificationListener");
ClassLoader newTCL = entry.getClassLoader();
NotificationBroadcaster broadcaster = entry.getInvoker();
ClassLoader oldTCL = TCLAction.UTIL.getContextClassLoader();
final boolean setCl = newTCL != oldTCL && newTCL != null;
try
{
if (setCl)
TCLAction.UTIL.setContextClassLoader(newTCL);
listeners.add(entry.getObjectName(), broadcaster, listener, filter, handback);
}
finally
{
if (setCl)
TCLAction.UTIL.setContextClassLoader(oldTCL);