/** * Unregister controller with this monitor. * * @param controller to be unregistered from stability detection. * @throws java.lang.IllegalArgumentException if {@code controller} is null * @throws java.lang.IllegalStateException if {@code controller}s lock is held by current thread */ public void removeController(final ServiceController<?> controller) throws IllegalArgumentException, IllegalStateException { if (controller == null) { throw new IllegalArgumentException("Controller is null"); } if (holdsLock(controller)) { throw new IllegalStateException("Controller lock is held"); } final ServiceControllerImpl<?> serviceController = (ServiceControllerImpl<?>) controller; final boolean removeMonitorFromController; synchronized (controllersLock) { if (cleanupInProgress) return; awaitRemoveCompletion(); removeInProgress = removeMonitorFromController = controllers.remove(serviceController); } if (!removeMonitorFromController) return; serviceController.removeMonitor(this); synchronized (controllersLock) { removeInProgress = false; controllersLock.notifyAll(); } }
/** * Unregister controller with this monitor. * * @param controller to be unregistered from stability detection. * @throws java.lang.IllegalArgumentException if {@code controller} is null * @throws java.lang.IllegalStateException if {@code controller}s lock is held by current thread */ public void removeController(final ServiceController<?> controller) throws IllegalArgumentException, IllegalStateException { if (controller == null) { throw new IllegalArgumentException("Controller is null"); } if (holdsLock(controller)) { throw new IllegalStateException("Controller lock is held"); } final ServiceControllerImpl<?> serviceController = (ServiceControllerImpl<?>) controller; final boolean removeMonitorFromController; synchronized (controllersLock) { if (cleanupInProgress) return; awaitRemoveCompletion(); removeInProgress = removeMonitorFromController = controllers.remove(serviceController); } if (!removeMonitorFromController) return; serviceController.removeMonitor(this); synchronized (controllersLock) { removeInProgress = false; controllersLock.notifyAll(); } }