Example usage for javax.management.relation MBeanServerNotificationFilter MBeanServerNotificationFilter

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

Introduction

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

Prototype

public MBeanServerNotificationFilter() 

Source Link

Document

Creates a filter selecting all MBeanServerNotification notifications for all ObjectNames.

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 . ja v  a 2s  .  c om*/
    _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 NotificationFilter createNotificationFilter(String authority, Properties params)
        throws MalformedObjectNameException {

    boolean isConnector = URI_AUTHORITY_CONNECTOR.equals(authority);
    boolean isDelegate = URI_AUTHORITY_MBSDELEGATE.equals(authority);

    if (isDelegate && params.containsKey(URIPROP_FILTER_NOTIFBEANS)) {
        MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
        String beansStr = params.getProperty(URIPROP_FILTER_NOTIFBEANS);
        if (beansStr != null) {
            setNotificationMBeans(filter, beansStr.split(";"));
        }/* w  w w.j a v a 2 s. co  m*/

        setNotificationTypes(filter, params, isDelegate, isConnector);
        return filter;
    }

    if (params.containsKey(URIPROP_FILTER_ATTRIBUTES)) {
        AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
        for (String attribute : params.getProperty(URIPROP_FILTER_ATTRIBUTES).split(";")) {
            filter.enableAttribute(attribute);
        }
        return filter;
    }

    if (params.containsKey(URIPROP_FILTER_NOTIFTYPE)) {
        NotificationFilterSupport filter = new NotificationFilterSupport();
        setNotificationTypes(filter, params, isDelegate, isConnector);
        return filter;
    }

    return null;
}