javax.management.ListenerNotFoundException Java Examples

The following examples show how to use javax.management.ListenerNotFoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {

    NotificationListener instance = getListener(listener);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "removeNotificationListener",
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.removeNotificationListener(name, instance, filter, handback);
}
 
Example #2
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void removeNotificationListener(ObjectName name,
        ObjectName listener)
        throws InstanceNotFoundException,
        ListenerNotFoundException,
        IOException {

    if (logger.debugOn()) logger.debug("removeNotificationListener" +
            "(ObjectName,ObjectName)",
            "name=" + name
            + ", listener=" + listener);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        connection.removeNotificationListener(name,
                listener,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.removeNotificationListener(name,
                listener,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #3
Source File: SnmpMibTable.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Enable to remove an SNMP entry listener from this
 * <CODE>SnmpMibTable</CODE>.
 *
 * @param listener The listener object which will handle the
 *    notifications emitted by the registered MBean.
 *    This method will remove all the information related to this
 *    listener.
 *
 * @exception ListenerNotFoundException The listener is not registered
 *    in the MBean.
 */
@Override
public synchronized void
    removeNotificationListener(NotificationListener listener)
    throws ListenerNotFoundException {

    // looking for listener in handbackTable
    //
    java.util.Vector<?> handbackList = handbackTable.get(listener) ;
    if ( handbackList == null ) {
        throw new ListenerNotFoundException("listener");
    }

    // If handback is null, remove the listener entry
    //
    handbackTable.remove(listener) ;
    filterTable.remove(listener) ;
}
 
Example #4
Source File: RequiredModelMBean.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Removes a listener for Notifications from the RequiredModelMBean.
 *
 * @param listener The listener name which was handling notifications
 *    emitted by the registered MBean.
 *    This method will remove all information related to this listener.
 *
 * @exception ListenerNotFoundException The listener is not registered
 *    in the MBean or is null.
 *
 * @see #addNotificationListener
 **/
public void removeNotificationListener(NotificationListener listener)
    throws ListenerNotFoundException {
    if (listener == null)
        throw new ListenerNotFoundException(
                  "Notification listener is null");

    final String mth="removeNotificationListener(NotificationListener)";
    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);
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(), mth, "Exit");
    }

}
 
