Java Code Examples for javax.management.MBeanServerNotification#getMBeanName()

The following examples show how to use javax.management.MBeanServerNotification#getMBeanName() . 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: ClientGui.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private void handleNotificationInAwtEventThread(final Notification notif, final Object paramObject) {
    if (StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) {
        if (!(paramObject instanceof ObjectName)) {
            handle("Invalid notification object type", new ClassCastException(paramObject.getClass().getName()));
            return;
        }
        final ObjectName param = (ObjectName) paramObject;
        final JTextArea text = statusLogTextAreaMap.get(param);
        if (text != null) {
            text.append(notif.getMessage() + '\n');
        }
        return;
    }
    if (notif instanceof MBeanServerNotification) {
        final MBeanServerNotification mbsn = (MBeanServerNotification) notif;
        final ObjectName mbeanName = mbsn.getMBeanName();
        if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notif.getType())) {
            onMBeanRegistered(mbeanName);
        } else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notif.getType())) {
            onMBeanUnregistered(mbeanName);
        }
    }
}
 
Example 2
Source File: ArrayNotificationBuffer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void createdNotification(MBeanServerNotification n) {
    final String shouldEqual =
        MBeanServerNotification.REGISTRATION_NOTIFICATION;
    if (!n.getType().equals(shouldEqual)) {
        logger.warning("createNotification", "bad type: " + n.getType());
        return;
    }

    ObjectName name = n.getMBeanName();
    if (logger.debugOn())
        logger.debug("createdNotification", "for: " + name);

    synchronized (this) {
        if (createdDuringQuery != null) {
            createdDuringQuery.add(name);
            return;
        }
    }

    if (isInstanceOf(mBeanServer, name, broadcasterClass)) {
        addBufferListener(name);
        if (isDisposed())
            removeBufferListener(name);
    }
}
 
Example 3
Source File: ArrayNotificationBuffer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void createdNotification(MBeanServerNotification n) {
    final String shouldEqual =
        MBeanServerNotification.REGISTRATION_NOTIFICATION;
    if (!n.getType().equals(shouldEqual)) {
        logger.warning("createNotification", "bad type: " + n.getType());
        return;
    }

    ObjectName name = n.getMBeanName();
    if (logger.debugOn())
        logger.debug("createdNotification", "for: " + name);

    synchronized (this) {
        if (createdDuringQuery != null) {
            createdDuringQuery.add(name);
            return;
        }
    }

    if (isInstanceOf(mBeanServer, name, broadcasterClass)) {
        addBufferListener(name);
        if (isDisposed())
            removeBufferListener(name);
    }
}
 
Example 4
Source File: ArrayNotificationBuffer.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void createdNotification(MBeanServerNotification n) {
    final String shouldEqual =
        MBeanServerNotification.REGISTRATION_NOTIFICATION;
    if (!n.getType().equals(shouldEqual)) {
        logger.warning("createNotification", "bad type: " + n.getType());
        return;
    }

    ObjectName name = n.getMBeanName();
    if (logger.debugOn())
        logger.debug("createdNotification", "for: " + name);

    synchronized (this) {
        if (createdDuringQuery != null) {
            createdDuringQuery.add(name);
            return;
        }
    }

    if (isInstanceOf(mBeanServer, name, broadcasterClass)) {
        addBufferListener(name);
        if (isDisposed())
            removeBufferListener(name);
    }
}
 
Example 5
Source File: ArrayNotificationBuffer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void createdNotification(MBeanServerNotification n) {
    final String shouldEqual =
        MBeanServerNotification.REGISTRATION_NOTIFICATION;
    if (!n.getType().equals(shouldEqual)) {
        logger.warning("createNotification", "bad type: " + n.getType());
        return;
    }

    ObjectName name = n.getMBeanName();
    if (logger.debugOn())
        logger.debug("createdNotification", "for: " + name);

    synchronized (this) {
        if (createdDuringQuery != null) {
            createdDuringQuery.add(name);
            return;
        }
    }

    if (isInstanceOf(mBeanServer, name, broadcasterClass)) {
        addBufferListener(name);
        if (isDisposed())
            removeBufferListener(name);
    }
}
 
