Interface HttpChannel.Listener
- All Superinterfaces:
EventListener
- All Known Implementing Classes:
HttpChannel.TransientListeners
,HttpChannelListeners
- Enclosing class:
- HttpChannel
Listener for HttpChannel
events.
HttpChannel will emit events for the various phases it goes through while processing an HTTP request and response.
Implementations of this interface may listen to those events to track timing and/or other values such as request URI, etc.
The events parameters, especially the Request
object, may be
in a transient state depending on the event, and not all properties/features
of the parameters may be available inside a listener method.
It is recommended that the event parameters are not acted upon
in the listener methods, or undefined behavior may result. For example, it
would be a bad idea to try to read some content from the
ServletInputStream
in listener methods. On the other
hand, it is legit to store request attributes in one listener method that
may be possibly retrieved in another listener method in a later event.
Listener methods are invoked synchronously from the thread that is performing the request processing, and they should not call blocking code (otherwise the request processing will be blocked as well).
Listener instances that are set as a bean on the Connector
are
efficiently added to HttpChannel
. If additional listeners are added
using the deprecated HttpChannel.addListener(Listener)
HttpChannel.TransientListeners
must be added to the connector
in order for them to be invoked.-
Method Summary
Modifier and TypeMethodDescriptiondefault void
onAfterDispatch
(Request request) Invoked just after the application returns from the first invocation.default void
onBeforeDispatch
(Request request) Invoked just before calling the application.default void
onComplete
(Request request) Invoked when the request and response processing are complete.default void
onDispatchFailure
(Request request, Throwable failure) Invoked when the application threw an exception.default void
onRequestBegin
(Request request) Invoked just after the HTTP request line and headers have been parsed.default void
onRequestContent
(Request request, ByteBuffer content) Invoked every time a request content chunk has been parsed, just before making it available to the application.default void
onRequestContentEnd
(Request request) Invoked when the end of the request content is detected.default void
onRequestEnd
(Request request) Invoked when the request has been fully parsed.default void
onRequestFailure
(Request request, Throwable failure) Invoked when the request processing failed.default void
onRequestTrailers
(Request request) Invoked when the request trailers have been parsed.default void
onResponseBegin
(Request request) Invoked just before the response line is written to the network.default void
onResponseCommit
(Request request) Invoked just after the response is committed (that is, the response line, headers and possibly some content have been written to the network).default void
onResponseContent
(Request request, ByteBuffer content) Invoked after a response content chunk has been written to the network.default void
onResponseEnd
(Request request) Invoked when the response has been fully written.default void
onResponseFailure
(Request request, Throwable failure) Invoked when the response processing failed.
-
Method Details
-
onRequestBegin
Invoked just after the HTTP request line and headers have been parsed.- Parameters:
request
- the request object
-
onBeforeDispatch
Invoked just before calling the application.- Parameters:
request
- the request object
-
onDispatchFailure
Invoked when the application threw an exception.- Parameters:
request
- the request objectfailure
- the exception thrown by the application
-
onAfterDispatch
Invoked just after the application returns from the first invocation.- Parameters:
request
- the request object
-
onRequestContent
Invoked every time a request content chunk has been parsed, just before making it available to the application.- Parameters:
request
- the request objectcontent
- aslice
of the request content chunk
-
onRequestContentEnd
Invoked when the end of the request content is detected.- Parameters:
request
- the request object
-
onRequestTrailers
Invoked when the request trailers have been parsed.- Parameters:
request
- the request object
-
onRequestEnd
Invoked when the request has been fully parsed.- Parameters:
request
- the request object
-
onRequestFailure
Invoked when the request processing failed.- Parameters:
request
- the request objectfailure
- the request failure
-
onResponseBegin
Invoked just before the response line is written to the network.- Parameters:
request
- the request object
-
onResponseCommit
Invoked just after the response is committed (that is, the response line, headers and possibly some content have been written to the network).- Parameters:
request
- the request object
-
onResponseContent
Invoked after a response content chunk has been written to the network.- Parameters:
request
- the request objectcontent
- aslice
of the response content chunk
-
onResponseEnd
Invoked when the response has been fully written.- Parameters:
request
- the request object
-
onResponseFailure
Invoked when the response processing failed.- Parameters:
request
- the request objectfailure
- the response failure
-
onComplete
Invoked when the request and response processing are complete.- Parameters:
request
- the request object
-