java类javax.management.NotificationFilter的实例源码

RequiredModelMBean.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
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");
    }

}
RMIConnector.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
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);
}
ClientNotifForwarder.java 文件源码 项目:openjdk-jdk10 阅读 28 收藏 0 点赞 0 评论 0
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);
}
ClientNotifForwarder.java 文件源码 项目:openjdk-jdk10 阅读 27 收藏 0 点赞 0 评论 0
public synchronized Integer
getListenerId(ObjectName name,
               NotificationListener listener,
               NotificationFilter filter,
               Object handback)
        throws ListenerNotFoundException, IOException {

    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();
            break;
        }
    }

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

    return id;
}
PogamutMBeanServer.java 文件源码 项目:Pogamut3 阅读 25 收藏 0 点赞 0 评论 0
public Listener1(ObjectName name,
        ObjectName 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();
}
PogamutMBeanServer.java 文件源码 项目:Pogamut3 阅读 33 收藏 0 点赞 0 评论 0
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();
}
PogamutMBeanServer.java 文件源码 项目:Pogamut3 阅读 26 收藏 0 点赞 0 评论 0
@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);
}
OldMBeanServerTest.java 文件源码 项目:openjdk-jdk10 阅读 28 收藏 0 点赞 0 评论 0
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);
}
ServerNotifForwarder.java 文件源码 项目:openjdk-jdk10 阅读 30 收藏 0 点赞 0 评论 0
public void apply(List<TargetedNotification> targetedNotifs,
                  ObjectName source, Notification notif) {
    // We proceed in two stages here, to avoid holding the listenerMap
    // lock while invoking the filters (which are user code).
    final IdAndFilter[] candidates;
    synchronized (listenerMap) {
        final Set<IdAndFilter> set = listenerMap.get(source);
        if (set == null) {
            logger.debug("bufferFilter", "no listeners for this name");
            return;
        }
        candidates = new IdAndFilter[set.size()];
        set.toArray(candidates);
    }
    // We don't synchronize on targetedNotifs, because it is a local
    // variable of our caller and no other thread can see it.
    for (IdAndFilter idaf : candidates) {
        final NotificationFilter nf = idaf.getFilter();
        if (nf == null || nf.isNotificationEnabled(notif)) {
            logger.debug("bufferFilter", "filter matches");
            final TargetedNotification tn =
                    new TargetedNotification(notif, idaf.getId());
            if (allowNotificationEmission(source, tn))
                targetedNotifs.add(tn);
        }
    }
}
BaseModelMBean.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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);
}
DefaultMBeanServerInterceptor.java 文件源码 项目:openjdk-jdk10 阅读 30 收藏 0 点赞 0 评论 0
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);
    }
}
Basic.java 文件源码 项目:openjdk-jdk10 阅读 28 收藏 0 点赞 0 评论 0
/**
 * MBean Notification support
 * You shouldn't update these methods
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws IllegalArgumentException {
    broadcaster.addNotificationListener(listener, filter, handback);
}
ServerNotifForwarder.java 文件源码 项目:jdk8u-jdk 阅读 27 收藏 0 点赞 0 评论 0
public void apply(List<TargetedNotification> targetedNotifs,
                  ObjectName source, Notification notif) {
    // We proceed in two stages here, to avoid holding the listenerMap
    // lock while invoking the filters (which are user code).
    final IdAndFilter[] candidates;
    synchronized (listenerMap) {
        final Set<IdAndFilter> set = listenerMap.get(source);
        if (set == null) {
            logger.debug("bufferFilter", "no listeners for this name");
            return;
        }
        candidates = new IdAndFilter[set.size()];
        set.toArray(candidates);
    }
    // We don't synchronize on targetedNotifs, because it is a local
    // variable of our caller and no other thread can see it.
    for (IdAndFilter idaf : candidates) {
        final NotificationFilter nf = idaf.getFilter();
        if (nf == null || nf.isNotificationEnabled(notif)) {
            logger.debug("bufferFilter", "filter matches");
            final TargetedNotification tn =
                    new TargetedNotification(notif, idaf.getId());
            if (allowNotificationEmission(source, tn))
                targetedNotifs.add(tn);
        }
    }
}
BaseNotificationBroadcaster.java 文件源码 项目:lazycat 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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 {

    synchronized (entries) {

        // Optimization to coalesce attribute name filters
        if (filter instanceof BaseAttributeFilter) {
            BaseAttributeFilter newFilter = (BaseAttributeFilter) filter;
            Iterator<BaseNotificationBroadcasterEntry> items = entries.iterator();
            while (items.hasNext()) {
                BaseNotificationBroadcasterEntry item = items.next();
                if ((item.listener == listener) && (item.filter != null)
                        && (item.filter instanceof BaseAttributeFilter) && (item.handback == handback)) {
                    BaseAttributeFilter oldFilter = (BaseAttributeFilter) item.filter;
                    String newNames[] = newFilter.getNames();
                    String oldNames[] = oldFilter.getNames();
                    if (newNames.length == 0) {
                        oldFilter.clear();
                    } else {
                        if (oldNames.length != 0) {
                            for (int i = 0; i < newNames.length; i++)
                                oldFilter.addAttribute(newNames[i]);
                        }
                    }
                    return;
                }
            }
        }

        // General purpose addition of a new entry
        entries.add(new BaseNotificationBroadcasterEntry(listener, filter, handback));
    }

}
SnmpMibTable.java 文件源码 项目:jdk8u-jdk 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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) ;
}
GarbageCollectorImpl.java 文件源码 项目:OpenJSharp 阅读 27 收藏 0 点赞 0 评论 0
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);
    }
}
MBeanServerAccessController.java 文件源码 项目:jdk8u-jdk 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
    throws InstanceNotFoundException {
    checkRead();
    getMBeanServer().addNotificationListener(name, listener,
                                             filter, handback);
}
NotificationEmitterSupport.java 文件源码 项目:OpenJSharp 阅读 25 收藏 0 点赞 0 评论 0
public ListenerInfo(NotificationListener listener,
                    NotificationFilter filter,
                    Object handback) {
    this.listener = listener;
    this.filter = filter;
    this.handback = handback;
}
DefaultMBeanServerInterceptor.java 文件源码 项目:OpenJSharp 阅读 36 收藏 0 点赞 0 评论 0
public void addNotificationListener(ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

    // ------------------------------
    // ------------------------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "addNotificationListener", "ObjectName = " + name);
    }

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

    NotificationBroadcaster broadcaster =
            getNotificationBroadcaster(name, instance,
                                       NotificationBroadcaster.class);

    // ------------------
    // Check listener
    // ------------------
    if (listener == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Null listener"),"Null listener");
    }

    NotificationListener listenerWrapper =
        getListenerWrapper(listener, name, instance, true);
    broadcaster.addNotificationListener(listenerWrapper, filter, handback);
}
DefaultMBeanServerInterceptor.java 文件源码 项目:OpenJSharp 阅读 21 收藏 0 点赞 0 评论 0
public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

    // ------------------------------
    // ------------------------------

    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance = getMBean(listener);
    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException(listener.getCanonicalName()),
            "The MBean " + listener.getCanonicalName() +
            "does not implement the NotificationListener interface") ;
    }

    // ----------------
    // Add a listener on an MBean
    // ----------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "addNotificationListener",
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.addNotificationListener(name,(NotificationListener) resource,
                                   filter, handback) ;
}
DefaultMBeanServerInterceptor.java 文件源码 项目:OpenJSharp 阅读 25 收藏 0 点赞 0 评论 0
public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {
    removeNotificationListener(name, listener, filter, handback, false);
}
NotificationBufferTest.java 文件源码 项目:jdk8u-jdk 阅读 33 收藏 0 点赞 0 评论 0
private static NotificationBufferFilter makeFilter(final Integer id,
                                                   final ObjectName pattern,
                                                   final NotificationFilter filter) {
    return new NotificationBufferFilter() {
        public void apply(List<TargetedNotification> notifs,
                          ObjectName source, Notification notif) {
            if (pattern.apply(source)) {
                if (filter == null || filter.isNotificationEnabled(notif))
                    notifs.add(new TargetedNotification(notif, id));
            }
        }
    };
}
JmxMBeanServer.java 文件源码 项目:OpenJSharp 阅读 31 收藏 0 点赞 0 评论 0
public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {

    mbsInterceptor.removeNotificationListener(cloneObjectName(name),
                                              listener, filter, handback);
}
SnmpMibTable.java 文件源码 项目:OpenJSharp 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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) ;
}
MBeanServerAccessController.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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);
}
MBeanServerAccessController.java 文件源码 项目:OpenJSharp 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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);
}
MBeanServerAccessController.java 文件源码 项目:OpenJSharp 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
    throws InstanceNotFoundException {
    checkRead();
    getMBeanServer().addNotificationListener(name, listener,
                                             filter, handback);
}
MBeanServerAccessController.java 文件源码 项目:jdk8u-jdk 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 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);
}
MBeanServerAccessController.java 文件源码 项目:OpenJSharp 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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);
}
RMIConnector.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}


问题


面经


文章

微信
公众号

扫码关注公众号