public interface IConversationFlowListener extends ICancellationByRequestFilterListener, ICancellationByRequestListenerListener, ICancellationByResponseFilterListener, IExternalCancellationListener, IMaximumRestartsReachedListener, ICommunicationErrorListener, IConversationCompletionListener
HttpConversationManager.setDefaultFlowListener(IConversationFlowListener)
or via the IHttpConversation.setFlowListener(IConversationFlowListener)
.
This interface extends a bunch of single-method interfaces. This is to leverage Java 8 lambda expressions. Read the documentation of prepareFor()
to understand how this can be put to good use.
Modifier and Type | Interface and Description |
---|---|
static class |
IConversationFlowListener.Builder
Internally used builder class.
|
Modifier and Type | Method and Description |
---|---|
static IConversationFlowListener.Builder |
prepareFor()
Prepares for handling a series of events.
|
onCancellationByRequestFilter
onCancellationByRequestListener
onCancellationByResponseFilter
onExternalCancellation
onMaximumRestartsReached
onCommunicationError
onCompletion
static IConversationFlowListener.Builder prepareFor()
The below code creates a listener that listens for external cancellation, communication error and completion of a particular conversation:
IConversationFlowListener listener = IConversationFlowListener.prepareFor() .externalCancellation(event -> { ... }) .communicationError(e -> { ... }) .completion(() -> { ... }) .build();
The listeners created this way can be set to individual conversations using
IHttpConversation.setFlowListener(IConversationFlowListener)
or as a default one on a conversation manager using HttpConversationManager.setDefaultFlowListener(IConversationFlowListener)
.
This method is a lambda-enabled alternative for the EmptyFlowListener
. The above example is functionally
equivalent to:
IConversationFlowListener listener = new EmptyFlowListener() { @Override public void onExternalCancellation(ICancellationEvent event) { ... } @Override public void onCommunicationError(IOException e) { ... } @Override public void onCompletion() { ... } };