Class ServerConfiguration.Builder

    • Method Detail

      • ssl

        public ServerConfiguration.Builder ssl​(Supplier<? extends SSLContext> sslContextBuilder)
        Sets SSLContext to to use with the server. If not null then server enforce SSL communication.
        Parameters:
        sslContextBuilder - ssl context builder; will be built as a first step of this method execution
        Returns:
        an updated builder
      • allowedCipherSuite

        public ServerConfiguration.Builder allowedCipherSuite​(List<String> cipherSuite)
        Configures allowed SSL cipher suite.
        Parameters:
        cipherSuite - allowed cipher suite
        Returns:
        this builder
      • port

        public ServerConfiguration.Builder port​(int port)
        Sets server port. If port is 0 or less then any available ephemeral port will be used.

        Configuration key: port

        Parameters:
        port - the server port
        Returns:
        an updated builder
      • bindAddress

        public ServerConfiguration.Builder bindAddress​(InetAddress bindAddress)
        Sets a local address for server to bind. If null then listens an all local addresses.

        Configuration key: bind-address

        Parameters:
        bindAddress - the address to bind the server or null for all local addresses
        Returns:
        an updated builder
      • backlog

        public ServerConfiguration.Builder backlog​(int size)
        Sets a maximum length of the queue of incoming connections. Default value is 1024.

        Configuration key: backlog

        Parameters:
        size - the maximum length of the queue of incoming connections
        Returns:
        an updated builder
      • timeout

        public ServerConfiguration.Builder timeout​(int milliseconds)
        Sets a socket timeout in milliseconds or 0 for infinite timeout.

        Configuration key: timeout

        Parameters:
        milliseconds - a socket timeout in milliseconds or 0
        Returns:
        an updated builder
      • receiveBufferSize

        public ServerConfiguration.Builder receiveBufferSize​(int bytes)
        Propose value of the TCP receive window that is advertised to the remote peer. If 0 then implementation default is used.

        Configuration key: receive-buffer

        Parameters:
        bytes - a buffer size in bytes or 0
        Returns:
        an updated builder
      • maxHeaderSize

        public ServerConfiguration.Builder maxHeaderSize​(int size)
        Configure maximal header size (all headers combined) in number of characters for default socket.
        Parameters:
        size - header size
        Returns:
        an updated builder
      • maxInitialLineLength

        public ServerConfiguration.Builder maxInitialLineLength​(int length)
        Configure maximal length of the initial HTTP line for default socket.
        Parameters:
        length - line length
        Returns:
        an updated buidler
      • addSocket

        public ServerConfiguration.Builder addSocket​(String name,
                                                     int port,
                                                     InetAddress bindAddress)
        Adds an additional named server socket configuration. As a result, the server will listen on multiple ports.

        An additional named server socket may have a dedicated Routing configured through WebServer.Builder.addNamedRouting(String, Routing).

        Parameters:
        name - the name of the additional server socket configuration
        port - the port to bind; if 0 or less, any available ephemeral port will be used
        bindAddress - the address to bind; if null, all local addresses will be bound
        Returns:
        an updated builder
      • addSocket

        public ServerConfiguration.Builder addSocket​(String name,
                                                     Supplier<SocketConfiguration> socketConfigurationBuilder)
        Adds an additional named server socket configuration builder. As a result, the server will listen on multiple ports.

        An additional named server socket may have a dedicated Routing configured through WebServer.Builder.addNamedRouting(String, Routing).

        Parameters:
        name - the name of the additional server socket configuration
        socketConfigurationBuilder - the additional named server socket configuration builder; will be built as a first step of this method execution
        Returns:
        an updated builder
      • workersCount

        public ServerConfiguration.Builder workersCount​(int workers)
        Sets a count of threads in pool used to tryProcess HTTP requests. Default value is CPU_COUNT * 2.

        Configuration key: workers

        Parameters:
        workers - a workers count
        Returns:
        an updated builder
      • tracer

        public ServerConfiguration.Builder tracer​(Supplier<? extends Tracer> tracerBuilder)
        Sets an opentracing.io tracer. (Default is GlobalTracer.)
        Parameters:
        tracerBuilder - a tracer builder to set; will be built as a first step of this method execution
        Returns:
        updated builder
      • enabledSSlProtocols

        public ServerConfiguration.Builder enabledSSlProtocols​(String... protocols)
        Configures the SSL protocols to enable with the default server socket.
        Parameters:
        protocols - protocols to enable, if null enables the default protocols
        Returns:
        an updated builder
      • enabledSSlProtocols

        public ServerConfiguration.Builder enabledSSlProtocols​(List<String> protocols)
        Configures the SSL protocols to enable with the default server socket.
        Parameters:
        protocols - protocols to enable, if null or empty enables the default protocols
        Returns:
        an updated builder
      • context

        public ServerConfiguration.Builder context​(Context context)
        Configure the application scoped context to be used as a parent for webserver request contexts.
        Parameters:
        context - top level context
        Returns:
        an updated builder
      • config

        public ServerConfiguration.Builder config​(Config config)
        Sets configuration values included in provided Config parameter.

        It can be used for configuration externalisation.

        All parameters sets before this method call can be seen as defaults and all parameters sets after can be seen as forced.

        Parameters:
        config - the configuration to use
        Returns:
        an updated builder