Interface RequestHandler
- All Superinterfaces:
SharedResource
- All Known Subinterfaces:
ClientProvider
,DelegatedRequestHandler
- All Known Implementing Classes:
AbstractClientProvider
,AbstractRequestHandler
,NonWorkingClientProvider
,NonWorkingRequestHandler
,ThreadedRequestHandler
Request
. To activate a
RequestHandler it must be bound
to a UriPattern
within a
ContainerBuilder
, and that builder must be activated
.- Author:
- Simon Thoresen Hult
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.yahoo.jdisc.SharedResource
SharedResource.Debug
-
Field Summary
Fields inherited from interface com.yahoo.jdisc.SharedResource
DEBUG, SYSTEM_PROPERTY_NAME_DEBUG
-
Method Summary
Modifier and TypeMethodDescriptionhandleRequest
(Request request, ResponseHandler handler) This method will process the givenRequest
and return aContentChannel
into which the caller can write the Request's content.void
handleTimeout
(Request request, ResponseHandler handler) This method is called by theContainer
when aRequest
that was previously accepted byhandleRequest(Request, ResponseHandler)
has timed out.Methods inherited from interface com.yahoo.jdisc.SharedResource
refer, refer, release
-
Method Details
-
handleRequest
This method will process the given
Request
and return aContentChannel
into which the caller can write the Request's content. For every call to this method, the implementation must call the providedResponseHandler
exactly once.Notice that unless this method throws an Exception, a reference to the currently active
Container
instance is kept internally untilResponseHandler.handleResponse(Response)
has been called. This ensures that the configured environment of the Request is stable throughout its lifetime. Failure to call back with a Response will prevent the release of that reference, and therefore prevent the corresponding Container from ever shutting down. The requirement to callResponseHandler.handleResponse(Response)
is regardless of any subsequent errors that may occur while working with the returned ContentChannel.- Parameters:
request
- The Request to handle.handler
- The handler to pass the correspondingResponse
to.- Returns:
- The ContentChannel to write the Request content to. Notice that the ContentChannel itself also holds a Container reference, so failure to close this will prevent the Container from ever shutting down.
-
handleTimeout
This method is called by the
Container
when aRequest
that was previously accepted byhandleRequest(Request, ResponseHandler)
has timed out. If the Request has no timeout (i.e.Request.getTimeout(TimeUnit)
returns null), then this method is never called.The given
ResponseHandler
is the same ResponseHandler that was initially passed to thehandleRequest(Request, ResponseHandler)
method, and it is guarded by a volatile boolean so that only the first call toResponseHandler.handleResponse(Response)
is actually passed on. This means that you do NOT need to manage the ResponseHandlers yourself to prevent a late Response from calling the same ResponseHandler.Notice that you MUST call
ResponseHandler.handleResponse(Response)
as a reaction to having this method invoked. Failure to do so will prevent the Container from ever shutting down.- Parameters:
request
- The Request that has timed out.handler
- The handler to pass the timeoutResponse
to.- See Also:
-