Class RequestProcessingContext
- java.lang.Object
-
- org.glassfish.jersey.server.internal.process.RequestProcessingContext
-
- All Implemented Interfaces:
RespondingContext
public final class RequestProcessingContext extends java.lang.Object implements RespondingContext
Request processing context. Serves as a hub for all request processing related information and is being passed between stages.
-
-
Field Summary
Fields Modifier and Type Field Description private Ref<Value<AsyncContext>>
asyncContextValueRef
private CloseableService
closeableService
private InjectionManager
injectionManager
private RequestEventBuilder
monitoringEventBuilder
private RequestEventListener
monitoringEventListener
private ContainerRequest
request
private RespondingContext
respondingContext
private UriRoutingContext
routingContext
-
Constructor Summary
Constructors Constructor Description RequestProcessingContext(InjectionManager injectionManager, ContainerRequest request, UriRoutingContext routingContext, RequestEventBuilder monitoringEventBuilder, RequestEventListener monitoringEventListener)
Create new request processing context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncContext
asyncContext()
Get the asynchronous context associated with this request processing context.Value<AsyncContext>
asyncContextValue()
Get aValue
instance holding the asynchronous context associated with this request processing context.CloseableService
closeableService()
Get closeable service associated with the request.Stage<ContainerResponse>
createRespondingRoot()
(Optionally) create a responder chain from all transformations previously pushed into the context.void
initAsyncContext(Value<AsyncContext> lazyContextValue)
Lazily initializeAsyncContext
for this request processing context.InjectionManager
injectionManager()
Get injection manager.RequestEventBuilder
monitoringEventBuilder()
Get request monitoring event builder.void
push(java.util.function.Function<ContainerResponse,ContainerResponse> responseTransformation)
Push response transformation function that should be applied.void
push(ChainableStage<ContainerResponse> stage)
Push chainable response transformation stage that should be applied.ContainerRequest
request()
Get the processed container request.RoutingContext
routingContext()
Get the routing context for the processed container request.void
triggerEvent(RequestEvent.Type eventType)
Trigger a new monitoring event for the currently processed request.(package private) UriRoutingContext
uriRoutingContext()
Get the underlyingUriRoutingContext
instance for the processed container request.
-
-
-
Field Detail
-
injectionManager
private final InjectionManager injectionManager
-
request
private final ContainerRequest request
-
routingContext
private final UriRoutingContext routingContext
-
respondingContext
private final RespondingContext respondingContext
-
closeableService
private final CloseableService closeableService
-
monitoringEventBuilder
private final RequestEventBuilder monitoringEventBuilder
-
monitoringEventListener
private final RequestEventListener monitoringEventListener
-
asyncContextValueRef
private final Ref<Value<AsyncContext>> asyncContextValueRef
-
-
Constructor Detail
-
RequestProcessingContext
public RequestProcessingContext(InjectionManager injectionManager, ContainerRequest request, UriRoutingContext routingContext, RequestEventBuilder monitoringEventBuilder, RequestEventListener monitoringEventListener)
Create new request processing context.- Parameters:
injectionManager
- injection manager / injector.request
- container request.routingContext
- routing context.monitoringEventBuilder
- request monitoring event builder.monitoringEventListener
- registered request monitoring event listener.
-
-
Method Detail
-
request
public ContainerRequest request()
Get the processed container request.- Returns:
- processed container request.
-
routingContext
public RoutingContext routingContext()
Get the routing context for the processed container request.- Returns:
- request routing context.
-
uriRoutingContext
UriRoutingContext uriRoutingContext()
Get the underlyingUriRoutingContext
instance for the processed container request.This instance is used by
RequestProcessingConfigurator
to satisfy injection of multiple types, namely:UriInfo
ExtendedUriInfo
ResourceInfo
- Returns:
- request routing context.
-
closeableService
public CloseableService closeableService()
Get closeable service associated with the request.- Returns:
- closeable service associated with the request.
-
initAsyncContext
public void initAsyncContext(Value<AsyncContext> lazyContextValue)
Lazily initializeAsyncContext
for this request processing context.The
lazyContextValue
will be only invoked once during the first call toasyncContext()
. As such, the asynchronous context for this request can be initialized lazily, on demand.- Parameters:
lazyContextValue
- lazily initializedAsyncContext
instance bound to this request processing context.
-
asyncContext
public AsyncContext asyncContext()
Get the asynchronous context associated with this request processing context. May returnnull
if no asynchronous context has been initialized in this request processing context yet.- Returns:
- asynchronous context associated with this request processing context, or
null
if the asynchronous context has not been initialized yet (seeinitAsyncContext(org.glassfish.jersey.internal.util.collection.Value)
).
-
asyncContextValue
public Value<AsyncContext> asyncContextValue()
Get aValue
instance holding the asynchronous context associated with this request processing context. May return an empty value if no asynchronous context has been initialized in this request processing context yet.- Returns:
- value instance holding the asynchronous context associated with this request processing context.
The returned value may be empty, if no asynchronous context has been initialized yet
(see
initAsyncContext(org.glassfish.jersey.internal.util.collection.Value)
).
-
injectionManager
public InjectionManager injectionManager()
Get injection manager. The returned instance is application-scoped.- Returns:
- application-scoped injection manager.
-
monitoringEventBuilder
public RequestEventBuilder monitoringEventBuilder()
Get request monitoring event builder.- Returns:
- request monitoring event builder.
-
triggerEvent
public void triggerEvent(RequestEvent.Type eventType)
Trigger a new monitoring event for the currently processed request.- Parameters:
eventType
- request event type.
-
push
public void push(java.util.function.Function<ContainerResponse,ContainerResponse> responseTransformation)
Description copied from interface:RespondingContext
Push response transformation function that should be applied.- Specified by:
push
in interfaceRespondingContext
- Parameters:
responseTransformation
- response transformation function.
-
push
public void push(ChainableStage<ContainerResponse> stage)
Description copied from interface:RespondingContext
Push chainable response transformation stage that should be applied.- Specified by:
push
in interfaceRespondingContext
- Parameters:
stage
- response transformation chainable stage.
-
createRespondingRoot
public Stage<ContainerResponse> createRespondingRoot()
Description copied from interface:RespondingContext
(Optionally) create a responder chain from all transformations previously pushed into the context.- Specified by:
createRespondingRoot
in interfaceRespondingContext
- Returns:
- created responder chain root or
null
in case of no registered transformations.
-
-