/** * Atomic deactivate which makes sure that the maintainer stays the same. * * @param maintainer the current maintainer of this remote * @throws InterruptedException if deactivation is interrupted * @throws CouldNotPerformException if deactivation fails * @throws VerificationFailedException is thrown if the given maintainer does not match the current one */ public void deactivate(final Object maintainer) throws InterruptedException, CouldNotPerformException, VerificationFailedException { if (this.maintainer.equals(maintainer)) { synchronized (maintainerLock) { unlock(maintainer); deactivate(); lock(maintainer); } } else { throw new VerificationFailedException("[" + maintainer + "] is not the current maintainer of this remote"); } }
/** * {@inheritDoc} * * @throws InterruptedException {@inheritDoc} * @throws CouldNotPerformException {@inheritDoc} */ @Override public void activate(final Object maintainer) throws InterruptedException, CouldNotPerformException { if (!isLocked() || this.maintainer.equals(maintainer)) { synchronized (maintainerLock) { unlock(maintainer); activate(); lock(maintainer); } } else { throw new VerificationFailedException("[" + maintainer + "] is not the current maintainer of this remote"); } }