List of usage examples for javax.management MBeanServerNotification getMBeanName
public ObjectName getMBeanName()
From source file:org.openspaces.focalserver.FocalServer.java
/** * Logs registration events from the local mbeanserver *///from w w w . j a v a 2 s . c o m public void handleNotification(Notification notification, Object object) { if (notification instanceof MBeanServerNotification) { Logger logger = Logger.getLogger(FocalServer.class.getName()); MBeanServerNotification mBeanServerNotification = (MBeanServerNotification) notification; if (mBeanServerNotification.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) { ObjectName beanName = mBeanServerNotification.getMBeanName(); logger.log(Level.FINE, "Registered:" + beanName); } else { logger.log(Level.FINE, "Unregistered:" + mBeanServerNotification.getMBeanName()); } } }
From source file:net.sbbi.upnp.jmx.upnp.UPNPConnectorServer.java
public void handleNotification(Notification notification, Object handBack) { if (notification.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) { MBeanServerNotification regNot = (MBeanServerNotification) notification; MBeanServer srv = getMBeanServer(); ObjectName name = regNot.getMBeanName(); try {/*from w ww. j a va 2 s . c o m*/ ObjectInstance objIn = srv.getObjectInstance(name); String className = objIn.getClassName(); // do not expose as UPN, UPNP devices exposed as MBeans ( class UPNPServiceMBean purpose ) if (className.equals(UPNPServiceMBean.class.getName())) return; if (builder.select(name, className)) { MBeanInfo info = srv.getMBeanInfo(name); UPNPMBeanDevice dv = builder.buildUPNPMBean(getMBeanServer(), objIn, info); if (dv != null) { dv.setBindAddress(sktAddress); dv.start(); registeredMBeans.put(name.toString(), dv); } } } catch (Exception ex) { log.error("Error during UPNP Mbean device " + name.toString() + " creation", ex); } } else if (notification.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { MBeanServerNotification regNot = (MBeanServerNotification) notification; String beanName = regNot.getMBeanName().toString(); synchronized (STOP_PROCESS) { UPNPMBeanDevice dv = (UPNPMBeanDevice) registeredMBeans.get(beanName); if (dv != null) { try { dv.stop(); } catch (Exception ex) { log.error("Error during UPNPMBean device stop", ex); } registeredMBeans.remove(beanName); } } } }
From source file:org.apache.geode.admin.jmx.internal.MBeanUtil.java
static void registerServerNotificationListener() { if (mbeanServer == null) { return;//from w w w .jav a 2s .c o m } try { // the MBeanServerDelegate name is spec'ed as the following... ObjectName delegate = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); mbeanServer.addNotificationListener(delegate, new NotificationListener() { public void handleNotification(Notification notification, Object handback) { MBeanServerNotification serverNotification = (MBeanServerNotification) notification; if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(serverNotification.getType())) { ObjectName objectName = serverNotification.getMBeanName(); synchronized (MBeanUtil.managedResources) { Object entry = MBeanUtil.managedResources.get(objectName); if (entry == null) return; if (!(entry instanceof ManagedResource)) { throw new ClassCastException(LocalizedStrings.MBeanUtil_0_IS_NOT_A_MANAGEDRESOURCE .toLocalizedString(new Object[] { entry.getClass().getName() })); } ManagedResource resource = (ManagedResource) entry; { // call cleanup on managedResource cleanupResource(resource); } } } } }, null, null); } catch (JMException e) { logStackTrace(Level.WARN, e, LocalizedStrings.MBeanUtil_FAILED_TO_REGISTER_SERVERNOTIFICATIONLISTENER.toLocalizedString()); } catch (JMRuntimeException e) { logStackTrace(Level.WARN, e, LocalizedStrings.MBeanUtil_FAILED_TO_REGISTER_SERVERNOTIFICATIONLISTENER.toLocalizedString()); } }
From source file:org.apache.helix.tools.JmxDumper.java
@Override public void handleNotification(Notification notification, Object handback) { MBeanServerNotification mbs = (MBeanServerNotification) notification; if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(mbs.getType())) { // System.out.println("Adding mbean " + mbs.getMBeanName()); _logger.info("Adding mbean " + mbs.getMBeanName()); if (mbs.getMBeanName().getDomain().equalsIgnoreCase(_domain)) { addMBean(mbs.getMBeanName()); }// w w w . j a va2 s . c o m } else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(mbs.getType())) { // System.out.println("Removing mbean " + mbs.getMBeanName()); _logger.info("Removing mbean " + mbs.getMBeanName()); if (mbs.getMBeanName().getDomain().equalsIgnoreCase(_domain)) { removeMBean(mbs.getMBeanName()); } } }