Java 类javax.management.NotificationListener 实例源码

项目:openjdk-jdk10    文件:RMIConnector.java   
public void addNotificationListener(ObjectName name,
        NotificationListener listener,
        NotificationFilter filter,
        Object handback)
        throws InstanceNotFoundException,
        IOException {

    final boolean debug = logger.debugOn();

    if (debug)
        logger.debug("addNotificationListener" +
                "(ObjectName,NotificationListener,"+
                "NotificationFilter,Object)",
                "name=" + name
                + ", listener=" + listener
                + ", filter=" + filter
                + ", handback=" + handback);

    final Integer listenerID =
            addListenerWithSubject(name,
            new MarshalledObject<NotificationFilter>(filter),
            delegationSubject,true);
    rmiNotifClient.addNotificationListener(listenerID, name, listener,
            filter, handback,
            delegationSubject);
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized void removeNotificationListener(ObjectName name,
        NotificationListener listener) throws InstanceNotFoundException,
        ListenerNotFoundException {     
    mbs.removeNotificationListener(name, listener);

    // TODO: slow implementation ... but fast one takes a lot of time to do :-)
    Iterator<Listener2> iter = listeners2.iterator();
    while(iter.hasNext()) {
        Listener2 l = iter.next();
        if (SafeEquals.equals(name, l.name) && SafeEquals.equals(listener, l.listener)) {
            listeners.remove(l);
            unregisteredListeners.remove(l);
            iter.remove();
        }
    }
}
项目:OpenJSharp    文件:RequiredModelMBean.java   
/**
 * 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");
    }

}
项目:openjdk-jdk10    文件:ClientNotifForwarder.java   
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 liId = getListenerId(name, listener,
            filter, handback);
    infoList.remove(liId);

    return liId;
}
项目:jdk8u-jdk    文件:ClientNotifForwarder.java   
public synchronized void addNotificationListener(Integer listenerID,
                                    ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback,
                                    Subject delegationSubject)
        throws IOException, InstanceNotFoundException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
                     "Add the listener "+listener+" at "+name);
    }

    infoList.put(listenerID,
                 new ClientListenerInfo(listenerID,
                                        name,
                                        listener,
                                        filter,
                                        handback,
                                        delegationSubject));


    init(false);
}
项目:jdk8u-jdk    文件:ScanDirAgent.java   
/**
 * Creates a new instance of ScanDirAgent
 * You will need to call {@link #init()} later on in order to initialize
 * the application.
 * @see #main
 **/
public ScanDirAgent() {
    // Initialize the notification queue
    queue = new LinkedBlockingQueue<Notification>();

    // Creates the listener.
    listener = new NotificationListener() {
        public void handleNotification(Notification notification,
                                       Object handback) {
            try {
                // Just put the received notification in the queue.
                // It will be consumed later on by 'waitForClose()'
                //
                LOG.finer("Queuing received notification "+notification);
                queue.put(notification);
            } catch (InterruptedException ex) {
                // OK
            }
        }
    };
}
项目:openjdk-jdk10    文件:RequiredModelMBean.java   
/**
 * 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");

    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
    }

    if (generalBroadcaster == null)
        throw new ListenerNotFoundException(
              "No notification listeners registered");


    generalBroadcaster.removeNotificationListener(listener);
    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
    }

}
项目:tomcat7    文件:BaseNotificationBroadcaster.java   
/**
 * 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();
        }
    }

}
项目:tomcat7    文件:BaseModelMBean.java   
/**
 * Add an attribute change notification event listener to this MBean.
 *
 * @param listener Listener that will receive event notifications
 * @param name Name of the attribute of interest, or <code>null</code>
 *  to indicate interest in all attributes
 * @param handback Handback object to be sent along with event
 *  notifications
 *
 * @exception IllegalArgumentException if the listener parameter is null
 */
@Override
public void addAttributeChangeNotificationListener
    (NotificationListener listener, String name, Object handback)
    throws IllegalArgumentException {

    if (listener == null)
        throw new IllegalArgumentException("Listener is null");
    if (attributeBroadcaster == null)
        attributeBroadcaster = new BaseNotificationBroadcaster();

    if( log.isDebugEnabled() )
        log.debug("addAttributeNotificationListener " + listener);

    BaseAttributeFilter filter = new BaseAttributeFilter(name);
    attributeBroadcaster.addNotificationListener
        (listener, filter, handback);

}
项目:jdk8u-jdk    文件:DefaultMBeanServerInterceptor.java   
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);
}
项目:tomcat7    文件:ConnectionPool.java   
/**
 * Return true if the notification was sent successfully, false otherwise.
 * @param type
 * @param message
 * @return true if the notification succeeded
 */
