Top Description Methods
org.glassfish.grizzly

public Interface Closeable

Known Direct Subinterfaces
org.glassfish.grizzly.Connection
Imports
java.io.IOException, java.util.concurrent.Future

General 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
java.io.Closeable

Method Summary

Modifier and TypeMethod and Description
public void
addCloseListener(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Add the CloseListener, which will be notified once the stream will be closed.

public void
assertOpen()

Checks if this Closeable is open and ready to be used.

public GrizzlyFuture<Closeable>

Returns:

java.util.concurrent.Future, which could be checked in case, if close operation will be run asynchronously
close
()

Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.

public void
close(CompletionHandler<Closeable>
CompletionHandler to be called, when the stream is closed
completionHandler
)

Gracefully closes this stream and releases any system resources associated with it.

public GrizzlyFuture<CloseReason>
closeFuture()

Returns: the Future, that will be notified once this Closeable is closed

public void
closeSilently()

Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.

public void
closeWithReason(IOException
reason why closed, this will be thrown by isOpen() if called subsequently
cause
)

Gracefully closes the Closeable and provides the reason description.

public boolean

Returns:

true, if Closeable is open and ready, or false otherwise.
isOpen
()

Is Closeable open and ready.

public boolean

Returns:

true if the listener was successfully removed, or false otherwise.
removeCloseListener
(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Remove the CloseListener.

public GrizzlyFuture<Closeable>

Returns:

java.util.concurrent.Future, which could be checked in case, if close operation will be run asynchronously
terminate
()

Closes this stream and releases any system resources associated with it.

public void
terminateSilently()

Closes this stream and releases any system resources associated with it.

public void
terminateWithReason(IOException
reason why terminated. This will be thrown is isOpen() is called subsequently
cause
)

Closes the Closeable and provides the reason description.

Method Detail

addCloseListenerback to summary
public void addCloseListener(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Add the CloseListener, which will be notified once the stream will be closed.

Parameters
closeListener:CloseListener<T extends Closeable, C extends ICloseType>

CloseListener.

assertOpenback to summary
public void assertOpen() throws IOException

Checks if this Closeable is open and ready to be used. If this Closeable is closed then an IOException will be thrown

Exceptions
IOException:
giving the reason why this Closeable was closed.
closeback to summary
public 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:GrizzlyFuture<Closeable>

java.util.concurrent.Future, which could be checked in case, if close operation will be run asynchronously

See Also
which is not asynchronous
closeback to summary
public void close(CompletionHandler<Closeable> completionHandler)

Gracefully 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:CompletionHandler<Closeable>

CompletionHandler to be called, when the stream is closed

Annotations
@Deprecated
closeFutureback to summary
public GrizzlyFuture<CloseReason> closeFuture()
Returns:GrizzlyFuture<CloseReason>

the Future, that will be notified once this Closeable is closed

Since
2.3.24
closeSilentlyback to summary
public 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.

closeWithReasonback to summary
public void closeWithReason(IOException cause)

Gracefully closes the Closeable and provides the reason description. This method is similar to closeSilently(), but additionally provides the reason why the Closeable will be closed.

Parameters
cause:IOException

reason why closed, this will be thrown by isOpen() if called subsequently

isOpenback to summary
public boolean isOpen()

Is Closeable open and ready. Returns true, if the Closeable is open and ready, or false otherwise.

Returns:boolean

true, if Closeable is open and ready, or false otherwise.

removeCloseListenerback to summary
public boolean removeCloseListener(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Remove the CloseListener.

Parameters
closeListener:CloseListener<T extends Closeable, C extends ICloseType>

CloseListener.

Returns:boolean

true if the listener was successfully removed, or false otherwise.

terminateback to summary
public 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:GrizzlyFuture<Closeable>

java.util.concurrent.Future, which could be checked in case, if close operation will be run asynchronously

terminateSilentlyback to summary
public 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.

terminateWithReasonback to summary
public void terminateWithReason(IOException cause)

Closes the Closeable and provides the reason description. This method is similar to terminateSilently(), but additionally provides the reason why the Closeable will be closed.

Parameters
cause:IOException

reason why terminated. This will be thrown is isOpen() is called subsequently