Class DefaultClosureMonitor
- java.lang.Object
-
- org.apache.directory.api.ldap.model.cursor.DefaultClosureMonitor
-
- All Implemented Interfaces:
ClosureMonitor
public class DefaultClosureMonitor extends Object implements ClosureMonitor
A basic ClosureMonitor that simply uses a boolean for state and a cause exception. Note that we consciously chose not to synchronize close() operations with checks to see if the monitor state is closed because it costs to synchronize and it's OK for the Cursor not to stop immediately when close() is called.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description DefaultClosureMonitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkNotClosed()
Checks if state of this ClosureMonitor is set to closed and if so, throws the causing Exception.void
close()
Sets monitor state to closed, and sets the cause to a CursorClosedException without an error message string.void
close(Exception cause)
Sets monitor state to closed, and sets the cause to a specific Exception.void
close(String cause)
Sets monitor state to closed, and sets the cause to a CursorClosedException with a specific error message string.Exception
getCause()
Gets the cause of the closure.boolean
isClosed()
Gets whether the state of this ClosureMonitor is set to closed.
-
-
-
Constructor Detail
-
DefaultClosureMonitor
public DefaultClosureMonitor()
-
-
Method Detail
-
close
public final void close()
Sets monitor state to closed, and sets the cause to a CursorClosedException without an error message string.- Specified by:
close
in interfaceClosureMonitor
-
close
public final void close(String cause)
Sets monitor state to closed, and sets the cause to a CursorClosedException with a specific error message string.- Specified by:
close
in interfaceClosureMonitor
- Parameters:
cause
- error message string
-
close
public final void close(Exception cause)
Sets monitor state to closed, and sets the cause to a specific Exception.- Specified by:
close
in interfaceClosureMonitor
- Parameters:
cause
- the exception to associate with the closure
-
getCause
public final Exception getCause()
Gets the cause of the closure.- Specified by:
getCause
in interfaceClosureMonitor
- Returns:
- the causing Exception
-
isClosed
public final boolean isClosed()
Gets whether the state of this ClosureMonitor is set to closed.- Specified by:
isClosed
in interfaceClosureMonitor
- Returns:
- true if state is closed, false if open
-
checkNotClosed
public void checkNotClosed() throws CursorClosedException
Checks if state of this ClosureMonitor is set to closed and if so, throws the causing Exception.- Specified by:
checkNotClosed
in interfaceClosureMonitor
- Throws:
CursorClosedException
- the cause of the closure
-
-