public interface IResponseFilter
IReceiveEventobject passed. The stream/reader obtained this way cannot be marked, reset or closed, otherwise an exception is thrown.
Implementations are expected to invoke the
IResponseFilterChain object, otherwise the rest of the filters in the chain will get omitted (which is not an error). The return value of the
filter(IReceiveEvent, IResponseFilterChain) method, if non-null and is not reference-equal with
RESTART_SIGNAL, signals the cancellation of the flow.
The filter chain itself is executed within the task submitted to the executor configured for the conversation manager.
An important design principle regarding filters is that they should be stateless as much as possible. All the relevant information about the conversation being executed and the enclosing manager is exposed via the event parameter. Making a filter dependent on the actual conversation manager or conversation object itself is a discouraged design approach. Furthermore, in case a filter is implemented to interact with a series of other filters then it's highly recommended to make them order-invariant.
|Modifier and Type||Field and Description|
The object to be returned from the
|Modifier and Type||Method and Description|
Filters the specified receive event and optionally passes on the control to the rest of the chain.
Returns a descriptor, which is a value-object that can be used to identify the filter for the purpose of chain transformation.
static final java.lang.Object RESTART_SIGNAL
filter(IReceiveEvent, IResponseFilterChain)method to signal that the conversation flow is to be restarted.
java.lang.Object filter(IReceiveEvent event, IResponseFilterChain chain) throws java.io.IOException
RESTART_SIGNALyields the cancellation of the conversation flow.
RESTART_SIGNAL results in the entire flow to be restarted, unless the maximum number of restarts is reached. Note that request parameter/header modifications performed by
request filters and the request listener remain in place within the flow. The original conversation object will not be modified though.
Implementations performing potentially long-running operations are expected to inspect the return value of
IBaseEvent.isCancelledExternally() and return if it signals true.
Note that due to buffering, reading from the stream/writer after having invoked
IResponseFilterChain.filter() on the argument will re-read the response from the beginning. Most
filter implementations are expected to pass on control to the chain as the very end of processing.
Passing control over to the rest of the chain is done as follows:
event- the event, must be non-null
chain- the chain, must be non-null
java.io.IOException- in case of problems reading from the stream/reader