Example usage for javax.management.relation MBeanServerNotificationFilter enableAllObjectNames

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

Introduction

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

Prototype

public synchronized void enableAllObjectNames() 

Source Link

Document

Enables all MBeanServerNotifications (all ObjectNames are selected).

Usage

From source file:org.apache.helix.tools.JmxDumper.java

public JmxDumper(String jmxService, String domain, String beanClassName, String namePattern, int samplePeriod,
        List<String> fields, List<String> operations, String outputfile, int sampleCount) throws Exception {
    _jmxUrl = jmxService;/*  w  w  w  . j av  a2 s  .  c o  m*/
    _domain = domain;
    _beanClassName = beanClassName;
    _samplePeriod = samplePeriod;
    _outputFields.addAll(fields);
    _operations.addAll(operations);
    _outputFileName = outputfile;
    _namePattern = namePattern;
    _targetSamples = sampleCount;

    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + _jmxUrl + "/jmxrmi");
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

    _mbeanServer = jmxc.getMBeanServerConnection();
    MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
    filter.enableAllObjectNames();
    _mbeanServer.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this, filter, null);
    init();
    _timer = new Timer(true);
    _timer.scheduleAtFixedRate(new SampleTask(), _samplePeriod, _samplePeriod);
}

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

private void setNotificationMBeans(MBeanServerNotificationFilter filter, String[] onames)
        throws MalformedObjectNameException {
    if (onames.length == 0)
        return;//from w w w .jav 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);
        }
    }
}