IOExitLock.java
/*
* Licensed Materials - Property of IBM
*
* "Restricted Materials of IBM"
*
* 5724-H72
*
* Copyright IBM Corp. 2011, 2024. All Rights Reserved.
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
*/
package com.ibm.wmqfte.exitroutine.api;
import java.io.IOException;
/**
* Represents a lock on a resource for either shared or exclusive access.
* {@link IOExitLock} instances are returned from
* {@link IOExitChannel#tryLock(boolean)} calls and WMQFTE will request the
* release of the lock at the appropriate time during a transfer. Additionally, when
* a {@link IOExitChannel#close()} method is called it will be the
* responsibility of the channel to release any associated locks.
*/
public interface IOExitLock {
/**
* Releases the lock.
* <p>
* After this method has been successfully called the lock is to be deemed as invalid.
*
* @throws IOException
* If the channel associated with the lock is not open or
* another problem occurs while attempting to release the lock.
*/
void release() throws IOException;
/**
* Indicates whether this lock is valid.
* <p>
* A lock is considered valid until its @ {@link #release()} method is
* called or the associated {@link IOExitChannel} is closed.
*
* @return {@code true} if this lock is valid, {@code false} otherwise.
*/
boolean isValid();
/**
* @return {@code true} if this lock is for shared access, {@code false} if
* this lock is for exclusive access.
*/
boolean isShared();
}