Class RequestEndedEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.server.RequestEndedEvent
All Implemented Interfaces:
Serializable

public class RequestEndedEvent extends EventObject
Event fired through the service event bus when the framework has handled a request and written the response, on the request thread and before the request interceptors run.

Besides the request, the event tells which request handler handled the request and which exception, if any, made handling it fail. The exception has already been passed to the session ErrorHandler at that point.

A message that a client sends through a push connection is reported without a response and without a request handler. The daily active user tracking that runs for some requests before they reach Flow reports its requests without a response, session or request handler, even though the matching RequestStartedEvent has a response, so a missing response does not by itself mean a push message.

See Also:
  • Constructor Details

    • RequestEndedEvent

      public RequestEndedEvent(VaadinService service, VaadinRequest request, VaadinResponse response, VaadinSession session, RequestHandler handler, Exception failure, Duration duration)
      Creates a new event.
      Parameters:
      service - the service that handled the request, not null
      request - the request, not null
      response - the response, or null for a push message
      session - the session used during the request, or null if the request did not use a session
      handler - the request handler that handled the request, or null if no request handler handled it
      failure - the exception that made handling the request fail, or null if handling it did not fail
      duration - the time from the start of handling the request until now, not null
  • Method Details

    • getService

      public VaadinService getService()
      Gets the service that handled the request.
      Returns:
      the service, not null
    • getRequest

      public VaadinRequest getRequest()
      Gets the request.
      Returns:
      the request, not null
    • getResponse

      public Optional<VaadinResponse> getResponse()
      Gets the response.
      Returns:
      the response, or an empty optional for a push message or a request reported by the daily active user tracking
    • getSession

      public Optional<VaadinSession> getSession()
      Gets the session used during the request.
      Returns:
      the session, or an empty optional if the request did not use a session
    • getHandler

      public Optional<RequestHandler> getHandler()
      Gets the request handler that handled the request. The type of the handler tells what kind of request it was, for example UidlRequestHandler for a client-to-server message.

      A push message is not handled by a request handler, and neither is a request that failed before a handler accepted it.

      Returns:
      the request handler, or an empty optional if no request handler handled the request
    • getFailure

      public Optional<Exception> getFailure()
      Gets the exception that made handling the request fail.

      Failures of push messages are reported as well: the push handling records them with VaadinService.recordRequestFailure(VaadinRequest, Exception).

      Returns:
      the exception, or an empty optional if handling the request did not fail
    • getDuration

      public Duration getDuration()
      Gets the time it took to handle the request, measured from just before the RequestStartedEvent was fired.
      Returns:
      the duration, not null