use of javax.management.JMRuntimeException in project geode by apache.
the class MBeanUtil method registerServerNotificationListener.
static void registerServerNotificationListener() {
if (mbeanServer == null) {
return;
}
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());
}
}
Aggregations