Java Code Examples for javax.management.Notification#getType()

The following examples show how to use javax.management.Notification#getType() . 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: SimpleListener.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public synchronized void handleNotification(Notification notification,
                                            Object handback) {
    Utils.debug(Utils.DEBUG_STANDARD,
        "SimpleListener::handleNotification :" + notification);
    try {
        received = true;
        type = notification.getType();
        this.handback = handback;
        handbacks.add(handback);
        nbrec++;
        notify();
    } catch(Exception e) {
        System.out.println("(ERROR) SimpleListener::handleNotification :"
                    + " Caught exception "
                    + e) ;
    }
}
 
Example 2
Source File: RuntimeExceptionTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());
            messageReceived = true;
        }
    }
}
 
Example 3
Source File: RuntimeExceptionTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());
            messageReceived = true;
        }
    }
}
 
Example 4
Source File: SimpleListener.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public synchronized void handleNotification(Notification notification,
                                            Object handback) {
    Utils.debug(Utils.DEBUG_STANDARD,
        "SimpleListener::handleNotification :" + notification);
    try {
        received = true;
        type = notification.getType();
        this.handback = handback;
        handbacks.add(handback);
        nbrec++;
        notify();
    } catch(Exception e) {
        System.out.println("(ERROR) SimpleListener::handleNotification :"
                    + " Caught exception "
                    + e) ;
    }
}
 
Example 5
Source File: RuntimeExceptionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
Example 6
Source File: ReflectionExceptionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
Example 7
Source File: ReflectionExceptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
Example 8
Source File: JMXController.java    From kieker with Apache License 2.0 6 votes vote down vote up
@Override
public final void handleNotification(final Notification notification, final Object handback) {
	if (LOGGER.isInfoEnabled()) {
		final String notificationType = notification.getType();
		final String connectionID;
		if (notification instanceof JMXConnectionNotification) {
			connectionID = ((JMXConnectionNotification) notification).getConnectionId();
		} else {
			connectionID = "unknown";
		}
		if (notificationType.equals(JMXConnectionNotification.OPENED)) {
			LOGGER.info("New JMX remote connection initialized. Connection ID: " + connectionID);
		} else if (notificationType.equals(JMXConnectionNotification.CLOSED)) {
			LOGGER.info("JMX remote connection closed. Connection ID: " + connectionID);
		} else { // unknown message
			LOGGER.info(notificationType + ": " + notification.getMessage() + " (ID: " + connectionID + ")");
		}
	}
}
 
Example 9
Source File: RuntimeExceptionTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
Example 10
Source File: ReflectionExceptionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
Example 11
Source File: ReflectionExceptionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void handleNotification(Notification notification, Object handback) {
    echo(">>> Received notification: " + notification);
    if (notification instanceof MonitorNotification) {
        String type = notification.getType();
        if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
            MonitorNotification mn = (MonitorNotification) notification;
            echo("\tType: " + mn.getType());
            echo("\tTimeStamp: " + mn.getTimeStamp());
            echo("\tObservedObject: " + mn.getObservedObject());
            echo("\tObservedAttribute: " + mn.getObservedAttribute());
            echo("\tDerivedGauge: " + mn.getDerivedGauge());
            echo("\tTrigger: " + mn.getTrigger());

            synchronized (this) {
                messageReceived = true;
                notifyAll();
            }
        }
    }
}
 
Example 12
Source File: OldGarbageCollectorListener.java    From kanela with Apache License 2.0 5 votes vote down vote up
@Override
public void handleNotification(Notification notification, Object handback) {
    val type = notification.getType();
    if(type.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
        val userData = (CompositeData) notification.getUserData();
        val info = GarbageCollectionNotificationInfo.from(userData);
        processGCEvent(info);
    }
}
 
Example 13
Source File: NotifReconnectDeadlockTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(Notification n, Object hb) {

                // treat the client notif to know the end
                if (n instanceof JMXConnectionNotification) {
                    if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {

                        clientState = n.getType();
                        System.out.println(
                           ">>> The client state has been changed to: "+clientState);

                        synchronized(lock) {
                            lock.notifyAll();
                        }
                    }

                    return;
                }

                System.out.println(">>> Do sleep to make reconnection.");
                synchronized(lock) {
                    try {
                        lock.wait(listenerSleep);
                    } catch (Exception e) {
                        // OK
                    }
                }
            }
 
Example 14
Source File: NotifReconnectDeadlockTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(Notification n, Object hb) {

                // treat the client notif to know the end
                if (n instanceof JMXConnectionNotification) {
                    if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {

                        clientState = n.getType();
                        System.out.println(
                           ">>> The client state has been changed to: "+clientState);

                        synchronized(lock) {
                            lock.notifyAll();
                        }
                    }

                    return;
                }

                System.out.println(">>> Do sleep to make reconnection.");
                synchronized(lock) {
                    try {
                        lock.wait(listenerSleep);
                    } catch (Exception e) {
                        // OK
                    }
                }
            }
 
Example 15
Source File: NotifReconnectDeadlockTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void handleNotification(Notification n, Object hb) {

                // treat the client notif to know the end
                if (n instanceof JMXConnectionNotification) {
                    if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {

                        clientState = n.getType();
                        System.out.println(
                           ">>> The client state has been changed to: "+clientState);

                        synchronized(lock) {
                            lock.notifyAll();
                        }
                    }

                    return;
                }

                System.out.println(">>> Do sleep to make reconnection.");
                synchronized(lock) {
                    try {
                        lock.wait(listenerSleep);
                    } catch (Exception e) {
                        // OK
                    }
                }
            }
 
Example 16
Source File: MBeanServerNotificationFilter.java    From openjdk-jdk8u 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 17
Source File: MissingClassTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
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: MissingClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 20
Source File: MBeanServerNotificationFilter.java    From openjdk-jdk8u-backup 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;
}