org.apache.hc.core5.http.impl.bootstrap

## Class HttpAsyncServer

- java.lang.Object
- - org.apache.hc.core5.http.impl.bootstrap.AsyncServer
  - - org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer

- All Implemented Interfaces:
    Closeable, AutoCloseable, ModalCloseable, ConnectionAcceptor, ConnectionInitiator, IOReactor, IOReactorService

      public class HttpAsyncServer
      extends AsyncServer

  HTTP/1.1 server side message exchange handler.
  Since:
    5.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpAsyncServer(IOEventHandlerFactory eventHandlerFactory, IOReactorConfig ioReactorConfig, Decorator<IOSession> ioSessionDecorator, Callback<Exception> exceptionCallback, IOSessionListener sessionListener)` Use `AsyncServerBootstrap` to create instances of this class.
    `HttpAsyncServer(IOEventHandlerFactory eventHandlerFactory, IOReactorConfig ioReactorConfig, Decorator<IOSession> ioSessionDecorator, Callback<Exception> exceptionCallback, IOSessionListener sessionListener, String canonicalName)` Use `AsyncServerBootstrap` to create instances of this class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `Future<IOSession>` | `connect(NamedEndpoint remoteEndpoint, SocketAddress remoteAddress, SocketAddress localAddress, Timeout timeout, Object attachment, FutureCallback<IOSession> callback)` Requests a connection to a remote host.
    `Future<ListenerEndpoint>` | `listen(SocketAddress address)` Deprecated. Use `listen(SocketAddress, URIScheme)`
    `Future<ListenerEndpoint>` | `listen(SocketAddress address, FutureCallback<ListenerEndpoint> callback)` Deprecated. Use `listen(SocketAddress, URIScheme, FutureCallback)`
    `Future<ListenerEndpoint>` | `listen(SocketAddress address, URIScheme scheme)`
    `Future<ListenerEndpoint>` | `listen(SocketAddress address, URIScheme scheme, FutureCallback<ListenerEndpoint> callback)`
    `Future<ListenerEndpoint>` | `listen(SocketAddress address, URIScheme scheme, Object attachment, FutureCallback<ListenerEndpoint> callback)`

    - ### Methods inherited from class org.apache.hc.core5.http.impl.bootstrap.AsyncServer

      `awaitShutdown, close, close, getEndpoints, getStatus, initiateShutdown, listen, pause, resume, start`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpAsyncServer

          @Internal
          public HttpAsyncServer(IOEventHandlerFactory eventHandlerFactory,
                                           IOReactorConfig ioReactorConfig,
                                           Decorator<IOSession> ioSessionDecorator,
                                           Callback<Exception> exceptionCallback,
                                           IOSessionListener sessionListener,
                                           String canonicalName)

      Use `AsyncServerBootstrap` to create instances of this class.
      Since:
        5.1

    - #### HttpAsyncServer

          @Internal
          public HttpAsyncServer(IOEventHandlerFactory eventHandlerFactory,
                                           IOReactorConfig ioReactorConfig,
                                           Decorator<IOSession> ioSessionDecorator,
                                           Callback<Exception> exceptionCallback,
                                           IOSessionListener sessionListener)

      Use `AsyncServerBootstrap` to create instances of this class.

  - ### Method Detail

    - #### listen

          public Future<ListenerEndpoint> listen(SocketAddress address,
                                                 URIScheme scheme,
                                                 Object attachment,
                                                 FutureCallback<ListenerEndpoint> callback)

      Since:
        5.1

    - #### listen

          public Future<ListenerEndpoint> listen(SocketAddress address,
                                                 URIScheme scheme,
                                                 FutureCallback<ListenerEndpoint> callback)

      Since:
        5.1

    - #### listen

          public Future<ListenerEndpoint> listen(SocketAddress address,
                                                 URIScheme scheme)

      Since:
        5.1

    - #### listen

          @Deprecated
          public Future<ListenerEndpoint> listen(SocketAddress address,
                                                             FutureCallback<ListenerEndpoint> callback)

      Deprecated. Use `listen(SocketAddress, URIScheme, FutureCallback)`
      Description copied from interface: `ConnectionAcceptor`
      Opens a new listener endpoint with the given socket address. Once the endpoint is fully initialized it starts accepting incoming connections and propagates I/O activity notifications to the I/O event dispatcher.
      Specified by:
        `listen` in interface `ConnectionAcceptor`
      Overrides:
        `listen` in class `AsyncServer`
      Parameters:
        `address` - the socket address to listen on.
        `callback` - the result callback.
      Returns:
        listener endpoint.

    - #### listen

          @Deprecated
          public Future<ListenerEndpoint> listen(SocketAddress address)

      Deprecated. Use `listen(SocketAddress, URIScheme)`
      Overrides:
        `listen` in class `AsyncServer`

    - #### connect

          public final Future<IOSession> connect(NamedEndpoint remoteEndpoint,
                                                 SocketAddress remoteAddress,
                                                 SocketAddress localAddress,
                                                 Timeout timeout,
                                                 Object attachment,
                                                 FutureCallback<IOSession> callback)

      Description copied from interface: `ConnectionInitiator`
      Requests a connection to a remote host.

      Opening a connection to a remote host usually tends to be a time consuming process and may take a while to complete. One can monitor and control the process of session initialization by means of the `Future` interface.

      There are several parameters one can use to exert a greater control over the process of session initialization:

      A non-null local socket address parameter can be used to bind the socket to a specific local address.

      An attachment object can added to the new session's context upon initialization. This object can be used to pass an initial processing state to the protocol handler.

      It is often desirable to be able to react to the completion of a session request asynchronously without having to wait for it, blocking the current thread of execution. One can optionally provide an implementation `FutureCallback` instance to get notified of events related to session requests, such as request completion, cancellation, failure or timeout.

      Specified by:
        `connect` in interface `ConnectionInitiator`
      Parameters:
        `remoteEndpoint` - name of the remote host.
        `remoteAddress` - remote socket address.
        `localAddress` - local socket address. Can be `null`, in which can the default local address and a random port will be used.
        `timeout` - connect timeout.
        `attachment` - the attachment object. Can be `null`.
        `callback` - interface. Can be `null`.
      Returns:
        session request object.

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.