Package com.yahoo.container.jdisc
Class ThreadedHttpRequestHandler
- java.lang.Object
-
- com.yahoo.jdisc.AbstractResource
-
- com.yahoo.jdisc.handler.AbstractRequestHandler
-
- com.yahoo.container.jdisc.ThreadedRequestHandler
-
- com.yahoo.container.jdisc.ThreadedHttpRequestHandler
-
- All Implemented Interfaces:
com.yahoo.jdisc.handler.RequestHandler
,com.yahoo.jdisc.SharedResource
- Direct Known Subclasses:
AccessLogRequestHandler
,FilterBackingRequestHandler
,LoggingRequestHandler
,LogHandler
,VipStatusHandler
public abstract class ThreadedHttpRequestHandler extends ThreadedRequestHandler
A simple HTTP request handler, using theHttpRequest
andHttpResponse
classes. Users need to override thehandle(HttpRequest)
method in this class and theHttpResponse.render(java.io.OutputStream)
method.- Author:
- hmusum, Steinar Knutsen, bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThreadedHttpRequestHandler.LazyContentChannel
A content channel which will return the header and create the proper channel the first time content data needs to be written to it.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTENT_TYPE
protected java.util.logging.Logger
log
Logger for subclasses-
Fields inherited from class com.yahoo.container.jdisc.ThreadedRequestHandler
metric
-
-
Constructor Summary
Constructors Constructor Description ThreadedHttpRequestHandler(java.util.concurrent.Executor executor)
ThreadedHttpRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric)
ThreadedHttpRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addDateHeader(HttpResponse httpResponse, long startTime)
protected com.yahoo.jdisc.http.HttpRequest
asHttpRequest(com.yahoo.jdisc.Request request)
protected LoggingCompletionHandler
createLoggingCompletionHandler(long startTime, long renderStartTime, HttpResponse response, HttpRequest httpRequest, ContentChannelOutputStream rendererWiring)
Override this to implement custom access logging.abstract HttpResponse
handle(HttpRequest request)
Override this to implement a synchronous style handler.HttpResponse
handle(HttpRequest request, com.yahoo.jdisc.handler.ContentChannel channel)
Override this rather than handle(request) to be able to write to the channel before returning from this method.void
handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
-
Methods inherited from class com.yahoo.container.jdisc.ThreadedRequestHandler
executor, getRequestType, getTimeout, handleRequest, writeErrorResponseOnOverload
-
Methods inherited from class com.yahoo.jdisc.AbstractResource
currentState, destroy, refer, release, retainCount
-
-
-
-
Field Detail
-
CONTENT_TYPE
public static final java.lang.String CONTENT_TYPE
- See Also:
- Constant Field Values
-
log
protected final java.util.logging.Logger log
Logger for subclasses
-
-
Constructor Detail
-
ThreadedHttpRequestHandler
public ThreadedHttpRequestHandler(java.util.concurrent.Executor executor)
-
ThreadedHttpRequestHandler
@Inject public ThreadedHttpRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric)
-
ThreadedHttpRequestHandler
public ThreadedHttpRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
-
-
Method Detail
-
handle
public abstract HttpResponse handle(HttpRequest request)
Override this to implement a synchronous style handler.- Parameters:
request
- incoming HTTP request- Returns:
- a valid HTTP response for presentation to the user
-
handle
public HttpResponse handle(HttpRequest request, com.yahoo.jdisc.handler.ContentChannel channel)
Override this rather than handle(request) to be able to write to the channel before returning from this method. This default implementation calls handle(request)
-
handleRequest
public final void handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
- Specified by:
handleRequest
in classThreadedRequestHandler
-
addDateHeader
protected void addDateHeader(HttpResponse httpResponse, long startTime)
-
createLoggingCompletionHandler
protected LoggingCompletionHandler createLoggingCompletionHandler(long startTime, long renderStartTime, HttpResponse response, HttpRequest httpRequest, ContentChannelOutputStream rendererWiring)
Override this to implement custom access logging.- Parameters:
startTime
- execution startrenderStartTime
- start of output renderingresponse
- the response which the log entry regardshttpRequest
- the incoming HTTP requestrendererWiring
- the stream the rendered response is written to, used for fetching length of rendered response
-
asHttpRequest
protected com.yahoo.jdisc.http.HttpRequest asHttpRequest(com.yahoo.jdisc.Request request)
-
-