Class NonWorkingClientProvider
- java.lang.Object
-
- com.yahoo.jdisc.NoopSharedResource
-
- com.yahoo.jdisc.test.NonWorkingClientProvider
-
- All Implemented Interfaces:
RequestHandler
,ClientProvider
,SharedResource
public final class NonWorkingClientProvider extends NoopSharedResource implements ClientProvider
- Author:
- Simon Thoresen Hult
-
-
Field Summary
-
Fields inherited from interface com.yahoo.jdisc.SharedResource
DEBUG, SYSTEM_PROPERTY_NAME_DEBUG
-
-
Constructor Summary
Constructors Constructor Description NonWorkingClientProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentChannel
handleRequest(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 byRequestHandler.handleRequest(Request, ResponseHandler)
has timed out.void
start()
This is a synchronous method to configure this ClientProvider.-
Methods inherited from class com.yahoo.jdisc.NoopSharedResource
refer, release
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.yahoo.jdisc.SharedResource
refer, release
-
-
-
-
Method Detail
-
start
public void start()
Description copied from interface:ClientProvider
This is a synchronous method to configure this ClientProvider. The
Container
does not call this method, instead it is a required step in theApplication
initialization code.- Specified by:
start
in interfaceClientProvider
-
handleRequest
public ContentChannel handleRequest(Request request, ResponseHandler handler)
Description copied from interface:RequestHandler
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.- Specified by:
handleRequest
in interfaceRequestHandler
- 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
public void handleTimeout(Request request, ResponseHandler handler)
Description copied from interface:RequestHandler
This method is called by the
Container
when aRequest
that was previously accepted byRequestHandler.handleRequest(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 theRequestHandler.handleRequest(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.- Specified by:
handleTimeout
in interfaceRequestHandler
- Parameters:
request
- The Request that has timed out.handler
- The handler to pass the timeoutResponse
to.- See Also:
Response.dispatchTimeout(ResponseHandler)
-
-