Example 6
Source File: ArrayNotificationBuffer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void createdNotification(MBeanServerNotification n) {
    final String shouldEqual =
        MBeanServerNotification.REGISTRATION_NOTIFICATION;
    if (!n.getType().equals(shouldEqual)) {
        logger.warning("createNotification", "bad type: " + n.getType());
        return;
    }

    ObjectName name = n.getMBeanName();
    if (logger.debugOn())
        logger.debug("createdNotification", "for: " + name);

    synchronized (this) {
        if (createdDuringQuery != null) {
            createdDuringQuery.add(name);
            return;
        }
    }

    if (isInstanceOf(mBeanServer, name, broadcasterClass)) {
        addBufferListener(name);
        if (isDisposed())
            removeBufferListener(name);
    }
}
 
Example 7
Source File: ArrayNotificationBuffer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void createdNotification(MBeanServerNotification n) {
    final String shouldEqual =
        MBeanServerNotification.REGISTRATION_NOTIFICATION;
    if (!n.getType().equals(shouldEqual)) {
        logger.warning("createNotification", "bad type: " + n.getType());
        return;
    }

    ObjectName name = n.getMBeanName();
    if (logger.debugOn())
        logger.debug("createdNotification", "for: " + name);

    synchronized (this) {
        if (createdDuringQuery != null) {
            createdDuringQuery.add(name);
            return;
        }
    }

    if (isInstanceOf(mBeanServer, name, broadcasterClass)) {
        addBufferListener(name);
        if (isDisposed())
            removeBufferListener(name);
    }
}
 
Example 8
Source File: MBeanListener.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(
        final Notification notifIn,
        final Object handback)
{
    if (notifIn instanceof MBeanServerNotification)
    {
        final MBeanServerNotification notif = (MBeanServerNotification) notifIn;
        final ObjectName objectName = notif.getMBeanName();

        boolean match = false;
        if ( mObjectName != null && mObjectName.equals(objectName) )
        {
            match = true;
        }
        else if ( objectName.getDomain().equals( mJMXDomain ) )
        {
            if ( mType != null && mType.equals(objectName.getKeyProperty(TYPE_KEY)) )
            {
                final String mbeanName = objectName.getKeyProperty(NAME_KEY);
                if (mName != null && mName.equals(mbeanName))
                {
                    match = true;
                }
            }
        }

        if ( match )
        {
            final String notifType = notif.getType();
            if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanRegistered(objectName, this);
            }
            else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanUnregistered(objectName, this);
            }
        }
    }
}
 
Example 9
Source File: ServerNotifForwarder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example 10
Source File: ServerNotifForwarder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example 11
Source File: ServerNotifForwarder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example 12
Source File: MBeanListener.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(
        final Notification notifIn,
        final Object handback)
{
    if (notifIn instanceof MBeanServerNotification)
    {
        final MBeanServerNotification notif = (MBeanServerNotification) notifIn;
        final ObjectName objectName = notif.getMBeanName();

        boolean match = false;
        if ( mObjectName != null && mObjectName.equals(objectName) )
        {
            match = true;
        }
        else if ( objectName.getDomain().equals( mJMXDomain ) )
        {
            if ( mType != null && mType.equals(objectName.getKeyProperty(TYPE_KEY)) )
            {
                final String mbeanName = objectName.getKeyProperty(NAME_KEY);
                if (mName != null && mName.equals(mbeanName))
                {
                    match = true;
                }
            }
        }

        if ( match )
        {
            final String notifType = notif.getType();
            if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanRegistered(objectName, this);
            }
            else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanUnregistered(objectName, this);
            }
        }
    }
}
 
Example 13
Source File: ServerNotifForwarder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example 14
Source File: MBeanListener.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(
        final Notification notifIn,
        final Object handback)
{
    if (notifIn instanceof MBeanServerNotification)
    {
        final MBeanServerNotification notif = (MBeanServerNotification) notifIn;
        final ObjectName objectName = notif.getMBeanName();

        boolean match = false;
        if ( mObjectName != null && mObjectName.equals(objectName) )
        {
            match = true;
        }
        else if ( objectName.getDomain().equals( mJMXDomain ) )
        {
            if ( mType != null && mType.equals(objectName.getKeyProperty(TYPE_KEY)) )
            {
                final String mbeanName = objectName.getKeyProperty(NAME_KEY);
                if (mName != null && mName.equals(mbeanName))
                {
                    match = true;
                }
            }
        }

        if ( match )
        {
            final String notifType = notif.getType();
            if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanRegistered(objectName, this);
            }
            else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanUnregistered(objectName, this);
            }
        }
    }
}
 
