List of usage examples for javax.management MBeanServerConnection removeNotificationListener
public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException;
Removes a listener from a registered MBean.
If the listener is registered more than once, perhaps with different filters or callbacks, this method will remove all those registrations.
From source file:com.continuent.tungsten.common.jmx.JmxManager.java
/** * Remove NotificationListener from this MBean. * /*from w w w. j av a 2 s. c o m*/ * @param jmxConnector The MBean server connector. * @param mbeanClass The class for which an MBean exists. * @param notificationListener Previously added NotificationListener * instance. * @throws Exception */ static public void removeNotificationListener(JMXConnector jmxConnector, Class<?> mbeanClass, NotificationListener notificationListener) throws Exception { MBeanServerConnection mbsc = jmxConnector.getMBeanServerConnection(); ObjectName objectName = generateMBeanObjectName(mbeanClass); mbsc.removeNotificationListener(objectName, notificationListener); }
From source file:com.continuent.tungsten.common.jmx.JmxManager.java
/** * Remove NotificationListener from this MBean. * /*from w w w .j av a 2 s.com*/ * @param jmxConnector The MBean server connector. * @param mbeanInterface The MBean interface this instance implements. * @param mbeanName A custom name for the MBean. * @param notificationListener Previously added NotificationListener * instance. * @throws Exception */ static public void removeNotificationListener(JMXConnector jmxConnector, Class<?> mbeanInterface, String mbeanName, NotificationListener notificationListener, boolean ignored) throws Exception { MBeanServerConnection mbsc = jmxConnector.getMBeanServerConnection(); ObjectName objectName = generateMBeanObjectName(mbeanInterface.getName(), mbeanName); mbsc.removeNotificationListener(objectName, notificationListener); }
From source file:io.fabric8.spi.process.AbstractProcessHandler.java
@Override public final Future<ManagedProcess> start() { State state = managedProcess.getState(); assertNotDestroyed(state);//w ww .jav a 2 s . co m // Setup a call back notification to get the JMX connection of the started process final CountDownLatch latch = new CountDownLatch(1); String jmxAgentServiceURL = managedProcess .getAttribute(ContainerAttributes.ATTRIBUTE_KEY_AGENT_JMX_SERVER_URL); String jmxAgentUsername = managedProcess.getAttribute(ContainerAttributes.ATTRIBUTE_KEY_AGENT_JMX_USERNAME); String jmxAgentPassword = managedProcess.getAttribute(ContainerAttributes.ATTRIBUTE_KEY_AGENT_JMX_PASSWORD); JMXConnector connector = ManagementUtils.getJMXConnector(jmxAgentServiceURL, jmxAgentUsername, jmxAgentPassword, 200, TimeUnit.MILLISECONDS); try { final MBeanServerConnection server = connector.getMBeanServerConnection(); server.addNotificationListener(Agent.OBJECT_NAME, new NotificationListener() { @Override public void handleNotification(Notification notification, Object handback) { String eventType = notification.getType(); if (NOTIFICATION_TYPE_AGENT_REGISTRATION.equals(eventType)) { AgentRegistration agentReg = (AgentRegistration) notification.getSource(); String agentName = agentReg.getIdentity().getName(); String procName = (String) handback; if (agentName.equals(procName)) { try { server.removeNotificationListener(Agent.OBJECT_NAME, this); } catch (Exception ex) { // ignore } latch.countDown(); } } } }, null, managedProcess.getIdentity().getName()); } catch (RuntimeException rte) { throw rte; } catch (Exception ex) { throw new IllegalStateException(ex); } finally { IOUtils.safeClose(connector); } try { if (state == State.CREATED || state == State.STOPPED) { doStart(managedProcess); IllegalStateAssertion.assertNotNull(process, "No process created"); managedProcess.setState(State.STARTED); } } catch (Exception ex) { throw new LifecycleException("Cannot start container", ex); } return new ProcessFuture(managedProcess); //, latch); }
From source file:org.helios.collector.jmx.connection.AbstractMBeanServerConnectionFactory.java
/** * Removes a registered notification listener * @param objectName/*from w w w . j a v a 2s. c o m*/ * @param listener * @throws InstanceNotFoundException * @throws ListenerNotFoundException * @throws IOException */ @Override @ManagedOperation public void removeNotificationListener(ObjectName objectName, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { validateConn(); MBeanServerConnection conn = null; try { conn = getPooledConnection(); conn.removeNotificationListener(objectName, listener); } catch (MBeanServerConnectionFactoryException e) { throw new RuntimeException("Failed to get pooled connection", e); } finally { try { this.returnPooledConnection(conn); } catch (Exception e) { log.debug(e.getMessage()); } } }
From source file:org.helios.collector.jmx.connection.AbstractMBeanServerConnectionFactory.java
/** * Removes a registered notification listener * @param objectName/*from w ww .j a v a2s . c om*/ * @param listener * @throws InstanceNotFoundException * @throws ListenerNotFoundException * @throws IOException */ @Override @ManagedOperation public void removeNotificationListener(ObjectName objectName, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { validateConn(); MBeanServerConnection conn = null; try { conn = getPooledConnection(); conn.removeNotificationListener(objectName, listener); } catch (MBeanServerConnectionFactoryException e) { throw new RuntimeException("Failed to get pooled connection", e); } finally { try { this.returnPooledConnection(conn); } catch (Exception e) { log.debug(e.getMessage()); } } }
From source file:org.hyperic.hq.product.jmx.MxNotificationListener.java
public void remove() throws PluginException { MBeanServerConnection mServer; try {/*from w w w . j a v a2s . c o m*/ mServer = MxUtil.getMBeanServer(this.props); } catch (Exception e) { throw new PluginException("getMBeanServer(" + this.props + "): " + 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 (ListenerNotFoundException e) { log.warn(mbeans[i] + ": " + e.getMessage()); } catch (Exception e) { throw new PluginException("removeNotificationListener(" + mbeans[i] + "): " + e.getMessage(), e); } } }