Class ThreadedHttpRequestHandler

    • 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 interface com.yahoo.jdisc.SharedResource

        DEBUG, SYSTEM_PROPERTY_NAME_DEBUG
    • 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.jdisc.handler.AbstractRequestHandler

        handleTimeout
      • Methods inherited from class com.yahoo.jdisc.AbstractResource

        currentState, destroy, refer, release, retainCount
      • 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
    • Field Detail

      • 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 class ThreadedRequestHandler
      • 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 start
        renderStartTime - start of output rendering
        response - the response which the log entry regards
        httpRequest - the incoming HTTP request
        rendererWiring - 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)