public boolean notify(final String type, String message) {
    try {
        Notification n = new Notification(
                type,
                this,
                sequence.incrementAndGet(),
                System.currentTimeMillis(),
                "["+type+"] "+message);
        sendNotification(n);
        for (NotificationListener listener : listeners) {
            listener.handleNotification(n,this);
        }
        return true;
    }catch (Exception x) {
        if (log.isDebugEnabled()) {
            log.debug("Notify failed. Type="+type+"; Message="+message,x);
        }
        return false;
    }

}
项目:OpenJSharp    文件:ClientNotifForwarder.java   
public synchronized void addNotificationListener(Integer listenerID,
                                    ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback,
                                    Subject delegationSubject)
        throws IOException, InstanceNotFoundException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
                     "Add the listener "+listener+" at "+name);
    }

    infoList.put(listenerID,
                 new ClientListenerInfo(listenerID,
                                        name,
                                        listener,
                                        filter,
                                        handback,
                                        delegationSubject));


    init(false);
}
项目:jdk8u-jdk    文件:ArrayNotificationBuffer.java   
private void addNotificationListener(final ObjectName name,
                                     final NotificationListener listener,
                                     final NotificationFilter filter,
                                     final Object handback)
        throws Exception {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            public Void run() throws InstanceNotFoundException {
                mBeanServer.addNotificationListener(name,
                                                    listener,
                                                    filter,
                                                    handback);
                return null;
            }
        });
    } catch (Exception e) {
        throw extractException(e);
    }
}
项目:lazycat    文件:BaseModelMBean.java   
/**
 * Add an attribute change notification event listener to this MBean.
 *
 * @param listener
 *            Listener that will receive event notifications
 * @param name
 *            Name of the attribute of interest, or <code>null</code> to
 *            indicate interest in all attributes
 * @param handback
 *            Handback object to be sent along with event notifications
 *
 * @exception IllegalArgumentException
 *                if the listener parameter is null
 */
@Override
public void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback)
        throws IllegalArgumentException {

    if (listener == null)
        throw new IllegalArgumentException("Listener is null");
    if (attributeBroadcaster == null)
        attributeBroadcaster = new BaseNotificationBroadcaster();

    if (log.isDebugEnabled())
        log.debug("addAttributeNotificationListener " + listener);

    BaseAttributeFilter filter = new BaseAttributeFilter(name);
    attributeBroadcaster.addNotificationListener(listener, filter, handback);

}
项目:apache-tomcat-7.0.73-with-comment    文件:BaseModelMBean.java   
/**
 * Add an attribute change notification event listener to this MBean.
 *
 * @param listener Listener that will receive event notifications
 * @param name Name of the attribute of interest, or <code>null</code>
 *  to indicate interest in all attributes
 * @param handback Handback object to be sent along with event
 *  notifications
 *
 * @exception IllegalArgumentException if the listener parameter is null
 */