Example 15
Source File: ServerNotifForwarder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example 16
Source File: ServerNotifForwarder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example 17
Source File: MBeanListener.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(
        final Notification notifIn,
        final Object handback)
{
    if (notifIn instanceof MBeanServerNotification)
    {
        final MBeanServerNotification notif = (MBeanServerNotification) notifIn;
        final ObjectName objectName = notif.getMBeanName();

        boolean match = false;
        if ( mObjectName != null && mObjectName.equals(objectName) )
        {
            match = true;
        }
        else if ( objectName.getDomain().equals( mJMXDomain ) )
        {
            if ( mType != null && mType.equals(objectName.getKeyProperty(TYPE_KEY)) )
            {
                final String mbeanName = objectName.getKeyProperty(NAME_KEY);
                if (mName != null && mName.equals(mbeanName))
                {
                    match = true;
                }
            }
        }

        if ( match )
        {
            final String notifType = notif.getType();
            if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanRegistered(objectName, this);
            }
            else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notifType))
            {
                mCallback.mbeanUnregistered(objectName, this);
            }
        }
    }
}
 
Example 18
Source File: MBeanServerNotificationFilter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invoked before sending the specified notification to the listener.
 * <P>If:
 * <P>- the ObjectName of the concerned MBean is selected (explicitly OR
 * (implicitly and not explicitly deselected))
 * <P>AND
 * <P>- the type of the operation (registration or unregistration) is
 * selected
 * <P>then the notification is sent to the listener.
 *
 * @param notif  The notification to be sent.
 *
 * @return true if the notification has to be sent to the listener, false
 * otherwise.
 *
 * @exception IllegalArgumentException  if null parameter
 */
public synchronized boolean isNotificationEnabled(Notification notif)
    throws IllegalArgumentException {

    if (notif == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
            "isNotificationEnabled", notif);

    // Checks the type first
    String ntfType = notif.getType();
    Vector<String> enabledTypes = getEnabledTypes();
    if (!(enabledTypes.contains(ntfType))) {
        RELATION_LOGGER.logp(Level.FINER,
                MBeanServerNotificationFilter.class.getName(),
                "isNotificationEnabled",
                "Type not selected, exiting");
        return false;
    }

    // We have a MBeanServerNotification: downcasts it
    MBeanServerNotification mbsNtf = (MBeanServerNotification)notif;

    // Checks the ObjectName
    ObjectName objName = mbsNtf.getMBeanName();
    // Is it selected?
    boolean isSelectedFlg = false;
    if (selectedNames != null) {
        // Not all are implicitly selected:
        // checks for explicit selection
        if (selectedNames.size() == 0) {
            // All are explicitly not selected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "No ObjectNames selected, exiting");
            return false;
        }

        isSelectedFlg = selectedNames.contains(objName);
        if (!isSelectedFlg) {
            // Not in the explicit selected list
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName not in selected list, exiting");
            return false;
        }
    }

    if (!isSelectedFlg) {
        // Not explicitly selected: is it deselected?

        if (deselectedNames == null) {
            // All are implicitly deselected and it is not explicitly
            // selected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName not selected, and all " +
                    "names deselected, exiting");
            return false;

        } else if (deselectedNames.contains(objName)) {
            // Explicitly deselected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName explicitly not selected, exiting");
            return false;
        }
    }

    RELATION_LOGGER.logp(Level.FINER,
            MBeanServerNotificationFilter.class.getName(),
            "isNotificationEnabled",
            "ObjectName selected, exiting");
    return true;
}
 
Example 19
Source File: MBeanServerNotificationFilter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invoked before sending the specified notification to the listener.
 * <P>If:
 * <P>- the ObjectName of the concerned MBean is selected (explicitly OR
 * (implicitly and not explicitly deselected))
 * <P>AND
 * <P>- the type of the operation (registration or unregistration) is
 * selected
 * <P>then the notification is sent to the listener.
 *
 * @param notif  The notification to be sent.
 *
 * @return true if the notification has to be sent to the listener, false
 * otherwise.
 *
 * @exception IllegalArgumentException  if null parameter
 */
