Example usage for javax.management.relation MBeanServerNotificationFilter enableObjectName

List of usage examples for javax.management.relation MBeanServerNotificationFilter enableObjectName

Introduction

In this page you can find the example usage for javax.management.relation MBeanServerNotificationFilter enableObjectName.

Prototype

public synchronized void enableObjectName(ObjectName objectName) throws IllegalArgumentException 

Source Link

Document

Enables MBeanServerNotifications concerning given ObjectName.

Usage

From source file:org.mule.providers.jmx.JmxEndpointBuilder.java

private void setNotificationMBeans(MBeanServerNotificationFilter filter, String[] onames)
        throws MalformedObjectNameException {
    if (onames.length == 0)
        return;/*  w  ww  .  j  a  v  a 2s  . c  o m*/
    if (onames[0].equals("!*")) {
        filter.disableAllObjectNames();
    }
    for (String oname : onames) {
        boolean shallEnable = !oname.startsWith("!");
        if (shallEnable) {
            oname = oname.substring(1);
        }
        if ("*".equals(oname)) {
            if (shallEnable) {
                filter.enableAllObjectNames();
            } else {
                filter.disableAllObjectNames();
            }
            continue;
        }
        try {
            ObjectName objName = new ObjectName(oname);
            if (shallEnable) {
                filter.enableObjectName(objName);
            } else {
                filter.disableObjectName(objName);
            }
        } catch (Exception e) {
            logger.warn("Could not " + (shallEnable ? "enable" : "disable") + " " + oname, e);
        }
    }
}