@Override
public void addAttributeChangeNotificationListener
    (NotificationListener listener, String name, Object handback)
    throws IllegalArgumentException {

    if (listener == null)
        throw new IllegalArgumentException("Listener is null");
    if (attributeBroadcaster == null)
        attributeBroadcaster = new BaseNotificationBroadcaster();

    if( log.isDebugEnabled() )
        log.debug("addAttributeNotificationListener " + listener);

    BaseAttributeFilter filter = new BaseAttributeFilter(name);
    attributeBroadcaster.addNotificationListener
        (listener, filter, handback);

}
项目:jdk8u-jdk    文件:RMIConnector.java   
public void addNotificationListener(ObjectName name,
        NotificationListener listener,
        NotificationFilter filter,
        Object handback)
        throws InstanceNotFoundException,
        IOException {

    final boolean debug = logger.debugOn();

    if (debug)
        logger.debug("addNotificationListener" +
                "(ObjectName,NotificationListener,"+
                "NotificationFilter,Object)",
                "name=" + name
                + ", listener=" + listener
                + ", filter=" + filter
                + ", handback=" + handback);

    final Integer listenerID =
            addListenerWithSubject(name,
            new MarshalledObject<NotificationFilter>(filter),
            delegationSubject,true);
    rmiNotifClient.addNotificationListener(listenerID, name, listener,
            filter, handback,
            delegationSubject);
}
项目:OpenJSharp    文件:NotificationEmitterSupport.java   
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;
    }
}
项目:OpenJSharp    文件:DefaultMBeanServerInterceptor.java   
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);
}
项目:jdk8u-jdk    文件:ConcurrentModificationTest.java   
private static void listenerOp(MBeanServerConnection mserver, NotificationListener listener, boolean adding)
        throws Exception {
    if (adding) {
        mserver.addNotificationListener(delegateName, listener, null, null);
    } else {
        mserver.removeNotificationListener(delegateName, listener);
    }
}
项目:openjdk-jdk10    文件:RequiredModelMBean.java   
public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
    throws ListenerNotFoundException {

    if (listener == null)
        throw new ListenerNotFoundException(
                  "Notification listener is null");

    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
    }

    if (generalBroadcaster == null)
        throw new ListenerNotFoundException(
              "No notification listeners registered");


    generalBroadcaster.removeNotificationListener(listener,filter,
                                                  handback);

    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
    }

}
项目:jdk8u-jdk    文件:RequiredModelMBean.java   
/**
 * 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");
    }

}
项目:jdk8u-jdk    文件:OldMBeanServerTest.java   
RewriteListener(
        ObjectName name, Object userMBean,
        NotificationListener userListener) {
    this.name = name;
    this.userMBean = userMBean;
    this.userListener = userListener;
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
public Listener2(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) {
    this.name = name;
    this.listener = listener;
    this.filter = filter;
    this.handback = handback;
    HashCode hc = new HashCode();
    hc.add(name);
    hc.add(listener);
    hc.add(filter);
    hc.add(handback);
    this.hashCode = hc.getHash();
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter,
        Object handback) throws InstanceNotFoundException {     
    mbs.addNotificationListener(name, listener, filter, handback);
    Listener2 l = new Listener2(name, listener, filter, handback);
    listeners.add(l);
    listeners2.add(l);
}
项目:jdk8u-jdk    文件:SnmpMibTable.java   
/**
 * Enable this <CODE>SnmpMibTable</CODE> to send a notification.
 *
 * <p>
 * @param notification The notification to send.
 */
private synchronized void sendNotification(Notification notification) {

    // loop on listener
    //
    for(java.util.Enumeration<NotificationListener> k = handbackTable.keys();
        k.hasMoreElements(); ) {

        NotificationListener listener = k.nextElement();

        // Get the associated handback list and the associated filter list
        //
        java.util.Vector<?> handbackList = handbackTable.get(listener) ;
        java.util.Vector<NotificationFilter> filterList =
            filterTable.get(listener) ;

        // loop on handback
        //
        java.util.Enumeration<NotificationFilter> f = filterList.elements();
        for(java.util.Enumeration<?> h = handbackList.elements();
            h.hasMoreElements(); ) {

            Object handback = h.nextElement();
            NotificationFilter filter = f.nextElement();

            if ((filter == null) ||
                 (filter.isNotificationEnabled(notification))) {

                listener.handleNotification(notification,handback) ;
            }
        }
    }
}
项目:jdk8u-jdk    文件:SnmpMibTable.java   
/**
 * Enable to add an SNMP entry listener to this
 * <CODE>SnmpMibTable</CODE>.
 *
 * <p>
 * @param listener The listener object which will handle the
 *    notifications emitted by the registered MBean.
 *
 * @param filter The filter object. If filter is null, no filtering
 *    will be performed before handling notifications.
 *
 * @param handback The context to be sent to the listener when a
 *    notification is emitted.
 *
 * @exception IllegalArgumentException Listener parameter is null.
 */
