Class ListenerConfig.BuilderBase<BUILDER extends ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ListenerConfig>

java.lang.Object
io.helidon.nima.webserver.ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
io.helidon.builder.api.Prototype.Api, io.helidon.builder.api.Prototype.Builder<BUILDER,PROTOTYPE>, io.helidon.builder.api.Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>, ListenerConfig
Direct Known Subclasses:
ListenerConfig.Builder, WebServerConfig.BuilderBase
Enclosing interface:
ListenerConfig

public abstract static class ListenerConfig.BuilderBase<BUILDER extends ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ListenerConfig> extends Object implements io.helidon.builder.api.Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>, ListenerConfig
Fluent API builder base for ListenerConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(ListenerConfig prototype)
      Update this builder from an existing prototype instance.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(ListenerConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and interceptors.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
    • config

      public BUILDER config(io.helidon.common.config.Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface io.helidon.builder.api.Prototype.ConfiguredBuilder<BUILDER extends ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ListenerConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • protocolsDiscoverServices

      public BUILDER protocolsDiscoverServices(boolean discoverServices)
      Configuration of protocols. This may be either protocol selectors, or protocol upgraders from HTTP/1.1. As the order is not important (providers are ordered by weight by default), we can use a configuration as an object, such as:
       protocols:
       providers:
       http_1_1:
       max-prologue-length: 8192
       http_2:
       max-frame-size: 4096
       websocket:
       ....
       
      Parameters:
      discoverServices - whether to discover implementations through service loader
      Returns:
      updated builder instance
      See Also:
    • protocols

      public BUILDER protocols(List<? extends ProtocolConfig> protocols)
      Configuration of protocols. This may be either protocol selectors, or protocol upgraders from HTTP/1.1. As the order is not important (providers are ordered by weight by default), we can use a configuration as an object, such as:
       protocols:
       providers:
       http_1_1:
       max-prologue-length: 8192
       http_2:
       max-frame-size: 4096
       websocket:
       ....
       
      Parameters:
      protocols - all defined protocol configurations, loaded from service loader by default
      Returns:
      updated builder instance
      See Also:
    • addProtocols

      public BUILDER addProtocols(List<? extends ProtocolConfig> protocols)
      Configuration of protocols. This may be either protocol selectors, or protocol upgraders from HTTP/1.1. As the order is not important (providers are ordered by weight by default), we can use a configuration as an object, such as:
       protocols:
       providers:
       http_1_1:
       max-prologue-length: 8192
       http_2:
       max-frame-size: 4096
       websocket:
       ....
       
      Parameters:
      protocols - all defined protocol configurations, loaded from service loader by default
      Returns:
      updated builder instance
      See Also:
    • addProtocol

      public BUILDER addProtocol(ProtocolConfig protocol)
      Configuration of protocols. This may be either protocol selectors, or protocol upgraders from HTTP/1.1. As the order is not important (providers are ordered by weight by default), we can use a configuration as an object, such as:
       protocols:
       providers:
       http_1_1:
       max-prologue-length: 8192
       http_2:
       max-frame-size: 4096
       websocket:
       ....
       
      Parameters:
      protocol - all defined protocol configurations, loaded from service loader by default
      Returns:
      updated builder instance
      See Also:
    • clearRouting

      public BUILDER clearRouting()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • routing

      public BUILDER routing(HttpRouting routing)
      Http routing. This will always be added to the resulting Router, if defined, overriding any HTTP routing already present. If a custom listener has routing defined, it will be used, otherwise routing defined on web server will be used.
      Parameters:
      routing - HTTP Routing for this listener/server
      Returns:
      updated builder instance
      See Also:
    • routing

      public BUILDER routing(Consumer<HttpRouting.Builder> consumer)
      Http routing. This will always be added to the resulting Router, if defined, overriding any HTTP routing already present. If a custom listener has routing defined, it will be used, otherwise routing defined on web server will be used.
      Parameters:
      consumer - HTTP Routing for this listener/server
      Returns:
      updated builder instance
      See Also:
    • routings

      public BUILDER routings(List<? extends Routing> routings)
      List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed to routing()
      Parameters:
      routings - router for this listener/server
      Returns:
      updated builder instance
      See Also:
    • addRoutings

      public BUILDER addRoutings(List<? extends Routing> routings)
      List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed to routing()
      Parameters:
      routings - router for this listener/server
      Returns:
      updated builder instance
      See Also:
    • addRouting

      public BUILDER addRouting(Routing routing)
      List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed to routing()
      Parameters:
      routing - router for this listener/server
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name of this socket. Defaults to @default. Must be defined if more than one socket is needed.
      Parameters:
      name - name of the socket
      Returns:
      updated builder instance
      See Also:
    • host

      public BUILDER host(String host)
      Host of the default socket. Defaults to all host addresses (0.0.0.0).
      Parameters:
      host - host address to listen on (for the default socket)
      Returns:
      updated builder instance
      See Also:
    • address

      public BUILDER address(InetAddress address)
      Address to use. If both this and host() is configured, this will be used.
      Parameters:
      address - address to use
      Returns:
      updated builder instance
      See Also:
    • port

      public BUILDER port(int port)
      Port of the default socket. If configured to 0 (the default), server starts on a random port.
      Parameters:
      port - port to listen on (for the default socket)
      Returns:
      updated builder instance
      See Also:
    • backlog

      public BUILDER backlog(int backlog)
      Accept backlog.
      Parameters:
      backlog - backlog
      Returns:
      updated builder instance
      See Also:
    • maxPayloadSize

      public BUILDER maxPayloadSize(long maxPayloadSize)
      Maximal number of bytes an entity may have. If Http.Header.CONTENT_LENGTH is used, this is checked immediately, if Http.HeaderValues.TRANSFER_ENCODING_CHUNKED is used, we will fail when the number of bytes read would exceed the max payload size. Defaults to unlimited (-1).
      Parameters:
      maxPayloadSize - maximal number of bytes of entity
      Returns:
      updated builder instance
      See Also:
    • clearReceiveBufferSize

      public BUILDER clearReceiveBufferSize()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • receiveBufferSize

      public BUILDER receiveBufferSize(Integer receiveBufferSize)
      Listener receive buffer size.
      Parameters:
      receiveBufferSize - buffer size in bytes
      Returns:
      updated builder instance
      See Also:
    • writeQueueLength

      public BUILDER writeQueueLength(int writeQueueLength)
      Number of buffers queued for write operations.
      Parameters:
      writeQueueLength - maximal number of queued writes, defaults to 0
      Returns:
      updated builder instance
      See Also:
    • writeBufferSize

      public BUILDER writeBufferSize(int writeBufferSize)
      Initial buffer size in bytes of BufferedOutputStream created internally to write data to a socket connection. Default is 512.
      Parameters:
      writeBufferSize - initial buffer size used for writing
      Returns:
      updated builder instance
      See Also:
    • clearConnectionConfig

      public BUILDER clearConnectionConfig()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • connectionConfig

      public BUILDER connectionConfig(ConnectionConfig connectionConfig)
      Configuration of a connection (established from client against our server).
      Parameters:
      connectionConfig - connection configuration
      Returns:
      updated builder instance
      See Also:
    • connectionConfig

      public BUILDER connectionConfig(Consumer<ConnectionConfig.Builder> consumer)
      Configuration of a connection (established from client against our server).
      Parameters:
      consumer - connection configuration
      Returns:
      updated builder instance
      See Also:
    • clearTls

      public BUILDER clearTls()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • tls

      public BUILDER tls(Tls tls)
      Listener TLS configuration.
      Parameters:
      tls - tls of this configuration
      Returns:
      updated builder instance
      See Also:
    • tls

      public BUILDER tls(TlsConfig tlsConfig)
      Listener TLS configuration.
      Parameters:
      tlsConfig - tls of this configuration
      Returns:
      updated builder instance
      See Also:
    • tls

      public BUILDER tls(Consumer<TlsConfig.Builder> consumer)
      Listener TLS configuration.
      Parameters:
      consumer - tls of this configuration
      Returns:
      updated builder instance
      See Also:
    • clearContentEncoding

      public BUILDER clearContentEncoding()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(ContentEncodingContext contentEncoding)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, content encoding context of the webserver would be used.
      Parameters:
      contentEncoding - content encoding context
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(ContentEncodingContextConfig contentEncodingConfig)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, content encoding context of the webserver would be used.
      Parameters:
      contentEncodingConfig - content encoding context
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(Consumer<ContentEncodingContextConfig.Builder> consumer)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, content encoding context of the webserver would be used.
      Parameters:
      consumer - content encoding context
      Returns:
      updated builder instance
      See Also:
    • clearMediaContext

      public BUILDER clearMediaContext()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(MediaContext mediaContext)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, media context of the webserver would be used.
      Parameters:
      mediaContext - media context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(MediaContextConfig mediaContextConfig)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, media context of the webserver would be used.
      Parameters:
      mediaContextConfig - media context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(Consumer<MediaContextConfig.Builder> consumer)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, media context of the webserver would be used.
      Parameters:
      consumer - media context
      Returns:
      updated builder instance
      See Also:
    • connectionOptions

      public BUILDER connectionOptions(SocketOptions connectionOptions)
      Options for connections accepted by this listener. This is not used to setup server connection.
      Parameters:
      connectionOptions - socket options
      Returns:
      updated builder instance
      See Also:
    • connectionOptions

      public BUILDER connectionOptions(Consumer<SocketOptions.Builder> consumer)
      Options for connections accepted by this listener. This is not used to setup server connection.
      Parameters:
      consumer - consumer of builder for socket options
      Returns:
      updated builder instance
      See Also:
    • listenerSocketOptions

      public BUILDER listenerSocketOptions(Map<? extends SocketOption<?>,?> listenerSocketOptions)
      Server listener socket options. Unless configured through builder, SO_REUSEADDR is set to true, and SO_RCVBUF is set to 4096. This method replaces all values with the new ones.
      Parameters:
      listenerSocketOptions - custom socket options
      Returns:
      updated builder instance
      See Also:
    • addListenerSocketOptions

      public BUILDER addListenerSocketOptions(Map<? extends SocketOption<?>,?> listenerSocketOptions)
      Server listener socket options. Unless configured through builder, SO_REUSEADDR is set to true, and SO_RCVBUF is set to 4096. This method keeps existing values, then puts all new values into the map.
      Parameters:
      listenerSocketOptions - custom socket options
      Returns:
      updated builder instance
      See Also:
    • putListenerSocketOption

      public <TYPE> BUILDER putListenerSocketOption(SocketOption<TYPE> key, TYPE listenerSocketOption)
      Server listener socket options. Unless configured through builder, SO_REUSEADDR is set to true, and SO_RCVBUF is set to 4096. This method adds a new value to the map, or replaces it if the key already exists.
      Type Parameters:
      TYPE - Type to correctly map key and value
      Parameters:
      key - key to add or replace
      listenerSocketOption - new value for the key
      Returns:
      updated builder instance
      See Also:
    • connectionSelectors

      public BUILDER connectionSelectors(List<? extends ServerConnectionSelector> connectionSelectors)
      Explicitly defined connection selectors to be used with this socket. This list is augmented with the result of protocols(), but custom selectors are always used first.
      Parameters:
      connectionSelectors - connection selectors to be used for this socket
      Returns:
      updated builder instance
      See Also:
    • addConnectionSelectors

      public BUILDER addConnectionSelectors(List<? extends ServerConnectionSelector> connectionSelectors)
      Explicitly defined connection selectors to be used with this socket. This list is augmented with the result of protocols(), but custom selectors are always used first.
      Parameters:
      connectionSelectors - connection selectors to be used for this socket
      Returns:
      updated builder instance
      See Also:
    • addConnectionSelector

      public BUILDER addConnectionSelector(ServerConnectionSelector connectionSelector)
      Explicitly defined connection selectors to be used with this socket. This list is augmented with the result of protocols(), but custom selectors are always used first.
      Parameters:
      connectionSelector - connection selectors to be used for this socket
      Returns:
      updated builder instance
      See Also:
    • clearDirectHandlers

      public BUILDER clearDirectHandlers()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • directHandlers

      public BUILDER directHandlers(DirectHandlers directHandlers)
      Direct handlers specific for this listener. A direct handler takes care of problems that happen before (or outside of) routing, such as bad request.
      Parameters:
      directHandlers - direct handlers
      Returns:
      updated builder instance
      See Also:
    • directHandlers

      public BUILDER directHandlers(Consumer<DirectHandlers.Builder> consumer)
      Direct handlers specific for this listener. A direct handler takes care of problems that happen before (or outside of) routing, such as bad request.
      Parameters:
      consumer - direct handlers
      Returns:
      updated builder instance
      See Also:
    • clearListenerContext

      public BUILDER clearListenerContext()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • listenerContext

      public BUILDER listenerContext(Context listenerContext)
      Listener scoped context to be used as a parent for webserver request contexts (if used). If an explicit context is used, you need to take care of correctly configuring its parent. It is expected that the parent of this context is the WebServer context. You should also configure explicit WebServer context when using this method
      Parameters:
      listenerContext - listener context
      Returns:
      updated builder instance
      See Also:
    • listenerContext

      public BUILDER listenerContext(Consumer<Context.Builder> consumer)
      Listener scoped context to be used as a parent for webserver request contexts (if used). If an explicit context is used, you need to take care of correctly configuring its parent. It is expected that the parent of this context is the WebServer context. You should also configure explicit WebServer context when using this method
      Parameters:
      consumer - listener context
      Returns:
      updated builder instance
      See Also:
    • requestedUriDiscoveryContext

      public BUILDER requestedUriDiscoveryContext(RequestedUriDiscoveryContext requestedUriDiscoveryContext)
      Requested URI discovery context.
      Parameters:
      requestedUriDiscoveryContext - discovery context
      Returns:
      updated builder instance
      See Also:
    • requestedUriDiscoveryContext

      public BUILDER requestedUriDiscoveryContext(Consumer<RequestedUriDiscoveryContext.Builder> consumer)
      Requested URI discovery context.
      Parameters:
      consumer - consumer of builder for discovery context
      Returns:
      updated builder instance
      See Also:
    • protocols

      public List<ProtocolConfig> protocols()
      Configuration of protocols. This may be either protocol selectors, or protocol upgraders from HTTP/1.1. As the order is not important (providers are ordered by weight by default), we can use a configuration as an object, such as:
       protocols:
       providers:
       http_1_1:
       max-prologue-length: 8192
       http_2:
       max-frame-size: 4096
       websocket:
       ....
       
      Returns:
      the protocols
    • routing

      public Optional<HttpRouting> routing()
      Http routing. This will always be added to the resulting Router, if defined, overriding any HTTP routing already present. If a custom listener has routing defined, it will be used, otherwise routing defined on web server will be used.
      Returns:
      the routing
    • routings

      public List<Routing> routings()
      List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed to routing()
      Returns:
      the routings
    • name

      public String name()
      Name of this socket. Defaults to @default. Must be defined if more than one socket is needed.
      Returns:
      the name
    • host

      public String host()
      Host of the default socket. Defaults to all host addresses (0.0.0.0).
      Returns:
      the host
    • address

      public InetAddress address()
      Address to use. If both this and host() is configured, this will be used.
      Returns:
      the address
    • port

      public int port()
      Port of the default socket. If configured to 0 (the default), server starts on a random port.
      Returns:
      the port
    • backlog

      public int backlog()
      Accept backlog.
      Returns:
      the backlog
    • maxPayloadSize

      public long maxPayloadSize()
      Maximal number of bytes an entity may have. If Http.Header.CONTENT_LENGTH is used, this is checked immediately, if Http.HeaderValues.TRANSFER_ENCODING_CHUNKED is used, we will fail when the number of bytes read would exceed the max payload size. Defaults to unlimited (-1).
      Returns:
      the max payload size
    • receiveBufferSize

      public Optional<Integer> receiveBufferSize()
      Listener receive buffer size.
      Returns:
      the receive buffer size
    • writeQueueLength

      public int writeQueueLength()
      Number of buffers queued for write operations.
      Returns:
      the write queue length
    • writeBufferSize

      public int writeBufferSize()
      Initial buffer size in bytes of BufferedOutputStream created internally to write data to a socket connection. Default is 512.
      Returns:
      the write buffer size
    • connectionConfig

      public Optional<ConnectionConfig> connectionConfig()
      Configuration of a connection (established from client against our server).
      Returns:
      the connection config
    • tls

      public Optional<Tls> tls()
      Listener TLS configuration.
      Returns:
      the tls
    • contentEncoding

      public Optional<ContentEncodingContext> contentEncoding()
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, content encoding context of the webserver would be used.
      Returns:
      the content encoding
    • mediaContext

      public Optional<MediaContext> mediaContext()
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, media context of the webserver would be used.
      Returns:
      the media context
    • connectionOptions

      public SocketOptions connectionOptions()
      Options for connections accepted by this listener. This is not used to setup server connection.
      Returns:
      the connection options
    • listenerSocketOptions

      public Map<SocketOption<?>,Object> listenerSocketOptions()
      Server listener socket options. Unless configured through builder, SO_REUSEADDR is set to true, and SO_RCVBUF is set to 4096.
      Returns:
      the listener socket options
    • connectionSelectors

      public List<ServerConnectionSelector> connectionSelectors()
      Explicitly defined connection selectors to be used with this socket. This list is augmented with the result of protocols(), but custom selectors are always used first.
      Returns:
      the connection selectors
    • directHandlers

      public Optional<DirectHandlers> directHandlers()
      Direct handlers specific for this listener. A direct handler takes care of problems that happen before (or outside of) routing, such as bad request.
      Returns:
      the direct handlers
    • listenerContext

      public Optional<Context> listenerContext()
      Listener scoped context to be used as a parent for webserver request contexts (if used). If an explicit context is used, you need to take care of correctly configuring its parent. It is expected that the parent of this context is the WebServer context. You should also configure explicit WebServer context when using this method
      Returns:
      the listener context
    • requestedUriDiscoveryContext

      public RequestedUriDiscoveryContext requestedUriDiscoveryContext()
      Requested URI discovery context.
      Returns:
      the requested uri discovery context
    • config

      public Optional<io.helidon.common.config.Config> config()
      If this instance was configured, this would be the config instance used.
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • configureSocket

      default void configureSocket(ServerSocket socket)
      Update the server socket with configured socket options.
      Parameters:
      socket - socket to update