Package com.yahoo.jdisc.handler
Class FutureResponse
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<Response>
-
- com.yahoo.jdisc.handler.FutureResponse
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<Response>
,ResponseHandler
,java.util.concurrent.Future<Response>
public final class FutureResponse extends com.google.common.util.concurrent.AbstractFuture<Response> implements ResponseHandler
This class provides an implementation ofResponseHandler
that allows you to wait for aResponse
to be returned.- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Constructor Description FutureResponse()
Constructs a new FutureResponse that returns aNullContent
whenhandleResponse(Response)
is invoked.FutureResponse(ContentChannel content)
Constructs a new FutureResponse that returns the givenContentChannel
whenhandleResponse(Response)
is invoked.FutureResponse(ResponseHandler handler)
Constructs a new FutureResponse that calls the givenResponseHandler
whenhandleResponse(Response)
is invoked.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
ContentChannel
handleResponse(Response response)
This method will process the givenResponse
and return aContentChannel
into which the caller can write the Response's content.boolean
isCancelled()
-
-
-
Constructor Detail
-
FutureResponse
public FutureResponse()
Constructs a new FutureResponse that returns a
NullContent
whenhandleResponse(Response)
is invoked.
-
FutureResponse
public FutureResponse(ContentChannel content)
Constructs a new FutureResponse that returns the given
ContentChannel
whenhandleResponse(Response)
is invoked.- Parameters:
content
- The content channel for the Response.
-
FutureResponse
public FutureResponse(ResponseHandler handler)
Constructs a new FutureResponse that calls the given
ResponseHandler
whenhandleResponse(Response)
is invoked.- Parameters:
handler
- The ResponseHandler to invoke.
-
-
Method Detail
-
handleResponse
public ContentChannel handleResponse(Response response)
Description copied from interface:ResponseHandler
This method will process the givenResponse
and return aContentChannel
into which the caller can write the Response's content.- Specified by:
handleResponse
in interfaceResponseHandler
- Parameters:
response
- the Response to handle- Returns:
- the ContentChannel to write the Response content to. Notice that the ContentChannel holds a Container reference, so failure to close this will prevent the Container from ever shutting down.
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning)
-
-