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
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
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
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 4
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 5
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
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 Project: kieker   File: JMXController.java    License: 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 8
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 9
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
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
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 12
@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
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
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
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
/**
 * 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
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 18
/**
 * 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
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 20
/**
 * 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;
}