List of usage examples for javax.management MBeanServerNotification getType
public String getType()
From source file:org.openspaces.focalserver.FocalServer.java
/** * Logs registration events from the local mbeanserver *///from www . ja va 2 s . c om 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:org.apache.geode.admin.jmx.internal.MBeanUtil.java
static void registerServerNotificationListener() { if (mbeanServer == null) { return;//from w w w . j a v a2 s . 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 ww . ja v a2s . c om } 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()); } } }