Class RequestEventImpl
- java.lang.Object
-
- org.glassfish.jersey.server.internal.monitoring.RequestEventImpl
-
- All Implemented Interfaces:
RequestEvent
public class RequestEventImpl extends java.lang.Object implements RequestEvent
Request event
implementation. Instances are immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestEventImpl.Builder
Builder ofRequestEventImpl
.-
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.monitoring.RequestEvent
RequestEvent.ExceptionCause, RequestEvent.Type
-
-
Field Summary
Fields Modifier and Type Field Description private ContainerRequest
containerRequest
private java.lang.Iterable<javax.ws.rs.container.ContainerRequestFilter>
containerRequestFilters
private ContainerResponse
containerResponse
private java.lang.Iterable<javax.ws.rs.container.ContainerResponseFilter>
containerResponseFilters
private RequestEvent.ExceptionCause
exceptionCause
private javax.ws.rs.ext.ExceptionMapper<?>
exceptionMapper
private ExtendedUriInfo
extendedUriInfo
private boolean
responseSuccessfullyMapped
private boolean
responseWritten
private boolean
success
private java.lang.Throwable
throwable
private RequestEvent.Type
type
-
Constructor Summary
Constructors Modifier Constructor Description private
RequestEventImpl(RequestEvent.Type type, ContainerRequest containerRequest, ContainerResponse containerResponse, java.lang.Throwable throwable, ExtendedUriInfo extendedUriInfo, java.lang.Iterable<javax.ws.rs.container.ContainerResponseFilter> containerResponseFilters, java.lang.Iterable<javax.ws.rs.container.ContainerRequestFilter> containerRequestFilters, javax.ws.rs.ext.ExceptionMapper<?> exceptionMapper, boolean success, boolean responseSuccessfullyMapped, RequestEvent.ExceptionCause exceptionCause, boolean responseWritten)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContainerRequest
getContainerRequest()
Get the container request.java.lang.Iterable<javax.ws.rs.container.ContainerRequestFilter>
getContainerRequestFilters()
Getcontainer request filters
used during the request filtering phase.ContainerResponse
getContainerResponse()
Get the container response.java.lang.Iterable<javax.ws.rs.container.ContainerResponseFilter>
getContainerResponseFilters()
Getcontainer response filters
used during the response filtering phase.java.lang.Throwable
getException()
Get the latest exception, if any, thrown by the request and response processing.RequestEvent.ExceptionCause
getExceptionCause()
Get theexception cause
.javax.ws.rs.ext.ExceptionMapper<?>
getExceptionMapper()
Get theExceptionMapper
that was found and used during the exception mapping phase.RequestEvent.Type
getType()
Returns thetype
of this event.ExtendedUriInfo
getUriInfo()
Get theextended uri info
associated with this request.boolean
isResponseSuccessfullyMapped()
Returnstrue
if the response was successfully mapped from an exception byexception mappers
.boolean
isResponseWritten()
Returnstrue
if the response has been successfully written.boolean
isSuccess()
Returntrue
if the request and response has been successfully processed.
-
-
-
Field Detail
-
type
private final RequestEvent.Type type
-
containerRequest
private final ContainerRequest containerRequest
-
containerResponse
private final ContainerResponse containerResponse
-
throwable
private final java.lang.Throwable throwable
-
extendedUriInfo
private final ExtendedUriInfo extendedUriInfo
-
containerResponseFilters
private final java.lang.Iterable<javax.ws.rs.container.ContainerResponseFilter> containerResponseFilters
-
containerRequestFilters
private final java.lang.Iterable<javax.ws.rs.container.ContainerRequestFilter> containerRequestFilters
-
exceptionMapper
private final javax.ws.rs.ext.ExceptionMapper<?> exceptionMapper
-
success
private final boolean success
-
responseSuccessfullyMapped
private final boolean responseSuccessfullyMapped
-
exceptionCause
private final RequestEvent.ExceptionCause exceptionCause
-
responseWritten
private final boolean responseWritten
-
-
Constructor Detail
-
RequestEventImpl
private RequestEventImpl(RequestEvent.Type type, ContainerRequest containerRequest, ContainerResponse containerResponse, java.lang.Throwable throwable, ExtendedUriInfo extendedUriInfo, java.lang.Iterable<javax.ws.rs.container.ContainerResponseFilter> containerResponseFilters, java.lang.Iterable<javax.ws.rs.container.ContainerRequestFilter> containerRequestFilters, javax.ws.rs.ext.ExceptionMapper<?> exceptionMapper, boolean success, boolean responseSuccessfullyMapped, RequestEvent.ExceptionCause exceptionCause, boolean responseWritten)
-
-
Method Detail
-
getContainerRequest
public ContainerRequest getContainerRequest()
Description copied from interface:RequestEvent
Get the container request. The container request is available for all event types. Returned request must not be modified by therequest event listener
.- Specified by:
getContainerRequest
in interfaceRequestEvent
- Returns:
- The non-null container request.
-
getContainerResponse
public ContainerResponse getContainerResponse()
Description copied from interface:RequestEvent
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.- Specified by:
getContainerResponse
in interfaceRequestEvent
- Returns:
- Latest response being processed or
null
if no response has been produced yet.
-
getException
public java.lang.Throwable getException()
Description copied from interface:RequestEvent
Get the latest exception, if any, thrown by the request and response processing. When this method returns not null value, the methodRequestEvent.getExceptionCause()
returns the origin of the exception.- Specified by:
getException
in interfaceRequestEvent
- Returns:
- Exception thrown or
null
if no exception has been thrown.
-
getType
public RequestEvent.Type getType()
Description copied from interface:RequestEvent
Returns thetype
of this event.- Specified by:
getType
in interfaceRequestEvent
- Returns:
- Request event type.
-
getUriInfo
public ExtendedUriInfo getUriInfo()
Description copied from interface:RequestEvent
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).- Specified by:
getUriInfo
in interfaceRequestEvent
- Returns:
- Extended uri info or
null
if it is not available yet.
-
getExceptionMapper
public javax.ws.rs.ext.ExceptionMapper<?> getExceptionMapper()
Description copied from interface:RequestEvent
Get theExceptionMapper
that was found and used during the exception mapping phase.- Specified by:
getExceptionMapper
in interfaceRequestEvent
- Returns:
- Exception mapper or
null
if no exception mapper was found or even needed.
-
getContainerRequestFilters
public java.lang.Iterable<javax.ws.rs.container.ContainerRequestFilter> getContainerRequestFilters()
Description copied from interface:RequestEvent
Getcontainer request filters
used during the request filtering phase.- Specified by:
getContainerRequestFilters
in interfaceRequestEvent
- Returns:
- Container request filters or
null
if no filters were used yet.
-
getContainerResponseFilters
public java.lang.Iterable<javax.ws.rs.container.ContainerResponseFilter> getContainerResponseFilters()
Description copied from interface:RequestEvent
Getcontainer response filters
used during the response filtering phase.- Specified by:
getContainerResponseFilters
in interfaceRequestEvent
- Returns:
- Container response filter or
null
if no filters were used yet.
-
isSuccess
public boolean isSuccess()
Description copied from interface:RequestEvent
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
.- Specified by:
isSuccess
in interfaceRequestEvent
- Returns:
- True if the response was successfully processed.
-
isResponseSuccessfullyMapped
public boolean isResponseSuccessfullyMapped()
Description copied from interface:RequestEvent
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.- Specified by:
isResponseSuccessfullyMapped
in interfaceRequestEvent
- Returns:
- True if the exception occurred and it was successfully mapped into a response.
-
getExceptionCause
public RequestEvent.ExceptionCause getExceptionCause()
Description copied from interface:RequestEvent
Get theexception cause
. This method is relevant only in cases whenRequestEvent.getException()
returns non-null value (for example when handlingRequestEvent.Type.ON_EXCEPTION
) event type.- Specified by:
getExceptionCause
in interfaceRequestEvent
- Returns:
- Exception cause of the latest exception or
null
if no exception has occurred.
-
isResponseWritten
public boolean isResponseWritten()
Description copied from interface:RequestEvent
Returnstrue
if the response has been successfully written.true
is returned even for cases when the written response contains error response code.- Specified by:
isResponseWritten
in interfaceRequestEvent
- Returns:
true
if the response was successfully written;false
when the response has not been written yet or when writing of response failed.
-
-