Interface CompletionHandler
-
- All Known Implementing Classes:
FutureCompletion
,NonWorkingCompletionHandler
public interface CompletionHandler
This interface defines a handler for consuming the result of an asynchronous I/O operation.The asynchronous channels defined in this package allow a completion handler to be specified to consume the result of an asynchronous operation. The
completed()
method is invoked when the I/O operation completes successfully. Thefailed(Throwable)
method is invoked if the I/O operations fails. The implementations of these methods should complete in a timely manner so as to avoid keeping the invoking thread from dispatching to other completion handlers.Because a CompletionHandler might have a completely different lifespan than the originating ContentChannel objects, all instances of this interface are internally backed by a reference to the
Container
that was active when the initial Request was created. This ensures that the configured environment of the CompletionHandler is stable throughout its lifetime. This also means that the eithercompleted()
orfailed(Throwable)
MUST be called in order to release that reference. Failure to do so will prevent the Container from ever shutting down.- Author:
- Simon Thoresen Hult
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
completed()
Invoked when an operation has completed.void
failed(java.lang.Throwable t)
Invoked when an operation fails.
-
-
-
Method Detail
-
completed
void completed()
Invoked when an operation has completed. Notice that you MUST call either this orfailed(Throwable)
to release the internalContainer
reference. Failure to do so will prevent the Container from ever shutting down.
-
failed
void failed(java.lang.Throwable t)
Invoked when an operation fails. Notice that you MUST call either this orcompleted()
to release the internalContainer
reference. Failure to do so will prevent the Container from ever shutting down.- Parameters:
t
- The exception to indicate why the I/O operation failed.
-
-