Class HttpAsyncService

  • All Implemented Interfaces:
    NHttpServerEventHandler

    @Contract(threading=IMMUTABLE_CONDITIONAL)
    public class HttpAsyncService
    extends java.lang.Object
    implements NHttpServerEventHandler
    HttpAsyncService is a fully asynchronous HTTP server side protocol handler based on the non-blocking (NIO) I/O model. HttpAsyncServerProtocolHandler translates individual events fired through the NHttpServerEventHandler interface into logically related HTTP message exchanges.

    Upon receiving an incoming request HttpAsyncService verifies the message for compliance with the server expectations using HttpAsyncExpectationVerifier, if provided, and then HttpAsyncRequestHandlerMapper is used to map the request to a particular HttpAsyncRequestHandler intended to handle the request with the given URI. The protocol handler uses the selected HttpAsyncRequestHandler instance to process the incoming request and to generate an outgoing response.

    HttpAsyncService relies on HttpProcessor to generate mandatory protocol headers for all outgoing messages and apply common, cross-cutting message transformations to all incoming and outgoing messages, whereas individual HttpAsyncRequestHandlers are expected to implement application specific content generation and processing.

    Individual HttpAsyncRequestHandlers do not have to submit a response immediately. They 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 once response content becomes available.

    Since:
    4.2