Package org.glassfish.grizzly
Interface Closeable
-
- All Known Subinterfaces:
Connection<L>
- All Known Implementing Classes:
NIOConnection,TCPNIOConnection,TCPNIOServerConnection,UDPNIOConnection,UDPNIOServerConnection
public interface CloseableGeneral asynchronous closable interface. Closeable interface contains two sets of methods: close* and terminate*, so interface implementations can provide graceful and abrupt releasing of resources.- Author:
- Alexey Stashok
- See Also:
Closeable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddCloseListener(CloseListener closeListener)Add theCloseListener, which will be notified once the stream will be closed.voidassertOpen()Checks if this Closeable is open and ready to be used.GrizzlyFuture<Closeable>close()Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.voidclose(CompletionHandler<Closeable> completionHandler)Deprecated.please useclose()with the followingGrizzlyFuture.addCompletionHandler(org.glassfish.grizzly.CompletionHandler)callGrizzlyFuture<CloseReason>closeFuture()voidcloseSilently()Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.voidcloseWithReason(IOException cause)Gracefully closes the Closeable and provides the reason description.booleanisOpen()Is Closeable open and ready.booleanremoveCloseListener(CloseListener closeListener)Remove theCloseListener.GrizzlyFuture<Closeable>terminate()Closes this stream and releases any system resources associated with it.voidterminateSilently()Closes this stream and releases any system resources associated with it.voidterminateWithReason(IOException cause)Closes the Closeable and provides the reason description.
-
-
-
Method Detail
-
isOpen
boolean isOpen()
Is Closeable open and ready. Returns true, if the Closeable is open and ready, or false otherwise.- Returns:
- true, if Closeable is open and ready, or false otherwise.
-
assertOpen
void assertOpen() throws IOExceptionChecks if this Closeable is open and ready to be used. If this Closeable is closed then an IOException will be thrown- Throws:
IOException- giving the reason why this Closeable was closed.
-
terminateSilently
void terminateSilently()
Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Use this method, when no completion notification is needed.
-
terminate
GrizzlyFuture<Closeable> terminate()
Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.- Returns:
Future, which could be checked in case, if close operation will be run asynchronously
-
terminateWithReason
void terminateWithReason(IOException cause)
Closes the Closeable and provides the reason description. This method is similar toterminateSilently(), but additionally provides the reason why the Closeable will be closed.- Parameters:
cause- reason why terminated. This will be thrown isisOpen()is called subsequently
-
closeSilently
void closeSilently()
Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Use this method, when no completion notification is needed.
-
close
GrizzlyFuture<Closeable> close()
Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.- Returns:
Future, which could be checked in case, if close operation will be run asynchronously- See Also:
which is not asynchronous
-
close
@Deprecated void close(CompletionHandler<Closeable> completionHandler)
Deprecated.please useclose()with the followingGrizzlyFuture.addCompletionHandler(org.glassfish.grizzly.CompletionHandler)callGracefully closes this stream and releases any system resources associated with it. This operation waits for all pending output data to be flushed before closing the stream. If the stream is already closed then invoking this method has no effect.- Parameters:
completionHandler-CompletionHandlerto be called, when the stream is closed
-
closeWithReason
void closeWithReason(IOException cause)
Gracefully closes the Closeable and provides the reason description. This method is similar tocloseSilently(), but additionally provides the reason why the Closeable will be closed.- Parameters:
cause- reason why closed, this will be thrown byisOpen()if called subsequently
-
addCloseListener
void addCloseListener(CloseListener closeListener)
Add theCloseListener, which will be notified once the stream will be closed.- Parameters:
closeListener-CloseListener.
-
removeCloseListener
boolean removeCloseListener(CloseListener closeListener)
Remove theCloseListener.- Parameters:
closeListener-CloseListener.- Returns:
- true if the listener was successfully removed, or false otherwise.
-
closeFuture
GrizzlyFuture<CloseReason> closeFuture()
- Returns:
- the
Future, that will be notified once this Closeable is closed - Since:
- 2.3.24
-
-