Interface Server

All Superinterfaces:
AutoCloseable

public interface Server extends AutoCloseable
An application-owned listener. Closing a listener leaves its application running.
  • Method Summary

    Modifier and Type
    Method
    Description
    Observes admission without running callbacks on transport threads.
    void
    Starts a graceful drain and returns without waiting; idempotent and nonblocking, including from a handler.
    boolean
    Reports listener availability.
    Returns the bound address.
    default void
    Re-reads the TLS key material and swaps it in atomically for connections accepted from now on; connections that are open keep the material they negotiated with.
    Observes shutdown without granting ownership of its completion.
  • Method Details

    • localAddress

      InetSocketAddress localAddress()
      Returns the bound address.
      Returns:
      actual address, including the allocated port
    • isOpen

      boolean isOpen()
      Reports listener availability.
      Returns:
      whether the listener is accepting connections
    • admission

      AdmissionSnapshot admission()
      Observes admission without running callbacks on transport threads.
      Returns:
      a consistent snapshot for this listener, also available after shutdown
    • termination

      CompletionStage<Void> termination()
      Observes shutdown without granting ownership of its completion.
      Returns:
      completion after all listener resources and handlers have stopped
    • reloadTls

      default void reloadTls() throws IOException
      Re-reads the TLS key material and swaps it in atomically for connections accepted from now on; connections that are open keep the material they negotiated with. Call it after a certificate was renewed. If the new material is invalid, expired or does not match, the exception is thrown and the previous material stays in use.
      Throws:
      TlsConfigurationException - if the new material cannot be used
      IOException - if reloading failed for another reason
      IllegalStateException - if this listener does not serve TLS
    • close

      void close()
      Starts a graceful drain and returns without waiting; idempotent and nonblocking, including from a handler. The listener stops accepting connections at once and closes idle connections and connections still receiving a request. Requests queued for execution capacity are answered 503 without invoking their handlers. Running handlers may finish within a fixed grace period (five seconds); their responses are sent with Connection: close. After the grace period, remaining connections are force-closed and their handlers interrupted. Await termination() to join the shutdown.
      Specified by:
      close in interface AutoCloseable