类javax.management.NotificationFilter源码实例Demo

下面列出了怎么用javax.management.NotificationFilter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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);
}
 
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);
}
 
源代码3 项目: jdk8u60   文件: 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);
}
 
源代码4 项目: JDKSourceCode1.8   文件: 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);
}
 
源代码5 项目: openjdk-jdk8u   文件: 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);
}
 
源代码6 项目: TencentKona-8   文件: 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);
    }
}
 
源代码7 项目: openjdk-jdk9   文件: 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);
}
 
public BaseNotificationBroadcasterEntry(NotificationListener listener,
                                        NotificationFilter filter,
                                        Object handback) {
    this.listener = listener;
    this.filter = filter;
    this.handback = handback;
}
 
源代码9 项目: TencentKona-8   文件: RMIConnector.java
public void
        addConnectionNotificationListener(NotificationListener listener,
        NotificationFilter filter,
        Object handback) {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.addNotificationListener(listener, filter,
            handback);
}
 
public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {
    removeNotificationListener(name, listener, filter, handback, false);
}
 
源代码11 项目: jdk8u-jdk   文件: 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 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;
}
 
源代码12 项目: openjdk-jdk9   文件: NotificationEmitterSupport.java
public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback) {

    if (listener == null) {
        throw new IllegalArgumentException ("Listener can't be null") ;
    }

    /* Adding a new listener takes O(n) time where n is the number
       of existing listeners.  If you have a very large number of
       listeners performance could degrade.  That's a fairly
       surprising configuration, and it is hard to avoid this
       behaviour while still retaining the property that the
       listenerList is not synchronized while notifications are
       being sent through it.  If this becomes a problem, a
       possible solution would be a multiple-readers single-writer
       setup, so any number of sendNotification() calls could run
       concurrently but they would exclude an
       add/removeNotificationListener.  A simpler but less
       efficient solution would be to clone the listener list
       every time a notification is sent.  */
    synchronized (listenerLock) {
        List<ListenerInfo> newList = new ArrayList<>(listenerList.size() + 1);
        newList.addAll(listenerList);
        newList.add(new ListenerInfo(listener, filter, handback));
        listenerList = newList;
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: RMIConnector.java
public void
        removeConnectionNotificationListener(NotificationListener listener,
        NotificationFilter filter,
        Object handback)
        throws ListenerNotFoundException {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.removeNotificationListener(listener, filter,
            handback);
}
 
源代码14 项目: openjdk-jdk9   文件: DiagnosticCommandImpl.java
@Override
public synchronized void addNotificationListener(NotificationListener listener,
        NotificationFilter filter,
        Object handback) {
    boolean before = hasListeners();
    super.addNotificationListener(listener, filter, handback);
    boolean after = hasListeners();
    if (!before && after) {
        setNotificationEnabled(true);
    }
}
 
源代码15 项目: jdk1.8-source-analysis   文件: JmxMBeanServer.java
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {

    mbsInterceptor.removeNotificationListener(cloneObjectName(name),
                                              listener, filter, handback);
}
 
源代码16 项目: TencentKona-8   文件: NotificationEmitterSupport.java
public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback) {

    if (listener == null) {
        throw new IllegalArgumentException ("Listener can't be null") ;
    }

    /* Adding a new listener takes O(n) time where n is the number
       of existing listeners.  If you have a very large number of
       listeners performance could degrade.  That's a fairly
       surprising configuration, and it is hard to avoid this
       behaviour while still retaining the property that the
       listenerList is not synchronized while notifications are
       being sent through it.  If this becomes a problem, a
       possible solution would be a multiple-readers single-writer
       setup, so any number of sendNotification() calls could run
       concurrently but they would exclude an
       add/removeNotificationListener.  A simpler but less
       efficient solution would be to clone the listener list
       every time a notification is sent.  */
    synchronized (listenerLock) {
        List<ListenerInfo> newList = new ArrayList<>(listenerList.size() + 1);
        newList.addAll(listenerList);
        newList.add(new ListenerInfo(listener, filter, handback));
        listenerList = newList;
    }
}
 
源代码17 项目: JDKSourceCode1.8   文件: 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 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;
}
 
/**
 * 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);
}
 
/**
 * 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);
}
 
源代码20 项目: openjdk-jdk9   文件: JmxMBeanServer.java
public void removeNotificationListener(ObjectName name,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {

    mbsInterceptor.removeNotificationListener(cloneObjectName(name),
                                              listener, filter, handback);
}
 
源代码21 项目: openjdk-jdk8u-backup   文件: RMIConnector.java
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];
}
 
源代码22 项目: openjdk-jdk8u-backup   文件: NotificationSender.java
public void removeNotificationListener(NotificationListener l,
                                       NotificationFilter f,
                                       Object h)
        throws ListenerNotFoundException {
    super.removeNotificationListener(l, f, h);
    listenerCount--;
}
 
源代码23 项目: jdk8u60   文件: 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);
}
 
源代码24 项目: openjdk-jdk8u   文件: NotificationBufferTest.java
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));
            }
        }
    };
}
 
源代码25 项目: openjdk-jdk9   文件: 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);
}
 
源代码26 项目: jdk1.8-source-analysis   文件: RMIConnector.java
public void
        addConnectionNotificationListener(NotificationListener listener,
        NotificationFilter filter,
        Object handback) {
    if (listener == null)
        throw new NullPointerException("listener");
    connectionBroadcaster.addNotificationListener(listener, filter,
            handback);
}
 
源代码27 项目: jdk1.8-source-analysis   文件: RMIConnector.java
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);
    }
}
 
/**
 * 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);
}
 
源代码29 项目: jdk8u60   文件: MBeanServerAccessController.java
/**
 * 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);
}
 
源代码30 项目: TencentKona-8   文件: JmxMBeanServer.java
public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws InstanceNotFoundException, ListenerNotFoundException {

    mbsInterceptor.removeNotificationListener(cloneObjectName(name),
                                              listener, filter, handback);
}
 
 类所在包
 同包方法