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

java.lang.Object
io.helidon.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:
Prototype.Builder<BUILDER, PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
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 ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
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. This method disables automatic service discovery.
      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
    • routing

      public BUILDER routing(Consumer<HttpRouting.Builder> builderConsumer)
      Customize HTTP routing of this listener.
      Parameters:
      builderConsumer - consumer of HTTP Routing builder
      Returns:
      updated builder instance
    • addBinding

      public BUILDER addBinding(TcpTransportConfig config)
      Add a TCP transport binding from configuration.
      Parameters:
      config - TCP transport binding configuration
      Returns:
      updated builder instance
    • addBinding

      public BUILDER addBinding(UdsTransportConfig config)
      Add a Unix domain socket transport binding from configuration.
      Parameters:
      config - Unix domain socket transport binding configuration
      Returns:
      updated builder instance
    • config

      public BUILDER 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 ConfigBuilderSupport.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
    • clearProtocols

      public BUILDER clearProtocols()
      Clear all protocols.
      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 - add single all defined protocol configurations, loaded from service loader by default
      Returns:
      updated builder instance
      See Also:
    • clearBindings

      public BUILDER clearBindings()
      Clear all bindings.
      Returns:
      updated builder instance
      See Also:
    • bindings

      public BUILDER bindings(List<? extends TransportBindingFactory> bindings)
      Transport bindings that serve this listener are configured as one object keyed by binding type; list form and nested name or type are invalid, and built-in TCP remains enabled unless bindings.tcp.enabled=false.

      Configuration uses one object keyed by binding type. The object key is the binding's sole identity; list form and nested type or name properties are not supported. Each binding type may occur at most once.

      TCP is an overlay default: when no TCP binding is configured, the listener adds the built-in TCP binding even when another binding is configured. Set bindings.tcp.enabled=false to explicitly disable TCP. An explicit TCP entry replaces the synthesized default.

      Parameters:
      bindings - configured transport bindings
      Returns:
      updated builder instance
      See Also:
    • addBindings

      public BUILDER addBindings(List<? extends TransportBindingFactory> bindings)
      Transport bindings that serve this listener are configured as one object keyed by binding type; list form and nested name or type are invalid, and built-in TCP remains enabled unless bindings.tcp.enabled=false.

      Configuration uses one object keyed by binding type. The object key is the binding's sole identity; list form and nested type or name properties are not supported. Each binding type may occur at most once.

      TCP is an overlay default: when no TCP binding is configured, the listener adds the built-in TCP binding even when another binding is configured. Set bindings.tcp.enabled=false to explicitly disable TCP. An explicit TCP entry replaces the synthesized default.

      Parameters:
      bindings - configured transport bindings
      Returns:
      updated builder instance
      See Also:
    • addBinding

      public BUILDER addBinding(TransportBindingFactory binding)
      Transport bindings that serve this listener are configured as one object keyed by binding type; list form and nested name or type are invalid, and built-in TCP remains enabled unless bindings.tcp.enabled=false.

      Configuration uses one object keyed by binding type. The object key is the binding's sole identity; list form and nested type or name properties are not supported. Each binding type may occur at most once.

      TCP is an overlay default: when no TCP binding is configured, the listener adds the built-in TCP binding even when another binding is configured. Set bindings.tcp.enabled=false to explicitly disable TCP. An explicit TCP entry replaces the synthesized default.

      Parameters:
      binding - add single configured transport bindings
      Returns:
      updated builder instance
      See Also:
    • clearRouting

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

      public BUILDER routing(HttpRouting.Builder 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:
    • clearRoutings

      public BUILDER clearRoutings()
      Clear all routings.
      Returns:
      updated builder instance
      See Also:
    • routings

      public BUILDER routings(List<Builder<?, ? 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<Builder<?, ? 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(Builder<?, ? extends Routing> routing)
      List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed to routing()
      Parameters:
      routing - add single 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:
    • clearBindAddress

      public BUILDER clearBindAddress()
      Clear existing value of bindAddress.
      Returns:
      updated builder instance
      See Also:
    • bindAddress

      public BUILDER bindAddress(SocketAddress bindAddress)
      The TCP address to bind to (<host>:<port>); Unix domain addresses are rejected and must instead use bindings.uds.socket. If this is set it will override host(), address() and port().

      To bind a Unix domain socket, configure an explicit uds transport binding instead. The legacy unix:/path form is rejected; use bindings.uds.socket=/path and explicitly disable TCP when the listener should be UDS-only.

      Parameters:
      bindAddress - the socket address to bind on.
      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 HeaderNames.CONTENT_LENGTH is used, this is checked immediately, if 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:
    • 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:
    • smartAsyncWrites

      public BUILDER smartAsyncWrites(boolean smartAsyncWrites)
      If enabled and writeQueueLength() is greater than 1, then start with async writes but possibly switch to sync writes if async queue size is always below a certain threshold.
      Parameters:
      smartAsyncWrites - smart async setting
      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 4096. Set buffer size to a value less than one to turn off buffering.
      Parameters:
      writeBufferSize - initial buffer size used for writing
      Returns:
      updated builder instance
      See Also:
    • shutdownGracePeriod

      public BUILDER shutdownGracePeriod(Duration shutdownGracePeriod)
      Grace period in ISO 8601 duration format to allow running tasks to complete before listener's shutdown. Default is 500 milliseconds.

      Configuration file values example: PT0.5S, PT2S.

      Parameters:
      shutdownGracePeriod - grace period
      Returns:
      updated builder instance
      See Also:
    • clearTls

      public BUILDER clearTls()
      Clear existing value of tls.
      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 tls)
      Listener TLS configuration.
      Parameters:
      tls - prototype of tls of this configuration
      Returns:
      updated builder instance
      See Also:
    • tls

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

      public BUILDER tls(Supplier<? extends Tls> supplier)
      Listener TLS configuration.
      Parameters:
      supplier - supplier of tls of this configuration
      Returns:
      updated builder instance
      See Also:
    • clearVirtualHosts

      public BUILDER clearVirtualHosts()
      Clear all virtualHosts.
      Returns:
      updated builder instance
      See Also:
    • virtualHosts

      public BUILDER virtualHosts(List<? extends VirtualHostConfig> virtualHosts)
      Listener TLS virtual hosts selected by SNI; requires listener TLS and NIO socket-channel transport (use-nio=true).

      Virtual hosts select TLS material only. The listener routing is used for all requests. Server startup fails if virtual hosts are configured without listener TLS or with use-nio disabled.

      Parameters:
      virtualHosts - configured listener virtual hosts
      Returns:
      updated builder instance
      See Also:
    • addVirtualHosts

      public BUILDER addVirtualHosts(List<? extends VirtualHostConfig> virtualHosts)
      Listener TLS virtual hosts selected by SNI; requires listener TLS and NIO socket-channel transport (use-nio=true).

      Virtual hosts select TLS material only. The listener routing is used for all requests. Server startup fails if virtual hosts are configured without listener TLS or with use-nio disabled.

      Parameters:
      virtualHosts - configured listener virtual hosts
      Returns:
      updated builder instance
      See Also:
    • addVirtualHost

      public BUILDER addVirtualHost(VirtualHostConfig virtualHost)
      Listener TLS virtual hosts selected by SNI; requires listener TLS and NIO socket-channel transport (use-nio=true).

      Virtual hosts select TLS material only. The listener routing is used for all requests. Server startup fails if virtual hosts are configured without listener TLS or with use-nio disabled.

      Parameters:
      virtualHost - add single configured listener virtual hosts
      Returns:
      updated builder instance
      See Also:
    • addVirtualHost

      public BUILDER addVirtualHost(Consumer<VirtualHostConfig.Builder> consumer)
      Listener TLS virtual hosts selected by SNI; requires listener TLS and NIO socket-channel transport (use-nio=true).

      Virtual hosts select TLS material only. The listener routing is used for all requests. Server startup fails if virtual hosts are configured without listener TLS or with use-nio disabled.

      Parameters:
      consumer - consumer of builder for configured listener virtual hosts
      Returns:
      updated builder instance
      See Also:
    • sni

      public BUILDER sni(SniConfig sni)
      Listener-scoped server TLS SNI policy.
      Parameters:
      sni - SNI policy
      Returns:
      updated builder instance
      See Also:
    • sni

      public BUILDER sni(Consumer<SniConfig.Builder> consumer)
      Listener-scoped server TLS SNI policy.
      Parameters:
      consumer - consumer of builder of SNI policy
      Returns:
      updated builder instance
      See Also:
    • sni

      public BUILDER sni(Supplier<? extends SniConfig> supplier)
      Listener-scoped server TLS SNI policy.
      Parameters:
      supplier - supplier of SNI policy
      Returns:
      updated builder instance
      See Also:
    • clearContentEncoding

      public BUILDER clearContentEncoding()
      Clear existing value of contentEncoding.
      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 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 - prototype of 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 - consumer of builder of content encoding context
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(Supplier<? extends ContentEncodingContext> supplier)
      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:
      supplier - supplier of content encoding context
      Returns:
      updated builder instance
      See Also:
    • clearMediaContext

      public BUILDER clearMediaContext()
      Clear existing value of mediaContext.
      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 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 - prototype of 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 - consumer of builder of media context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(Supplier<? extends MediaContext> supplier)
      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:
      supplier - supplier of 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 of socket options
      Returns:
      updated builder instance
      See Also:
    • connectionOptions

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

      @Deprecated(since="27.0.0", forRemoval=true) public BUILDER maxTcpConnections(int maxTcpConnections)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This option is deprecated, use maxConnections instead
      Limits listener-wide connection admission shared by all connection-oriented bindings.
      Parameters:
      maxTcpConnections - pre-accept connection admission capacity for this listener
      Returns:
      updated builder instance
      See Also:
    • maxConnections

      public BUILDER maxConnections(int maxConnections)
      Limits listener-wide connection admission shared by all connection-oriented bindings. A permit is acquired before accepting or admitting connection work and released after the connection finishes, or immediately if admission, setup, or submission fails. Defaults to -1, meaning "unlimited" - what the system allows. 0 has the same meaning as -1 - unlimited number of connections. A finite value must be at least the number of active connection-oriented bindings that reserve a permit while waiting to accept; listener planning fails otherwise. If the finite limit is L and N active bindings hold an idle permit, concentrated traffic has worst-case immediately usable capacity L - N + 1. The shared limit provides neither per-binding quotas nor strict fairness; an event-driven binding can be temporarily starved while idle pre-accept reservations are held.
      Parameters:
      maxConnections - pre-accept connection admission capacity for this listener, regardless of transport binding or protocol
      Returns:
      updated builder instance
      See Also:
    • maxConcurrentRequests

      public BUILDER maxConcurrentRequests(int maxConcurrentRequests)
      Limits the number of requests that can be executed at the same time (the number of active virtual threads of requests). Defaults to -1, meaning "unlimited" - what the system allows. 0 has the same meaning as -1 - unlimited number of requests. Also make sure that this number is higher than the expected time it takes to handle a single request in your application, as otherwise you may stop in-progress requests.

      Setting this option will always ignore concurrencyLimit() and will use the FixedLimit.

      Parameters:
      maxConcurrentRequests - number of requests that can be processed on this listener, regardless of protocol
      Returns:
      updated builder instance
      See Also:
    • clearConcurrencyLimit

      public BUILDER clearConcurrencyLimit()
      Clear existing value of concurrencyLimit.
      Returns:
      updated builder instance
      See Also:
    • concurrencyLimit

      public BUILDER concurrencyLimit(Limit concurrencyLimit)
      Concurrency limit to use to limit concurrent execution of incoming requests. The default is to have unlimited concurrency.

      Note that if maxConcurrentRequests() is configured, this is ignored.

      Parameters:
      concurrencyLimit - concurrency limit
      Returns:
      updated builder instance
      See Also:
    • idleConnectionTimeout

      public BUILDER idleConnectionTimeout(Duration idleConnectionTimeout)
      How long should we wait before closing a connection that has no traffic on it. Defaults to PT5M (5 minutes). Note that the timestamp is refreshed max. once per second, so this setting would be useless if configured for shorter periods of time (also not a very good support for connection keep alive, if the connections are killed so soon anyway).
      Parameters:
      idleConnectionTimeout - timeout of idle connections
      Returns:
      updated builder instance
      See Also:
    • idleConnectionPeriod

      public BUILDER idleConnectionPeriod(Duration idleConnectionPeriod)
      How often should we check for idleConnectionTimeout(). Defaults to PT2M (2 minutes).
      Parameters:
      idleConnectionPeriod - period of checking for idle connections
      Returns:
      updated builder instance
      See Also:
    • maxInMemoryEntity

      public BUILDER maxInMemoryEntity(int maxInMemoryEntity)
      If the entity is expected to be smaller that this number of bytes, it would be buffered in memory to optimize performance when writing it. If bigger, streaming will be used.

      Note that for some entity types we cannot use streaming, as they are already fully in memory (String, byte[]), for such cases, this option is ignored.

      Default is 128Kb.

      Parameters:
      maxInMemoryEntity - maximal number of bytes to buffer in memory for supported writers
      Returns:
      updated builder instance
      See Also:
    • listenerSocketOptions

      public BUILDER listenerSocketOptions(Map<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<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 - The key and value has to use the same generic type.
      Parameters:
      key - key to add or replace
      listenerSocketOption - new value for the key
      Returns:
      updated builder instance
      See Also:
    • clearConnectionSelectors

      public BUILDER clearConnectionSelectors()
      Clear all connectionSelectors.
      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 - add single connection selectors to be used for this socket
      Returns:
      updated builder instance
      See Also:
    • clearConnectionSelectorProviders

      public BUILDER clearConnectionSelectorProviders()
      Clear all connectionSelectorProviders.
      Returns:
      updated builder instance
      See Also:
    • connectionSelectorProviders

      public BUILDER connectionSelectorProviders(List<? extends ServerConnectionSelectorProvider> connectionSelectorProviders)
      Providers of connection selectors discovered for this listener.
      Parameters:
      connectionSelectorProviders - connection selector providers
      Returns:
      updated builder instance
      See Also:
    • addConnectionSelectorProviders

      public BUILDER addConnectionSelectorProviders(List<? extends ServerConnectionSelectorProvider> connectionSelectorProviders)
      Providers of connection selectors discovered for this listener.
      Parameters:
      connectionSelectorProviders - connection selector providers
      Returns:
      updated builder instance
      See Also:
    • addConnectionSelectorProvider

      public BUILDER addConnectionSelectorProvider(ServerConnectionSelectorProvider connectionSelectorProvider)
      Providers of connection selectors discovered for this listener.
      Parameters:
      connectionSelectorProvider - add single connection selector providers
      Returns:
      updated builder instance
      See Also:
    • clearDirectHandlers

      public BUILDER clearDirectHandlers()
      Clear existing value of directHandlers.
      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 - consumer of builder of direct handlers
      Returns:
      updated builder instance
      See Also:
    • directHandlers

      public BUILDER directHandlers(Supplier<? extends DirectHandlers> supplier)
      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:
      supplier - supplier of direct handlers
      Returns:
      updated builder instance
      See Also:
    • clearListenerContext

      public BUILDER clearListenerContext()
      Clear existing value of listenerContext.
      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 - consumer of builder of listener context
      Returns:
      updated builder instance
      See Also:
    • listenerContext

      public BUILDER listenerContext(Supplier<? extends Context> supplier)
      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:
      supplier - supplier of listener context
      Returns:
      updated builder instance
      See Also:
    • enableProxyProtocol

      @Deprecated(since="4.5.2", forRemoval=true) public BUILDER enableProxyProtocol(boolean enableProxyProtocol)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use proxyProtocol() instead
      Deprecated PROXY protocol enablement flag for this socket. This protocol is supported by some load balancers/reverse proxies as a means to convey client information that would otherwise be lost. If enabled, the proxy protocol header must be present on every new connection established with your server. For more information, see the specification. Default is false.

      This deprecated option cannot enable PROXY protocol support by itself. Configure proxyProtocol() with ProxyProtocolConfig.trustedProxies() instead.

      Parameters:
      enableProxyProtocol - proxy support status
      Returns:
      updated builder instance
      See Also:
    • clearProxyProtocol

      public BUILDER clearProxyProtocol()
      Clear existing value of proxyProtocol.
      Returns:
      updated builder instance
      See Also:
    • proxyProtocol

      public BUILDER proxyProtocol(ProxyProtocolConfig proxyProtocol)
      PROXY protocol configuration.

      If configured and ProxyProtocolConfig.enabled() is true, PROXY protocol support is enabled for this listener. The ProxyProtocolConfig.trustedProxies() allow list must be configured explicitly when support is enabled.

      Parameters:
      proxyProtocol - PROXY protocol configuration
      Returns:
      updated builder instance
      See Also:
    • proxyProtocol

      public BUILDER proxyProtocol(Consumer<ProxyProtocolConfig.Builder> consumer)
      PROXY protocol configuration.

      If configured and ProxyProtocolConfig.enabled() is true, PROXY protocol support is enabled for this listener. The ProxyProtocolConfig.trustedProxies() allow list must be configured explicitly when support is enabled.

      Parameters:
      consumer - consumer of builder of PROXY protocol configuration
      Returns:
      updated builder instance
      See Also:
    • proxyProtocol

      public BUILDER proxyProtocol(Supplier<? extends ProxyProtocolConfig> supplier)
      PROXY protocol configuration.

      If configured and ProxyProtocolConfig.enabled() is true, PROXY protocol support is enabled for this listener. The ProxyProtocolConfig.trustedProxies() allow list must be configured explicitly when support is enabled.

      Parameters:
      supplier - supplier of PROXY protocol configuration
      Returns:
      updated builder instance
      See Also:
    • clearRequestedUriDiscoveryContext

      public BUILDER clearRequestedUriDiscoveryContext()
      Clear existing value of requestedUriDiscoveryContext.
      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 of discovery context
      Returns:
      updated builder instance
      See Also:
    • requestedUriDiscoveryContext

      public BUILDER requestedUriDiscoveryContext(Supplier<? extends RequestedUriDiscoveryContext> supplier)
      Requested URI discovery context.
      Parameters:
      supplier - supplier of discovery context
      Returns:
      updated builder instance
      See Also:
    • errorHandling

      public BUILDER errorHandling(ErrorHandling errorHandling)
      Configuration for this listener's error handling.
      Parameters:
      errorHandling - error handling
      Returns:
      updated builder instance
      See Also:
    • errorHandling

      public BUILDER errorHandling(Consumer<ErrorHandling.Builder> consumer)
      Configuration for this listener's error handling.
      Parameters:
      consumer - consumer of builder of error handling
      Returns:
      updated builder instance
      See Also:
    • errorHandling

      public BUILDER errorHandling(Supplier<? extends ErrorHandling> supplier)
      Configuration for this listener's error handling.
      Parameters:
      supplier - supplier of error handling
      Returns:
      updated builder instance
      See Also:
    • restoreResponseHeaders

      public BUILDER restoreResponseHeaders(boolean restoreResponseHeaders)
      Copy and restore response headers before and after passing a request to Jersey for processing. If Jersey fails to handle the request, and the Webserver continues processing the request, it needs to make sure the original headers are restored. Turn off this flag to avoid the extra overhead of copying headers when no handler executes after Jersey returns.
      Parameters:
      restoreResponseHeaders - copy/restore header setting
      Returns:
      updated builder instance
      See Also:
    • ignoreInvalidNamedRouting

      public BUILDER ignoreInvalidNamedRouting(boolean ignoreInvalidNamedRouting)
      If set to true, any named routing configured that does not have an associated named listener will NOT cause an exception to be thrown (default behavior is to throw an exception).
      Parameters:
      ignoreInvalidNamedRouting - whether to ignore invalid routing name, defaults to false
      Returns:
      updated builder instance
      See Also:
    • useNio

      public BUILDER useNio(boolean useNio)
      Whether to use an NIO socket channel instead of a socket; Unix domain socket bindings always use NIO and ignore this setting, while listener TLS virtual hosts require it to be true.
      Parameters:
      useNio - whether to use NIO socket channel, defaults to true
      Returns:
      updated builder instance
      See Also:
    • protocolsDiscoverServices

      public BUILDER protocolsDiscoverServices(boolean protocolsDiscoverServices)
      Service discovery flag for protocols(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Parameters:
      protocolsDiscoverServices - whether to enable automatic service discovery
      Returns:
      updated builder instance
      See Also:
    • bindingsDiscoverServices

      public BUILDER bindingsDiscoverServices(boolean bindingsDiscoverServices)
      Service discovery flag for bindings(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Parameters:
      bindingsDiscoverServices - whether to enable automatic service discovery
      Returns:
      updated builder instance
      See Also:
    • concurrencyLimitDiscoverServices

      public BUILDER concurrencyLimitDiscoverServices(boolean concurrencyLimitDiscoverServices)
      Service discovery flag for concurrencyLimit(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Parameters:
      concurrencyLimitDiscoverServices - whether to enable automatic service discovery
      Returns:
      updated builder instance
      See Also:
    • connectionSelectorProvidersDiscoverServices

      public BUILDER connectionSelectorProvidersDiscoverServices(boolean connectionSelectorProvidersDiscoverServices)
      Service discovery flag for connectionSelectorProviders(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Parameters:
      connectionSelectorProvidersDiscoverServices - whether to enable automatic service discovery
      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:
      all defined protocol configurations, loaded from service loader by default
    • bindings

      public List<TransportBindingFactory> bindings()
      Transport bindings that serve this listener are configured as one object keyed by binding type; list form and nested name or type are invalid, and built-in TCP remains enabled unless bindings.tcp.enabled=false.

      Configuration uses one object keyed by binding type. The object key is the binding's sole identity; list form and nested type or name properties are not supported. Each binding type may occur at most once.

      TCP is an overlay default: when no TCP binding is configured, the listener adds the built-in TCP binding even when another binding is configured. Set bindings.tcp.enabled=false to explicitly disable TCP. An explicit TCP entry replaces the synthesized default.

      Returns:
      configured transport bindings
    • routing

      public Optional<HttpRouting.Builder> 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:
      HTTP Routing for this listener/server
    • routings

      public List<Builder<?, ? extends Routing>> routings()
      List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed to routing()
      Returns:
      router for this listener/server
    • name

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

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

      public Optional<InetAddress> address()
      Address to use. If both this and host() is configured, this will be used.
      Returns:
      address to use
    • bindAddress

      public Optional<SocketAddress> bindAddress()
      The TCP address to bind to (<host>:<port>); Unix domain addresses are rejected and must instead use bindings.uds.socket. If this is set it will override host(), address() and port().

      To bind a Unix domain socket, configure an explicit uds transport binding instead. The legacy unix:/path form is rejected; use bindings.uds.socket=/path and explicitly disable TCP when the listener should be UDS-only.

      Returns:
      the socket address to bind on.
    • port

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

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

      public long maxPayloadSize()
      Maximal number of bytes an entity may have. If HeaderNames.CONTENT_LENGTH is used, this is checked immediately, if 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:
      maximal number of bytes of entity
    • writeQueueLength

      public int writeQueueLength()
      Number of buffers queued for write operations.
      Returns:
      maximal number of queued writes, defaults to 0
    • smartAsyncWrites

      public boolean smartAsyncWrites()
      If enabled and writeQueueLength() is greater than 1, then start with async writes but possibly switch to sync writes if async queue size is always below a certain threshold.
      Returns:
      smart async setting
    • writeBufferSize

      public int writeBufferSize()
      Initial buffer size in bytes of BufferedOutputStream created internally to write data to a socket connection. Default is 4096. Set buffer size to a value less than one to turn off buffering.
      Returns:
      initial buffer size used for writing
    • shutdownGracePeriod

      public Duration shutdownGracePeriod()
      Grace period in ISO 8601 duration format to allow running tasks to complete before listener's shutdown. Default is 500 milliseconds.

      Configuration file values example: PT0.5S, PT2S.

      Returns:
      grace period
    • tls

      public Optional<Tls> tls()
      Listener TLS configuration.
      Returns:
      tls of this configuration
    • virtualHosts

      public List<VirtualHostConfig> virtualHosts()
      Listener TLS virtual hosts selected by SNI; requires listener TLS and NIO socket-channel transport (use-nio=true).

      Virtual hosts select TLS material only. The listener routing is used for all requests. Server startup fails if virtual hosts are configured without listener TLS or with use-nio disabled.

      Returns:
      configured listener virtual hosts
    • sni

      public SniConfig sni()
      Listener-scoped server TLS SNI policy.
      Returns:
      SNI policy
    • 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:
      content encoding context
    • 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:
      media context
    • connectionOptions

      public Optional<SocketOptions> connectionOptions()
      Options for connections accepted by this listener. This is not used to setup server connection.
      Returns:
      socket options
    • maxTcpConnections

      @Deprecated(since="27.0.0", forRemoval=true) public int maxTcpConnections()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This option is deprecated, use maxConnections instead
      Limits listener-wide connection admission shared by all connection-oriented bindings.
      Returns:
      pre-accept connection admission capacity for this listener
    • maxConnections

      public int maxConnections()
      Limits listener-wide connection admission shared by all connection-oriented bindings. A permit is acquired before accepting or admitting connection work and released after the connection finishes, or immediately if admission, setup, or submission fails. Defaults to -1, meaning "unlimited" - what the system allows. 0 has the same meaning as -1 - unlimited number of connections. A finite value must be at least the number of active connection-oriented bindings that reserve a permit while waiting to accept; listener planning fails otherwise. If the finite limit is L and N active bindings hold an idle permit, concentrated traffic has worst-case immediately usable capacity L - N + 1. The shared limit provides neither per-binding quotas nor strict fairness; an event-driven binding can be temporarily starved while idle pre-accept reservations are held.
      Returns:
      pre-accept connection admission capacity for this listener, regardless of transport binding or protocol
    • maxConcurrentRequests

      public int maxConcurrentRequests()
      Limits the number of requests that can be executed at the same time (the number of active virtual threads of requests). Defaults to -1, meaning "unlimited" - what the system allows. 0 has the same meaning as -1 - unlimited number of requests. Also make sure that this number is higher than the expected time it takes to handle a single request in your application, as otherwise you may stop in-progress requests.

      Setting this option will always ignore concurrencyLimit() and will use the FixedLimit.

      Returns:
      number of requests that can be processed on this listener, regardless of protocol
    • concurrencyLimit

      public Optional<Limit> concurrencyLimit()
      Concurrency limit to use to limit concurrent execution of incoming requests. The default is to have unlimited concurrency.

      Note that if maxConcurrentRequests() is configured, this is ignored.

      Returns:
      concurrency limit
    • idleConnectionTimeout

      public Duration idleConnectionTimeout()
      How long should we wait before closing a connection that has no traffic on it. Defaults to PT5M (5 minutes). Note that the timestamp is refreshed max. once per second, so this setting would be useless if configured for shorter periods of time (also not a very good support for connection keep alive, if the connections are killed so soon anyway).
      Returns:
      timeout of idle connections
    • idleConnectionPeriod

      public Duration idleConnectionPeriod()
      How often should we check for idleConnectionTimeout(). Defaults to PT2M (2 minutes).
      Returns:
      period of checking for idle connections
    • maxInMemoryEntity

      public int maxInMemoryEntity()
      If the entity is expected to be smaller that this number of bytes, it would be buffered in memory to optimize performance when writing it. If bigger, streaming will be used.

      Note that for some entity types we cannot use streaming, as they are already fully in memory (String, byte[]), for such cases, this option is ignored.

      Default is 128Kb.

      Returns:
      maximal number of bytes to buffer in memory for supported writers
    • 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:
      custom 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:
      connection selectors to be used for this socket
    • connectionSelectorProviders

      public List<ServerConnectionSelectorProvider> connectionSelectorProviders()
      Providers of connection selectors discovered for this listener.
      Returns:
      connection selector providers
    • 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:
      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:
      listener context
      See Also:
    • enableProxyProtocol

      @Deprecated(since="4.5.2", forRemoval=true) public boolean enableProxyProtocol()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use proxyProtocol() instead
      Deprecated PROXY protocol enablement flag for this socket. This protocol is supported by some load balancers/reverse proxies as a means to convey client information that would otherwise be lost. If enabled, the proxy protocol header must be present on every new connection established with your server. For more information, see the specification. Default is false.

      This deprecated option cannot enable PROXY protocol support by itself. Configure proxyProtocol() with ProxyProtocolConfig.trustedProxies() instead.

      Returns:
      proxy support status
    • proxyProtocol

      public Optional<ProxyProtocolConfig> proxyProtocol()
      PROXY protocol configuration.

      If configured and ProxyProtocolConfig.enabled() is true, PROXY protocol support is enabled for this listener. The ProxyProtocolConfig.trustedProxies() allow list must be configured explicitly when support is enabled.

      Returns:
      PROXY protocol configuration
    • requestedUriDiscoveryContext

      public Optional<RequestedUriDiscoveryContext> requestedUriDiscoveryContext()
      Requested URI discovery context.
      Returns:
      discovery context
    • errorHandling

      public ErrorHandling errorHandling()
      Configuration for this listener's error handling.
      Returns:
      error handling
    • restoreResponseHeaders

      public boolean restoreResponseHeaders()
      Copy and restore response headers before and after passing a request to Jersey for processing. If Jersey fails to handle the request, and the Webserver continues processing the request, it needs to make sure the original headers are restored. Turn off this flag to avoid the extra overhead of copying headers when no handler executes after Jersey returns.
      Returns:
      copy/restore header setting
    • ignoreInvalidNamedRouting

      public boolean ignoreInvalidNamedRouting()
      If set to true, any named routing configured that does not have an associated named listener will NOT cause an exception to be thrown (default behavior is to throw an exception).
      Returns:
      whether to ignore invalid routing name, defaults to false
    • useNio

      public boolean useNio()
      Whether to use an NIO socket channel instead of a socket; Unix domain socket bindings always use NIO and ignore this setting, while listener TLS virtual hosts require it to be true.
      Returns:
      whether to use NIO socket channel, defaults to true
    • protocolsDiscoverServices

      public boolean protocolsDiscoverServices()
      Service discovery flag for protocols(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Returns:
      whether to enable automatic service discovery
    • bindingsDiscoverServices

      public boolean bindingsDiscoverServices()
      Service discovery flag for bindings(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Returns:
      whether to enable automatic service discovery
    • concurrencyLimitDiscoverServices

      public boolean concurrencyLimitDiscoverServices()
      Service discovery flag for concurrencyLimit(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Returns:
      whether to enable automatic service discovery
    • connectionSelectorProvidersDiscoverServices

      public boolean connectionSelectorProvidersDiscoverServices()
      Service discovery flag for connectionSelectorProviders(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Returns:
      whether to enable automatic service discovery
    • toString

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

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

      protected void validatePrototype()
      Validates required properties.
    • config

      protected Optional<Config> config()
      Configuration used to configure this instance.
      Returns:
      config instance