Example #5
Source File: NotificationEmitterSupport.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #6
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void removeNotificationListener(ObjectName name,
        ObjectName listener)
        throws InstanceNotFoundException,
        ListenerNotFoundException,
        IOException {

    if (logger.debugOn()) logger.debug("removeNotificationListener" +
            "(ObjectName,ObjectName)",
            "name=" + name
            + ", listener=" + listener);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        connection.removeNotificationListener(name,
                listener,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.removeNotificationListener(name,
                listener,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #7
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void removeNotificationListener(ObjectName name,
        ObjectName listener)
        throws InstanceNotFoundException,
        ListenerNotFoundException,
        IOException {

    if (logger.debugOn()) logger.debug("removeNotificationListener" +
            "(ObjectName,ObjectName)",
            "name=" + name
            + ", listener=" + listener);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        connection.removeNotificationListener(name,
                listener,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.removeNotificationListener(name,
                listener,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #8
Source File: SnmpMibTable.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Enable to remove an SNMP entry listener from this
 * <CODE>SnmpMibTable</CODE>.
 *
 * @param listener The listener object which will handle the
 *    notifications emitted by the registered MBean.
 *    This method will remove all the information related to this
 *    listener.
 *
 * @exception ListenerNotFoundException The listener is not registered
 *    in the MBean.
 */
@Override
public synchronized void
    removeNotificationListener(NotificationListener listener)
    throws ListenerNotFoundException {

    // looking for listener in handbackTable
    //
    java.util.Vector<?> handbackList = handbackTable.get(listener) ;
    if ( handbackList == null ) {
        throw new ListenerNotFoundException("listener");
    }

    // If handback is null, remove the listener entry
    //
    handbackTable.remove(listener) ;
    filterTable.remove(listener) ;
}
 
Example #9
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private NotificationListener getListener(ObjectName listener)
    throws ListenerNotFoundException {
    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance;
    try {
        instance = getMBean(listener);
    } catch (InstanceNotFoundException e) {
        throw EnvHelp.initCause(
                      new ListenerNotFoundException(e.getMessage()), e);
    }

    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        final RuntimeException exc =
            new IllegalArgumentException(listener.getCanonicalName());
        final String msg =
            "MBean " + listener.getCanonicalName() + " does not " +
            "implement " + NotificationListener.class.getName();
        throw new RuntimeOperationsException(exc, msg);
    }
    return (NotificationListener) resource;
}
 
Example #10
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {

    NotificationListener instance = getListener(listener);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "removeNotificationListener",
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.removeNotificationListener(name, instance, filter, handback);
}
 
Example #11
Source File: BaseNotificationBroadcaster.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Remove a notification event listener from this MBean.
 *
 * @param listener The listener to be removed (any and all registrations
 *  for this listener will be eliminated)
 *
 * @exception ListenerNotFoundException if this listener is not
 *  registered in the MBean
 */
@Override
public void removeNotificationListener(NotificationListener listener)
    throws ListenerNotFoundException {

    synchronized (entries) {
        Iterator<BaseNotificationBroadcasterEntry> items =
            entries.iterator();
        while (items.hasNext()) {
            BaseNotificationBroadcasterEntry item = items.next();
            if (item.listener == listener)
                items.remove();
        }
    }

}
 
Example #12
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void
        removeConnectionNotificationListener(NotificationListener listener)
        throws ListenerNotFoundException {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.removeNotificationListener(listener);
}
 
Example #13
Source File: ServerNotifForwarder.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #14
Source File: OldMBeanServerTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(
        ObjectName name, NotificationListener listener,
        NotificationFilter filter, Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {
    NotificationEmitter userMBean =
            (NotificationEmitter) getMBean(name);
    NotificationListener wrappedListener =
          wrappedListener(name, userMBean, listener);
    userMBean.removeNotificationListener(wrappedListener, filter, handback);
}
 
Example #15
Source File: NotificationEmitterSupport.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws ListenerNotFoundException {

    boolean found = false;

    synchronized (listenerLock) {
        List<ListenerInfo> newList = new ArrayList<>(listenerList);
        final int size = newList.size();
        for (int i = 0; i < size; i++) {
            ListenerInfo li =  newList.get(i);

            if (li.listener == listener) {
                found = true;
                if (li.filter == filter
                    && li.handback == handback) {
                    newList.remove(i);
                    listenerList = newList;
                    return;
                }
            }
        }
    }

    if (found) {
        /* We found this listener, but not with the given filter
         * and handback.  A more informative exception message may
         * make debugging easier.  */
        throw new ListenerNotFoundException("Listener not registered " +
                                            "with this filter and " +
                                            "handback");
    } else {
        throw new ListenerNotFoundException("Listener not registered");
    }
}
 
Example #16
Source File: MBeanServerAccessController.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener)
    throws InstanceNotFoundException, ListenerNotFoundException {
    checkRead();
    getMBeanServer().removeNotificationListener(name, listener);
}
 
Example #17
Source File: GarbageCollectorImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void removeNotificationListener(NotificationListener listener,
                                                    NotificationFilter filter,
                                                    Object handback)
        throws ListenerNotFoundException
{
    boolean before = hasListeners();
    super.removeNotificationListener(listener,filter,handback);
    boolean after = hasListeners();
    if (before && !after) {
        setNotificationEnabled(this,false);
    }
}
 
Example #18
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void
        removeConnectionNotificationListener(NotificationListener listener)
        throws ListenerNotFoundException {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.removeNotificationListener(listener);
}
 
Example #19
Source File: MBeanServerAccessController.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
    throws InstanceNotFoundException, ListenerNotFoundException {
    checkRead();
    getMBeanServer().removeNotificationListener(name, listener,
                                                filter, handback);
}
 
Example #20
Source File: GarbageCollectorImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void removeNotificationListener(NotificationListener listener,
                                                    NotificationFilter filter,
                                                    Object handback)
        throws ListenerNotFoundException
{
    boolean before = hasListeners();
    super.removeNotificationListener(listener,filter,handback);
    boolean after = hasListeners();
    if (before && !after) {
        setNotificationEnabled(this,false);
    }
}
 
Example #21
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(ObjectName name,
        ObjectName listener,
        NotificationFilter filter,
        Object handback)
        throws InstanceNotFoundException,
        ListenerNotFoundException,
        IOException {
    if (logger.debugOn())
        logger.debug("removeNotificationListener" +
                "(ObjectName,ObjectName,NotificationFilter,Object)",
                "name=" + name
                + ", listener=" + listener
                + ", filter=" + filter
                + ", handback=" + handback);

    final MarshalledObject<NotificationFilter> sFilter =
            new MarshalledObject<NotificationFilter>(filter);
    final MarshalledObject<Object> sHandback =
            new MarshalledObject<Object>(handback);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        connection.removeNotificationListener(name,
                listener,
                sFilter,
                sHandback,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.removeNotificationListener(name,
                listener,
                sFilter,
                sHandback,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #22
Source File: GarbageCollectorImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void removeNotificationListener(NotificationListener listener)
    throws ListenerNotFoundException {
    boolean before = hasListeners();
    super.removeNotificationListener(listener);
    boolean after = hasListeners();
    if (before && !after) {
        setNotificationEnabled(this,false);
    }
}
 
Example #23
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(ObjectName name,
        NotificationListener listener)
        throws InstanceNotFoundException,
        ListenerNotFoundException,
        IOException {

    final boolean debug = logger.debugOn();

    if (debug) logger.debug("removeNotificationListener"+
            "(ObjectName,NotificationListener)",
            "name=" + name
            + ", listener=" + listener);

    final Integer[] ret =
            rmiNotifClient.removeNotificationListener(name, listener);

    if (debug) logger.debug("removeNotificationListener",
            "listenerIDs=" + objects(ret));

    final ClassLoader old = pushDefaultClassLoader();

    try {
        connection.removeNotificationListeners(name,
                ret,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.removeNotificationListeners(name,
                ret,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }

}
 
Example #24
Source File: ServerNotifForwarder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #25
Source File: ClientNotifForwarder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized Integer
    removeNotificationListener(ObjectName name,
                               NotificationListener listener,
                               NotificationFilter filter,
                               Object handback)
        throws ListenerNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("removeNotificationListener",
                     "Remove the listener "+listener+" from "+name);
    }

    beforeRemove();

    Integer id = null;

    List<ClientListenerInfo> values =
            new ArrayList<ClientListenerInfo>(infoList.values());
    for (int i=values.size()-1; i>=0; i--) {
        ClientListenerInfo li = values.get(i);
        if (li.sameAs(name, listener, filter, handback)) {
            id=li.getListenerID();

            infoList.remove(id);

            break;
        }
    }

    if (id == null)
        throw new ListenerNotFoundException("Listener not found");

    return id;
}
 
Example #26
Source File: JmxMBeanServer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener)
    throws InstanceNotFoundException, ListenerNotFoundException {

    mbsInterceptor.removeNotificationListener(cloneObjectName(name),
                                              listener);
}
 
Example #27
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(ObjectName name,
        NotificationListener listener)
        throws InstanceNotFoundException,
        ListenerNotFoundException,
        IOException {

    final boolean debug = logger.debugOn();

    if (debug) logger.debug("removeNotificationListener"+
            "(ObjectName,NotificationListener)",
            "name=" + name
            + ", listener=" + listener);

    final Integer[] ret =
            rmiNotifClient.removeNotificationListener(name, listener);

    if (debug) logger.debug("removeNotificationListener",
            "listenerIDs=" + objects(ret));

    final ClassLoader old = pushDefaultClassLoader();

    try {
        connection.removeNotificationListeners(name,
                ret,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.removeNotificationListeners(name,
                ret,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }

}
 
Example #28
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void
        removeConnectionNotificationListener(NotificationListener listener,
        NotificationFilter filter,
        Object handback)
        throws ListenerNotFoundException {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.removeNotificationListener(listener, filter,
            handback);
}
 
Example #29
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener)
        throws InstanceNotFoundException, ListenerNotFoundException {
    NotificationListener instance = getListener(listener);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "removeNotificationListener",
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.removeNotificationListener(name, instance);
}
 
Example #30
Source File: ClientNotifForwarder.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public synchronized Integer
    removeNotificationListener(ObjectName name,
                               NotificationListener listener,
                               NotificationFilter filter,
                               Object handback)
        throws ListenerNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("removeNotificationListener",
                     "Remove the listener "+listener+" from "+name);
    }

    beforeRemove();

    Integer id = null;

    List<ClientListenerInfo> values =
            new ArrayList<ClientListenerInfo>(infoList.values());
    for (int i=values.size()-1; i>=0; i--) {
        ClientListenerInfo li = values.get(i);
        if (li.sameAs(name, listener, filter, handback)) {
            id=li.getListenerID();

            infoList.remove(id);

            break;
        }
    }

    if (id == null)
        throw new ListenerNotFoundException("Listener not found");

    return id;
}