use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class RequiredModelMBean method removeNotificationListener.
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
if (listener == null)
throw new ListenerNotFoundException("Notification listener is null");
final String mth = "removeNotificationListener(" + "NotificationListener, NotificationFilter, Object)";
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, "Entry");
}
if (generalBroadcaster == null)
throw new ListenerNotFoundException("No notification listeners registered");
generalBroadcaster.removeNotificationListener(listener, filter, handback);
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, "Exit");
}
}
use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class NotificationEmitterSupport method removeNotificationListener.
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
synchronized (listenerLock) {
List<ListenerInfo> newList = new ArrayList<>(listenerList);
/* We scan the list of listeners in reverse order because
in forward order we would have to repeat the loop with
the same index after a remove. */
for (int i = newList.size() - 1; i >= 0; i--) {
ListenerInfo li = newList.get(i);
if (li.listener == listener)
newList.remove(i);
}
if (newList.size() == listenerList.size())
throw new ListenerNotFoundException("Listener not registered");
listenerList = newList;
}
}
use of javax.management.ListenerNotFoundException in project jdk8u_jdk by JetBrains.
the class ServerNotifForwarder method removeNotificationListener.
public void removeNotificationListener(ObjectName name, Integer listenerID) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
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 (listenerMap) {
// Tread carefully because if set.size() == 1 it may be a
// Collections.singleton, which is unmodifiable.
Set<IdAndFilter> set = listenerMap.get(name);
IdAndFilter idaf = new IdAndFilter(listenerID, null);
if (set == null || !set.contains(idaf))
throw new ListenerNotFoundException("Listener not found");
if (set.size() == 1)
listenerMap.remove(name);
else
set.remove(idaf);
}
}
use of javax.management.ListenerNotFoundException in project felix by apache.
the class MemoryUsageSupport method dispose.
void dispose() {
NotificationEmitter memEmitter = (NotificationEmitter) getMemory();
try {
memEmitter.removeNotificationListener(this);
} catch (ListenerNotFoundException e) {
// don't care
}
context.removeServiceListener(this);
if (logServiceReference != null) {
context.ungetService(logServiceReference);
logServiceReference = null;
logService = null;
}
}
use of javax.management.ListenerNotFoundException in project felix by apache.
the class ClientInvoker method removeNotificationListener.
public void removeNotificationListener(ObjectName observed, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException {
Integer[] ids = notificationHandler.getNotificationListeners(new NotificationTuple(observed, listener));
if (ids == null)
throw new ListenerNotFoundException("Could not find listener " + listener);
connection.removeNotificationListeners(observed, ids, delegate);
notificationHandler.removeNotificationListeners(ids);
}
Aggregations