List of usage examples for javax.management NotificationEmitter removeNotificationListener
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException;
Removes a listener from this MBean.
From source file:net.sbbi.upnp.jmx.upnp.UPNPConnectorServer.java
public void stop() throws IOException { MBeanServer server = getMBeanServer(); IOException error = null;// w ww . j a v a2 s . c o m if (exposeMBeansAsUPNP.booleanValue()) { try { ObjectName delegate = new ObjectName("JMImplementation:type=MBeanServerDelegate"); NotificationEmitter emmiter = (NotificationEmitter) MBeanServerInvocationHandler .newProxyInstance(server, delegate, NotificationEmitter.class, false); emmiter.removeNotificationListener(this, null, this); } catch (Exception ex) { // MX4J throws an unexpected ListenerNotFoundException with jre 1.5.06.. works nice with sun JMX impl if (!(ex instanceof ListenerNotFoundException)) { IOException ioEx = new IOException("UPNPConnector stop error"); ioEx.initCause(ex); error = ioEx; } } synchronized (STOP_PROCESS) { // now stop all the remaining Devices for (Iterator i = registeredMBeans.values().iterator(); i.hasNext();) { UPNPMBeanDevice dv = (UPNPMBeanDevice) i.next(); try { dv.stop(); } catch (IOException ex) { log.error("Error during UPNPMBean device stop", ex); } } registeredMBeans.clear(); } } if (exposeUPNPAsMBeans.booleanValue()) { try { server.unregisterMBean(discoveryBeanName); } catch (Exception ex) { IOException ioEx = new IOException("Error occured during MBeans discovery"); ioEx.initCause(ex); throw ioEx; } } if (error != null) { throw error; } }