Interface RequestEvent
public interface RequestEvent
An event informing about details of a request processing. The event is created by a Jersey runtime and
handled by
RequestEventListener
(javadoc of listener describes how to register the listener for
particular request).
The event contains the RequestEvent.Type
which distinguishes between types of event. There are various
properties in the event (accessible by getters) and some of them might be relevant only to specific event types.
Note that internal state of the event must be modified. Even the event is immutable it exposes objects
which might be mutable and the code of event listener must not change state of these objects.- Author:
- Miroslav Fuksa
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Describes the origin of the exception.static enum
The type of the event which describes in which request processing phase the event is triggered. -
Method Summary
Modifier and TypeMethodDescriptionGet the container request.Getcontainer request filters
used during the request filtering phase.Get the container response.Getcontainer response filters
used during the response filtering phase.Get the latest exception, if any, thrown by the request and response processing.Get theexception cause
.Get theExceptionMapper
that was found and used during the exception mapping phase.getType()
Returns thetype
of this event.Get theextended uri info
associated with this request.boolean
Returnstrue
if the response was successfully mapped from an exception byexception mappers
.boolean
Returnstrue
if the response has been successfully written.boolean
Returntrue
if the request and response has been successfully processed.
-
Method Details
-
getType
RequestEvent.Type getType()Returns thetype
of this event.- Returns:
- Request event type.
-
getContainerRequest
ContainerRequest getContainerRequest()Get the container request. The container request is available for all event types. Returned request must not be modified by therequest event listener
.- Returns:
- The non-null container request.
-
getContainerResponse
ContainerResponse getContainerResponse()Get the container response. The response is available only for certainevent types
. The returned response might vary also on the event type. The getter returns always the latest response being processed. So, for example for eventRequestEvent.Type.EXCEPTION_MAPPING_FINISHED
event type the method returns mapped response and not the original response created from execution of the resource method.- Returns:
- Latest response being processed or
null
if no response has been produced yet.
-
getException
Throwable getException()Get the latest exception, if any, thrown by the request and response processing. When this method returns not null value, the methodgetExceptionCause()
returns the origin of the exception.- Returns:
- Exception thrown or
null
if no exception has been thrown.
-
getUriInfo
ExtendedUriInfo getUriInfo()Get theextended uri info
associated with this request. This method returns null forRequestEvent.Type.START
event. The returnedExtendedUriInfo
can be used to retrieve information relevant to many event types (especially event types describing the matching process).- Returns:
- Extended uri info or
null
if it is not available yet.
-
getExceptionMapper
ExceptionMapper<?> getExceptionMapper()Get theExceptionMapper
that was found and used during the exception mapping phase.- Returns:
- Exception mapper or
null
if no exception mapper was found or even needed.
-
getContainerRequestFilters
Iterable<ContainerRequestFilter> getContainerRequestFilters()Getcontainer request filters
used during the request filtering phase.- Returns:
- Container request filters or
null
if no filters were used yet.
-
getContainerResponseFilters
Iterable<ContainerResponseFilter> getContainerResponseFilters()Getcontainer response filters
used during the response filtering phase.- Returns:
- Container response filter or
null
if no filters were used yet.
-
isSuccess
boolean isSuccess()Returntrue
if the request and response has been successfully processed. Response is successfully processed when the response code is smaller than 400 and response was successfully written. If the exception occurred but was mapped into a response with successful response code and written, this method returnstrue
.- Returns:
- True if the response was successfully processed.
-
isResponseSuccessfullyMapped
boolean isResponseSuccessfullyMapped()Returnstrue
if the response was successfully mapped from an exception byexception mappers
. When exception mapping phase failed or when no exception was thrown at all the, the method returns false. This method is convenient when handling theRequestEvent.Type.EXCEPTION_MAPPING_FINISHED
event type.- Returns:
- True if the exception occurred and it was successfully mapped into a response.
-
getExceptionCause
RequestEvent.ExceptionCause getExceptionCause()Get theexception cause
. This method is relevant only in cases whengetException()
returns non-null value (for example when handlingRequestEvent.Type.ON_EXCEPTION
) event type.- Returns:
- Exception cause of the latest exception or
null
if no exception has occurred.
-
isResponseWritten
boolean isResponseWritten()Returnstrue
if the response has been successfully written.true
is returned even for cases when the written response contains error response code.- Returns:
true
if the response was successfully written;false
when the response has not been written yet or when writing of response failed.
-