@Override
public synchronized void
    addNotificationListener(NotificationListener listener,
                            NotificationFilter filter, Object handback)  {

    // Check listener
    //
    if (listener == null) {
        throw new java.lang.IllegalArgumentException
            ("Listener can't be null") ;
    }

    // looking for listener in handbackTable
    //
    Vector<Object> handbackList = handbackTable.get(listener) ;
    Vector<NotificationFilter> filterList = filterTable.get(listener) ;
    if ( handbackList == null ) {
        handbackList = new Vector<>() ;
        filterList = new Vector<>() ;
        handbackTable.put(listener, handbackList) ;
        filterTable.put(listener, filterList) ;
    }

    // Add the handback and the filter
    //
    handbackList.addElement(handback) ;
    filterList.addElement(filter) ;
}
项目:openjdk-jdk10    文件:OldMBeanServerTest.java   
public void removeNotificationListener(
        ObjectName name, NotificationListener listener)
        throws InstanceNotFoundException, ListenerNotFoundException {
    NotificationBroadcaster userMBean =
            (NotificationBroadcaster) getUserMBean(name);
    NotificationListener wrappedListener =
          wrappedListener(name, userMBean, listener);
    userMBean.removeNotificationListener(wrappedListener);
}
项目:jdk8u-jdk    文件:RMIConnector.java   
public void
        addConnectionNotificationListener(NotificationListener listener,
        NotificationFilter filter,
        Object handback) {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.addNotificationListener(listener, filter,
            handback);
}
项目:lazycat    文件:BaseModelMBean.java   
/**
 * Add a notification event listener to this MBean.
 *
 * @param listener
 *            Listener that will receive event notifications
 * @param filter
 *            Filter object used to filter event notifications actually
 *            delivered, or <code>null</code> for no filtering
 * @param handback
 *            Handback object to be sent along with event notifications
 *
 * @exception IllegalArgumentException
 *                if the listener parameter is null
 */
@Override
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
        throws IllegalArgumentException {

    if (listener == null)
        throw new IllegalArgumentException("Listener is null");

    if (log.isDebugEnabled())
        log.debug("addNotificationListener " + listener);

    if (generalBroadcaster == null)
        generalBroadcaster = new BaseNotificationBroadcaster();
    generalBroadcaster.addNotificationListener(listener, filter, handback);

    // We'll send the attribute change notifications to all listeners ( who
    // care )
    // The normal filtering can be used.
    // The problem is that there is no other way to add attribute change
    // listeners
    // to a model mbean ( AFAIK ). I suppose the spec should be fixed.
    if (attributeBroadcaster == null)
        attributeBroadcaster = new BaseNotificationBroadcaster();

    if (log.isDebugEnabled())
        log.debug("addAttributeNotificationListener " + listener);

    attributeBroadcaster.addNotificationListener(listener, filter, handback);
}
项目:openjdk-jdk10    文件:MBeanServerAccessController.java   
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public void addNotificationListener(ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
    throws InstanceNotFoundException {
    checkRead();
    getMBeanServer().addNotificationListener(name, listener,
                                             filter, handback);
}
项目:tomcat7    文件:BaseNotificationBroadcaster.java   
public BaseNotificationBroadcasterEntry(NotificationListener listener,
                                        NotificationFilter filter,
                                        Object handback) {
    this.listener = listener;
    this.filter = filter;
    this.handback = handback;
}
项目:openjdk-jdk10    文件:DefaultMBeanServerInterceptor.java   
private void removeNotificationListener(ObjectName name,
                                        NotificationListener listener,
                                        NotificationFilter filter,
                                        Object handback,
                                        boolean removeAll)
        throws InstanceNotFoundException, ListenerNotFoundException {

    if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
        MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name);
    }

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, null, name, "removeNotificationListener");

    /* We could simplify the code by assigning broadcaster after
       assigning listenerWrapper, but that would change the error
       behavior when both the broadcaster and the listener are
       erroneous.  */

    Class<? extends NotificationBroadcaster> reqClass =
        removeAll ? NotificationBroadcaster.class : NotificationEmitter.class;
    NotificationBroadcaster broadcaster =
        getNotificationBroadcaster(name, instance, reqClass);

    NotificationListener listenerWrapper =
        getListenerWrapper(listener, name, instance, false);

    if (listenerWrapper == null)
        throw new ListenerNotFoundException("Unknown listener");

    if (removeAll)
        broadcaster.removeNotificationListener(listenerWrapper);
    else {
        NotificationEmitter emitter = (NotificationEmitter) broadcaster;
        emitter.removeNotificationListener(listenerWrapper,
                                           filter,
                                           handback);
    }
}
项目:openjdk-jdk10    文件:OldMBeanServerTest.java   
public void addNotificationListener(
        ObjectName name, ObjectName listener,
        NotificationFilter filter, Object handback)
        throws InstanceNotFoundException {
    NotificationListener nl =
            (NotificationListener) getUserMBean(listener);
    addNotificationListener(name, nl, filter, handback);
}
项目:tomcat7    文件:BaseModelMBean.java   
/**
 * Add a notification event listener to this MBean.
 *
 * @param listener Listener that will receive event notifications
 * @param filter Filter object used to filter event notifications
 *  actually delivered, or <code>null</code> for no filtering
 * @param handback Handback object to be sent along with event
 *  notifications
 *
 * @exception IllegalArgumentException if the listener parameter is null
 */
