Interface HttpChannel.Listener
-
- All Superinterfaces:
java.util.EventListener
- All Known Implementing Classes:
HttpChannel.TransientListeners,HttpChannelListeners
- Enclosing class:
- HttpChannel
public static interface HttpChannel.Listener extends java.util.EventListenerListener for
HttpChannelevents.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
Requestobject, 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
ServletInputStreamin 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
method, then an instance ofConnectorare efficiently added toHttpChannel. If additional listeners are added using the deprecatedHttpChannel.addListener(Listener)HttpChannel.TransientListenersmust be added to the connector in order for them to be invoked.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidonAfterDispatch(Request request)Invoked just after the application returns from the first invocation.default voidonBeforeDispatch(Request request)Invoked just before calling the application.default voidonComplete(Request request)Invoked when the request and response processing are complete.default voidonDispatchFailure(Request request, java.lang.Throwable failure)Invoked when the application threw an exception.default voidonRequestBegin(Request request)Invoked just after the HTTP request line and headers have been parsed.default voidonRequestContent(Request request, java.nio.ByteBuffer content)Invoked every time a request content chunk has been parsed, just before making it available to the application.default voidonRequestContentEnd(Request request)Invoked when the end of the request content is detected.default voidonRequestEnd(Request request)Invoked when the request has been fully parsed.default voidonRequestFailure(Request request, java.lang.Throwable failure)Invoked when the request processing failed.default voidonRequestTrailers(Request request)Invoked when the request trailers have been parsed.default voidonResponseBegin(Request request)Invoked just before the response line is written to the network.default voidonResponseCommit(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 voidonResponseContent(Request request, java.nio.ByteBuffer content)Invoked after a response content chunk has been written to the network.default voidonResponseEnd(Request request)Invoked when the response has been fully written.default voidonResponseFailure(Request request, java.lang.Throwable failure)Invoked when the response processing failed.
-
-
-
Method Detail
-
onRequestBegin
default void onRequestBegin(Request request)
Invoked just after the HTTP request line and headers have been parsed.- Parameters:
request- the request object
-
onBeforeDispatch
default void onBeforeDispatch(Request request)
Invoked just before calling the application.- Parameters:
request- the request object
-
onDispatchFailure
default void onDispatchFailure(Request request, java.lang.Throwable failure)
Invoked when the application threw an exception.- Parameters:
request- the request objectfailure- the exception thrown by the application
-
onAfterDispatch
default void onAfterDispatch(Request request)
Invoked just after the application returns from the first invocation.- Parameters:
request- the request object
-
onRequestContent
default void onRequestContent(Request request, java.nio.ByteBuffer content)
Invoked every time a request content chunk has been parsed, just before making it available to the application.- Parameters:
request- the request objectcontent- asliceof the request content chunk
-
onRequestContentEnd
default void onRequestContentEnd(Request request)
Invoked when the end of the request content is detected.- Parameters:
request- the request object
-
onRequestTrailers
default void onRequestTrailers(Request request)
Invoked when the request trailers have been parsed.- Parameters:
request- the request object
-
onRequestEnd
default void onRequestEnd(Request request)
Invoked when the request has been fully parsed.- Parameters:
request- the request object
-
onRequestFailure
default void onRequestFailure(Request request, java.lang.Throwable failure)
Invoked when the request processing failed.- Parameters:
request- the request objectfailure- the request failure
-
onResponseBegin
default void onResponseBegin(Request request)
Invoked just before the response line is written to the network.- Parameters:
request- the request object
-
onResponseCommit
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).- Parameters:
request- the request object
-
onResponseContent
default void onResponseContent(Request request, java.nio.ByteBuffer content)
Invoked after a response content chunk has been written to the network.- Parameters:
request- the request objectcontent- asliceof the response content chunk
-
onResponseEnd
default void onResponseEnd(Request request)
Invoked when the response has been fully written.- Parameters:
request- the request object
-
onResponseFailure
default void onResponseFailure(Request request, java.lang.Throwable failure)
Invoked when the response processing failed.- Parameters:
request- the request objectfailure- the response failure
-
onComplete
default void onComplete(Request request)
Invoked when the request and response processing are complete.- Parameters:
request- the request object
-
-