Class ContextRequest
- All Implemented Interfaces:
Content.Source, Request, Attributes, Invocable
- Direct Known Subclasses:
ContextHandler.CoreContextRequest, ContextHandler.CoreContextRequest, ServletContextRequest
-
Nested Class Summary
Nested classes/interfaces inherited from interface Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.SyntheticNested classes/interfaces inherited from interface Content.Source
Content.Source.FactoryNested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.TaskNested classes/interfaces inherited from interface Request
Request.AttributesWrapper, Request.AuthenticationState, Request.Handler, Request.ServeAs, Request.Wrapper -
Field Summary
Fields inherited from interface Attributes
NULLFields inherited from interface Invocable
__nonBlocking, NOOPFields inherited from interface Request
COOKIE_ATTRIBUTE, DEFAULT_LOCALES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedContextRequest(ContextHandler.ScopedContext context, Request request) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFailureListener(Consumer<Throwable> onFailure) Adds a listener for asynchronous fatal failures.voidaddIdleTimeoutListener(Predicate<TimeoutException> onIdleTimeout) Adds a listener for idle timeouts.voidDemands to invoke the given demand callback parameter when a chunk of content is available.Get theContextassociated with thisRequest.Methods inherited from class Request.Wrapper
addHttpStreamWrapper, asAttributeMap, clearAttributes, consumeAvailable, fail, getAttribute, getAttributeNameSet, getBeginNanoTime, getComponents, getConnectionMetaData, getHeaders, getHeadersNanoTime, getHttpURI, getId, getLength, getMethod, getSession, getTrailers, getTunnelSupport, getWrapped, isSecure, push, read, removeAttribute, setAttribute, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Attributes
equals, hashCodeMethods inherited from interface Content.Source
fail, rewindMethods inherited from interface Invocable
getInvocationType
-
Constructor Details
-
ContextRequest
-
-
Method Details
-
demand
Description copied from interface:RequestDemands to invoke the given demand callback parameter when a chunk of content is available.
See how to use this method idiomatically.
Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the
Runnablecallback and a call to this method. Invocations of the passedRunnableare serialized and a callback fordemandcall is not invoked until any previousdemandcallback has returned. Thus theRunnableshould not block waiting for a callback of a future demand call.The demand callback may be invoked spuriously: a subsequent call to
Content.Source.read()may returnnull.Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.
Calling this method when there is already a pending demand results in an
IllegalStateExceptionto be thrown.If the invocation of the demand callback throws an exception, then
Content.Source.fail(Throwable)is called.- Specified by:
demandin interfaceContent.Source- Specified by:
demandin interfaceRequest- Overrides:
demandin classRequest.Wrapper- Parameters:
demandCallback- the demand callback to invoke when there is a content chunk available.- See Also:
-
addIdleTimeoutListener
Description copied from interface:RequestAdds a listener for idle timeouts.
The listener is a predicate function that should return
trueto indicate that the idle timeout should be handled by the container as a fatal failure (seeRequest.addFailureListener(Consumer)); orfalseto ignore that specific timeout and for another timeout to occur after another idle period.Idle timeout listeners are only invoked if there are no pending
Request.demand(Runnable)orResponse.write(boolean, ByteBuffer, Callback)operations.Listeners are processed in the same order they are added, and the first that returns
truestops the processing of subsequent listeners, which are therefore not invoked.- Specified by:
addIdleTimeoutListenerin interfaceRequest- Overrides:
addIdleTimeoutListenerin classRequest.Wrapper- Parameters:
onIdleTimeout- the idle timeout listener as a predicate function- See Also:
-
addFailureListener
Description copied from interface:RequestAdds a listener for asynchronous fatal failures.
When a listener is called, the effects of the failure have already taken place:
- Pending
Request.demand(Runnable)have been woken up. - Calls to
Request.read()will return theThrowablefailure. - Pending and new
Response.write(boolean, ByteBuffer, Callback)calls will be failed by callingCallback.failed(Throwable)on the callback passed toResponse.write(boolean, ByteBuffer, Callback).
Listeners are processed in the same order they are added.
- Specified by:
addFailureListenerin interfaceRequest- Overrides:
addFailureListenerin classRequest.Wrapper- Parameters:
onFailure- the failure listener as a consumer function- See Also:
- Pending
-
getContext
Description copied from interface:RequestGet theContextassociated with thisRequest.Note that a
Requestshould always have an associatedContextsince if theRequestis not being handled by aContextHandlerthen theContextfromServer.getContext()will be used.- Specified by:
getContextin interfaceRequest- Overrides:
getContextin classRequest.Wrapper- Returns:
- the
Contextassociated with thisRequest. Nevernull. - See Also:
-