public void removeNotificationListener(final ObjectName objectName, final NotificationListener listener, final NotificationFilter filter) { if (isConnected()) invokeWithReconnect(new Callable<Void>() { @Override public Void call() throws Exception { getConnectionOrFail().removeNotificationListener(objectName, listener, filter, null); return null; }}); }
/** * Gets a usable MBeanServerConnection. * * Method is threadsafe. * * @returns the MBeanServerConnection * @throws IllegalStateException if not connected. */ private synchronized MBeanServerConnection getConnectionOrFail() { if (isConnected()) return getConnection(); if (triedConnecting) { throw new IllegalStateException("Failed to connect to JMX at "+url); } else { String msg = "Not connected (and not attempted to connect) to JMX at "+url+ (failedReconnecting ? (" (last reconnect failure at "+ Time.makeDateString(failedReconnectingTime) + ")") : ""); throw new IllegalStateException(msg); } }
@Override protected boolean isConnected() { return super.isConnected() && getHelper().isConnected(); }