@Override
public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
    throws IllegalArgumentException {

    if (listener == null)
        throw new IllegalArgumentException("Listener is null");

    if( log.isDebugEnabled() ) log.debug("addNotificationListener " + listener);

    if (generalBroadcaster == null)
        generalBroadcaster = new BaseNotificationBroadcaster();
    generalBroadcaster.addNotificationListener
        (listener, filter, handback);

    // We'll send the attribute change notifications to all listeners ( who care )
    // The normal filtering can be used.
    // The problem is that there is no other way to add attribute change listeners
    // to a model mbean ( AFAIK ). I suppose the spec should be fixed.
    if (attributeBroadcaster == null)
        attributeBroadcaster = new BaseNotificationBroadcaster();

    if( log.isDebugEnabled() )
        log.debug("addAttributeNotificationListener " + listener);

    attributeBroadcaster.addNotificationListener
            (listener, filter, handback);
}
项目:jdk8u-jdk    文件:ClientNotifForwarder.java   
void dispatchNotification(TargetedNotification tn,
                          Integer myListenerID,
                          Map<Integer, ClientListenerInfo> listeners) {
    final Notification notif = tn.getNotification();
    final Integer listenerID = tn.getListenerID();

    if (listenerID.equals(myListenerID)) return;
    final ClientListenerInfo li = listeners.get(listenerID);

    if (li == null) {
        logger.trace("NotifFetcher.dispatch",
                     "Listener ID not in map");
        return;
    }

    NotificationListener l = li.getListener();
    Object h = li.getHandback();
    try {
        l.handleNotification(notif, h);
    } catch (RuntimeException e) {
        final String msg =
            "Failed to forward a notification " +
            "to a listener";
        logger.trace("NotifFetcher-run", msg, e);
    }

}
项目:jdk8u-jdk    文件:GarbageCollectorImpl.java   
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);
    }
}
项目:jdk8u-jdk    文件:MBeanServerAccessController.java   
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
    throws InstanceNotFoundException, ListenerNotFoundException {
    checkRead();
    getMBeanServer().removeNotificationListener(name, listener,
                                                filter, handback);
}
项目:OpenJSharp    文件:ClientListenerInfo.java   
public ClientListenerInfo(Integer listenerID,
                          ObjectName name,
                          NotificationListener listener,
                          NotificationFilter filter,
                          Object handback,
                          Subject delegationSubject) {
    this.listenerID = listenerID;
    this.name = name;
    this.listener = listener;
    this.filter = filter;
    this.handback = handback;
    this.delegationSubject = delegationSubject;
}
项目:openjdk-jdk10    文件:DiagnosticCommandImpl.java   
@Override
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(false);
    }
}
项目:openjdk-jdk10    文件:OldMBeanServerTest.java   
public void addNotificationListener(
        ObjectName name, NotificationListener listener,
        NotificationFilter filter, Object handback)
        throws InstanceNotFoundException {
    NotificationBroadcaster userMBean =
            (NotificationBroadcaster) getUserMBean(name);
    NotificationListener wrappedListener =
          wrappedListener(name, userMBean, listener);
    userMBean.addNotificationListener(wrappedListener, filter, handback);
}