public synchronized boolean isNotificationEnabled(Notification notif)
    throws IllegalArgumentException {

    if (notif == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
            "isNotificationEnabled", notif);

    // Checks the type first
    String ntfType = notif.getType();
    Vector<String> enabledTypes = getEnabledTypes();
    if (!(enabledTypes.contains(ntfType))) {
        RELATION_LOGGER.logp(Level.FINER,
                MBeanServerNotificationFilter.class.getName(),
                "isNotificationEnabled",
                "Type not selected, exiting");
        return false;
    }

    // We have a MBeanServerNotification: downcasts it
    MBeanServerNotification mbsNtf = (MBeanServerNotification)notif;

    // Checks the ObjectName
    ObjectName objName = mbsNtf.getMBeanName();
    // Is it selected?
    boolean isSelectedFlg = false;
    if (selectedNames != null) {
        // Not all are implicitly selected:
        // checks for explicit selection
        if (selectedNames.size() == 0) {
            // All are explicitly not selected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "No ObjectNames selected, exiting");
            return false;
        }

        isSelectedFlg = selectedNames.contains(objName);
        if (!isSelectedFlg) {
            // Not in the explicit selected list
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName not in selected list, exiting");
            return false;
        }
    }

    if (!isSelectedFlg) {
        // Not explicitly selected: is it deselected?

        if (deselectedNames == null) {
            // All are implicitly deselected and it is not explicitly
            // selected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName not selected, and all " +
                    "names deselected, exiting");
            return false;

        } else if (deselectedNames.contains(objName)) {
            // Explicitly deselected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName explicitly not selected, exiting");
            return false;
        }
    }

    RELATION_LOGGER.logp(Level.FINER,
            MBeanServerNotificationFilter.class.getName(),
            "isNotificationEnabled",
            "ObjectName selected, exiting");
    return true;
}
 
Example 20
Source File: MBeanServerNotificationFilter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invoked before sending the specified notification to the listener.
 * <P>If:
 * <P>- the ObjectName of the concerned MBean is selected (explicitly OR
 * (implicitly and not explicitly deselected))
 * <P>AND
 * <P>- the type of the operation (registration or unregistration) is
 * selected
 * <P>then the notification is sent to the listener.
 *
 * @param notif  The notification to be sent.
 *
 * @return true if the notification has to be sent to the listener, false
 * otherwise.
 *
 * @exception IllegalArgumentException  if null parameter
 */
public synchronized boolean isNotificationEnabled(Notification notif)
    throws IllegalArgumentException {

    if (notif == null) {
        String excMsg = "Invalid parameter.";
        throw new IllegalArgumentException(excMsg);
    }

    RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
            "isNotificationEnabled", notif);

    // Checks the type first
    String ntfType = notif.getType();
    Vector<String> enabledTypes = getEnabledTypes();
    if (!(enabledTypes.contains(ntfType))) {
        RELATION_LOGGER.logp(Level.FINER,
                MBeanServerNotificationFilter.class.getName(),
                "isNotificationEnabled",
                "Type not selected, exiting");
        return false;
    }

    // We have a MBeanServerNotification: downcasts it
    MBeanServerNotification mbsNtf = (MBeanServerNotification)notif;

    // Checks the ObjectName
    ObjectName objName = mbsNtf.getMBeanName();
    // Is it selected?
    boolean isSelectedFlg = false;
    if (selectedNames != null) {
        // Not all are implicitly selected:
        // checks for explicit selection
        if (selectedNames.size() == 0) {
            // All are explicitly not selected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "No ObjectNames selected, exiting");
            return false;
        }

        isSelectedFlg = selectedNames.contains(objName);
        if (!isSelectedFlg) {
            // Not in the explicit selected list
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName not in selected list, exiting");
            return false;
        }
    }

    if (!isSelectedFlg) {
        // Not explicitly selected: is it deselected?

        if (deselectedNames == null) {
            // All are implicitly deselected and it is not explicitly
            // selected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName not selected, and all " +
                    "names deselected, exiting");
            return false;

        } else if (deselectedNames.contains(objName)) {
            // Explicitly deselected
            RELATION_LOGGER.logp(Level.FINER,
                    MBeanServerNotificationFilter.class.getName(),
                    "isNotificationEnabled",
                    "ObjectName explicitly not selected, exiting");
            return false;
        }
    }

    RELATION_LOGGER.logp(Level.FINER,
            MBeanServerNotificationFilter.class.getName(),
            "isNotificationEnabled",
            "ObjectName selected, exiting");
    return true;
}