Interface WebServer


public interface WebServer
Represents a immutably configured WEB server.

Provides basic lifecycle and monitoring API.

Instance can be created from Routing and optionally from Config using create(Routing), create(Routing, io.helidon.config.Config) or builder(Routing)methods and their builder enabled overloads.

  • Field Details

  • Method Details

    • configuration

      ServerConfiguration configuration()
      Gets effective server configuration.
      Returns:
      Server configuration
    • start

      Single<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 Web Server.
      Returns:
      a single to react on startup process
    • whenShutdown

      Single<WebServer> whenShutdown()
      Completion stage is completed when server is shut down.
      Returns:
      a completion stage of the server
    • shutdown

      Single<WebServer> shutdown()
      Attempt to gracefully shutdown server. It is possible to use returned Single to react.

      RequestMethod can be called periodically.

      Returns:
      a single to react on finished shutdown process
      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
    • context

      Context context()
      Gets a WebServer context.
      Returns:
      a server context
    • readerContext

      MessageBodyReaderContext readerContext()
      Get the parent MessageBodyReaderContext context.
      Returns:
      media body reader context
    • writerContext

      MessageBodyWriterContext writerContext()
      Get the parent MessageBodyWriterContext context.
      Returns:
      media body writer context
    • 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
    • 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
    • updateTls

      void updateTls(WebServerTls tls)
      Update the TLS configuration of the default socket DEFAULT_SOCKET_NAME.
      Parameters:
      tls - new TLS configuration
      Throws:
      IllegalStateException - if WebServerTls.enabled() returns false or if SocketConfiguration.tls().sslContext() returns null
    • updateTls

      void updateTls(WebServerTls tls, String socketName)
      Update the TLS configuration of the named socket.
      Parameters:
      tls - new TLS configuration
      socketName - specific named socket name
      Throws:
      IllegalStateException - if WebServerTls.enabled() returns false or if SocketConfiguration.tls().sslContext() returns null
    • create

      static WebServer create(Routing routing)
      Creates new instance from provided routing and default configuration.
      Parameters:
      routing - a routing instance
      Returns:
      a new web server instance
      Throws:
      IllegalStateException - if none SPI implementation found
      NullPointerException - if 'routing' parameter is null
    • create

      static WebServer create(Routing routing, Config config)
      Creates new instance from provided configuration and routing.
      Parameters:
      routing - a routing instance
      config - configuration located on server configuration node
      Returns:
      a new web server instance
      Throws:
      NullPointerException - if 'routing' parameter is null
      Since:
      2.0.0
    • create

      static WebServer create(Supplier<Routing> routingBuilder, Config config)
      Creates new instance from provided configuration and routing.
      Parameters:
      routingBuilder - a supplier of routing (such as Routing.Builder
      config - configuration located on server configuration node
      Returns:
      a new web server instance
      Throws:
      NullPointerException - if 'routing' parameter is null
      Since:
      2.0.0
    • create

      static WebServer create(Supplier<? extends Routing> routingBuilder)
      Creates new instance from provided routing and default configuration.
      Parameters:
      routingBuilder - a routing builder instance that will be built as a first step of this method execution
      Returns:
      a new web server instance
      Throws:
      IllegalStateException - if none SPI implementation found
      NullPointerException - if 'routing' parameter is null
    • builder

      static WebServer.Builder builder(Supplier<? extends Routing> routingBuilder)
      Creates a builder of the WebServer.
      Parameters:
      routingBuilder - the routing builder; must not be null
      Returns:
      the builder
    • builder

      static WebServer.Builder builder()
      Creates a fluent API builder of the WebServer. Before calling the WebServer.Builder.build() method, you should configure the default routing. If none is configured, all requests will end in 404.
      Returns:
      a new builder
    • builder

      static WebServer.Builder builder(Routing routing)
      Creates a builder of the WebServer.
      Parameters:
      routing - the routing to use for the default port; must not be null
      Returns:
      the builder
      See Also: