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>>asyncContextValueRefprivate CloseableServicecloseableServiceprivate InjectionManagerinjectionManagerprivate RequestEventBuildermonitoringEventBuilderprivate RequestEventListenermonitoringEventListenerprivate ContainerRequestrequestprivate RespondingContextrespondingContextprivate UriRoutingContextroutingContext
-
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 AsyncContextasyncContext()Get the asynchronous context associated with this request processing context.Value<AsyncContext>asyncContextValue()Get aValueinstance holding the asynchronous context associated with this request processing context.CloseableServicecloseableService()Get closeable service associated with the request.Stage<ContainerResponse>createRespondingRoot()(Optionally) create a responder chain from all transformations previously pushed into the context.voidinitAsyncContext(Value<AsyncContext> lazyContextValue)Lazily initializeAsyncContextfor this request processing context.InjectionManagerinjectionManager()Get injection manager.RequestEventBuildermonitoringEventBuilder()Get request monitoring event builder.voidpush(java.util.function.Function<ContainerResponse,ContainerResponse> responseTransformation)Push response transformation function that should be applied.voidpush(ChainableStage<ContainerResponse> stage)Push chainable response transformation stage that should be applied.ContainerRequestrequest()Get the processed container request.RoutingContextroutingContext()Get the routing context for the processed container request.voidtriggerEvent(RequestEvent.Type eventType)Trigger a new monitoring event for the currently processed request.(package private) UriRoutingContexturiRoutingContext()Get the underlyingUriRoutingContextinstance 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 underlyingUriRoutingContextinstance for the processed container request.This instance is used by
RequestProcessingConfiguratorto satisfy injection of multiple types, namely:UriInfo
ExtendedUriInfoResourceInfo- 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 initializeAsyncContextfor this request processing context.The
lazyContextValuewill 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 initializedAsyncContextinstance bound to this request processing context.
-
asyncContext
public AsyncContext asyncContext()
Get the asynchronous context associated with this request processing context. May returnnullif no asynchronous context has been initialized in this request processing context yet.- Returns:
- asynchronous context associated with this request processing context, or
nullif the asynchronous context has not been initialized yet (seeinitAsyncContext(org.glassfish.jersey.internal.util.collection.Value)).
-
asyncContextValue
public Value<AsyncContext> asyncContextValue()
Get aValueinstance 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:RespondingContextPush response transformation function that should be applied.- Specified by:
pushin interfaceRespondingContext- Parameters:
responseTransformation- response transformation function.
-
push
public void push(ChainableStage<ContainerResponse> stage)
Description copied from interface:RespondingContextPush chainable response transformation stage that should be applied.- Specified by:
pushin 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:
createRespondingRootin interfaceRespondingContext- Returns:
- created responder chain root or
nullin case of no registered transformations.
-
-