Example usage for javax.management MBeanServer removeNotificationListener

List of usage examples for javax.management MBeanServer removeNotificationListener

Introduction

In this page you can find the example usage for javax.management MBeanServer removeNotificationListener.

Prototype

public void removeNotificationListener(ObjectName name, NotificationListener listener)
            throws InstanceNotFoundException, ListenerNotFoundException;

Source Link

Usage

From source file:org.hyperic.hq.plugin.weblogic.config.WeblogicAttributeChangeListener.java

public void remove() throws PluginException {

    MBeanServer mServer;

    try {//from  w  w w.ja va 2 s  . c o  m
        mServer = WeblogicUtil.getMBeanServer(this.props);
    } catch (MetricUnreachableException e) {
        throw new PluginException(e.getMessage(), e);
    } catch (MetricNotFoundException e) {
        throw new PluginException(e.getMessage(), e);
    }

    String[] mbeans = translate(this.mbeans);

    for (int i = 0; i < mbeans.length; i++) {
        ObjectName obj;
        try {
            obj = new ObjectName(mbeans[i]);
        } catch (MalformedObjectNameException e) {
            //programmer error.
            throw new IllegalArgumentException(e.getMessage());
        }

        try {
            mServer.removeNotificationListener(obj, this);
            log.info("Removed listener for: " + mbeans[i]);
        } catch (InstanceNotFoundException e) {
            throw new PluginException(mbeans[i] + ": " + e.getMessage(), e);
        } catch (ListenerNotFoundException e) {
            log.warn(mbeans[i] + ": " + e.getMessage());
        }
    }
}