Interface WebServer

All Superinterfaces:
RuntimeType.Api<WebServerConfig>

public interface WebServer extends RuntimeType.Api<WebServerConfig>
Server that opens server sockets and handles requests through routing.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default server socket configuration name.
  • Method Summary

    Modifier and Type
    Method
    Description
    A new builder to set up server.
    Context associated with the WebServer, used as a parent for listener contexts.
    static WebServer
    create(WebServerConfig serverConfig)
    Create a new web server from its configuration.
    static WebServer
    Create a new webserver customizing its configuration.
    default boolean
    Returns true if TLS is configured for the default socket.
    boolean
    hasTls(String socketName)
    Returns true if TLS is configured for the named socket.
    boolean
    Returns true if the server is currently running.
    default int
    Returns a port number the default server socket is bound to and is listening on; or -1 if unknown or not active.
    int
    port(String socketName)
    Returns a port number an additional named server socket is bound to and is listening on; or -1 if unknown or not active.
    default void
    Reload TLS keystore and truststore configuration for the default socket.
    void
    reloadTls(String socketName, Tls tls)
    Reload TLS keystore and truststore configuration for the named socket.
    Starts the server.
    Attempt to gracefully shutdown the server.

    Methods inherited from interface io.helidon.builder.api.RuntimeType.Api

    prototype
  • Field Details

    • DEFAULT_SOCKET_NAME

      static final String DEFAULT_SOCKET_NAME
      The default server socket configuration name. All the default server socket configuration such as port(String) is accessible using this name. The value is "@default".
      See Also:
  • Method Details

    • create

      static WebServer create(WebServerConfig serverConfig)
      Create a new web server from its configuration.
      Parameters:
      serverConfig - configuration
      Returns:
      a new web server
    • create

      static WebServer create(Consumer<WebServerConfig.Builder> builderConsumer)
      Create a new webserver customizing its configuration.
      Parameters:
      builderConsumer - consumer of configuration builder
      Returns:
      a new web server
    • builder

      static WebServerConfig.Builder builder()
      A new builder to set up server.
      Returns:
      builder
    • start

      WebServer start()
      Starts the server. Has no effect if server is running. The start will fail on a server that is shut down, or that failed to start. In such cases, create a new instance of WebServer.
      Returns:
      a started server
      Throws:
      IllegalStateException - when startup fails, in such a case all channels are shut down
    • stop

      WebServer stop()
      Attempt to gracefully shutdown the server.
      Returns:
      a stopped server
      See Also:
    • isRunning

      boolean isRunning()
      Returns true if the server is currently running. Running server in stopping phase returns true until it is not fully stopped.
      Returns:
      true if server is running
    • port

      default int port()
      Returns a port number the default server socket is bound to and is listening on; or -1 if unknown or not active.

      It is supported only when server is running.

      Returns:
      a listen port; or -1 if unknown or the default server socket is not active
    • port

      int port(String socketName)
      Returns a port number an additional named server socket is bound to and is listening on; or -1 if unknown or not active.
      Parameters:
      socketName - the name of an additional named server socket
      Returns:
      a listen port; or -1 if socket name is unknown or the server socket is not active
    • hasTls

      default boolean hasTls()
      Returns true if TLS is configured for the default socket.
      Returns:
      whether TLS is enabled for the default socket
    • context

      Context context()
      Context associated with the WebServer, used as a parent for listener contexts.
      Returns:
      a server context
    • hasTls

      boolean hasTls(String socketName)
      Returns true if TLS is configured for the named socket.
      Parameters:
      socketName - the name of a socket
      Returns:
      whether TLS is enabled for the socket, returns false if the socket does not exists
    • reloadTls

      default void reloadTls(Tls tls)
      Reload TLS keystore and truststore configuration for the default socket.
      Parameters:
      tls - new TLS configuration
    • reloadTls

      void reloadTls(String socketName, Tls tls)
      Reload TLS keystore and truststore configuration for the named socket.
      Parameters:
      socketName - socket name to reload TLS configuration on
      tls - new TLS configuration