Interface HttpAsyncRequestHandler<T>

  • All Known Implementing Classes:
    BasicAsyncRequestHandler

    public interface HttpAsyncRequestHandler<T>
    HttpAsyncRequestHandler represents a routine for asynchronous processing of a specific group of non-blocking HTTP requests. Protocol handlers are designed to take care of protocol specific aspects, whereas individual request handlers are expected to take care of application specific HTTP processing. The main purpose of a request handler is to generate a response object with a content entity to be sent back to the client in response to the given request.
    Since:
    4.2
    • Method Detail

      • processRequest

        HttpAsyncRequestConsumer<T> processRequest​(HttpRequest request,
                                                   HttpContext context)
                                            throws HttpException,
                                                   java.io.IOException
        Triggered when an incoming request is received. This method should return a HttpAsyncRequestConsumer that will be used to process the request and consume message content if enclosed. The consumer can optionally parse or transform the message content into a structured object which is then passed onto the handle(Object, HttpAsyncExchange, HttpContext) method for further processing.
        Parameters:
        request - the entity enclosing request.
        context - the execution context.
        Returns:
        request consumer.
        Throws:
        java.io.IOException - in case of an I/O error.
        HttpException - in case of HTTP protocol violation or a processing problem.
      • handle

        void handle​(T data,
                    HttpAsyncExchange httpExchange,
                    HttpContext context)
             throws HttpException,
                    java.io.IOException
        Triggered to complete request processing and to initiate the process of generating a response. This method does not have to submit a response immediately. It can defer transmission of an HTTP response back to the client without blocking the I/O thread by delegating the process of request handling to another service or a worker thread. HTTP response can be submitted as a later a later point of time using HttpAsyncExchange once response content becomes available.
        Parameters:
        data - request data returned by the request consumer.
        httpExchange - HTTP exchange.
        context - HTTP execution context.
        Throws:
        java.io.IOException - in case of an I/O error.
        HttpException - in case of HTTP protocol violation or a processing problem.