Search in sources :

Example 21 with ListenerNotFoundException

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");
    }
}
Also used : ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 22 with ListenerNotFoundException

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;
    }
}
Also used : ArrayList(java.util.ArrayList) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 23 with ListenerNotFoundException

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);
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 24 with ListenerNotFoundException

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;
    }
}
Also used : NotificationEmitter(javax.management.NotificationEmitter) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 25 with ListenerNotFoundException

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);
}
Also used : NotificationTuple(org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.NotificationTuple) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Aggregations

ListenerNotFoundException (javax.management.ListenerNotFoundException)34 ObjectName (javax.management.ObjectName)13 Notification (javax.management.Notification)11 NotificationEmitter (javax.management.NotificationEmitter)10 MalformedObjectNameException (javax.management.MalformedObjectNameException)9 InstanceNotFoundException (javax.management.InstanceNotFoundException)8 CompositeData (javax.management.openmbean.CompositeData)8 Test (org.testng.annotations.Test)8 IOException (java.io.IOException)5 NotificationFilterSupport (javax.management.NotificationFilterSupport)5 MemoryNotificationInfo (java.lang.management.MemoryNotificationInfo)4 MemoryUsage (java.lang.management.MemoryUsage)4 MBeanException (javax.management.MBeanException)4 NotificationListener (javax.management.NotificationListener)4 ReflectionException (javax.management.ReflectionException)4 MemoryMXBean (java.lang.management.MemoryMXBean)3 ArrayList (java.util.ArrayList)3 AttributeNotFoundException (javax.management.AttributeNotFoundException)3 IntrospectionException (javax.management.IntrospectionException)3 MemoryMXBeanImpl (com.ibm.java.lang.management.internal.MemoryMXBeanImpl)2