Class ListenerConfig.BuilderBase.ListenerConfigImpl

java.lang.Object
io.helidon.webserver.ListenerConfig.BuilderBase.ListenerConfigImpl
All Implemented Interfaces:
Prototype.Api, ListenerConfig
Direct Known Subclasses:
WebServerConfig.BuilderBase.WebServerConfigImpl
Enclosing class:
ListenerConfig.BuilderBase<BUILDER extends ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ListenerConfig>

protected static class ListenerConfig.BuilderBase.ListenerConfigImpl extends Object implements ListenerConfig
Generated implementation of the prototype, can be extended by descendant prototype implementations.
  • Constructor Details

    • ListenerConfigImpl

      protected ListenerConfigImpl(ListenerConfig.BuilderBase<?,?> builder)
      Create an instance providing a builder.
      Parameters:
      builder - extending builder base of this prototype
  • Method Details

    • protocols

      public List<ProtocolConfig> protocols()
      Description copied from interface: ListenerConfig
      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:
             ....
       
      Specified by:
      protocols in interface ListenerConfig
      Returns:
      all defined protocol configurations, loaded from service loader by default
    • routing

      public Optional<HttpRouting.Builder> routing()
      Description copied from interface: ListenerConfig
      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.
      Specified by:
      routing in interface ListenerConfig
      Returns:
      HTTP Routing for this listener/server
    • routings

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

      public String name()
      Description copied from interface: ListenerConfig
      Name of this socket. Defaults to @default. Must be defined if more than one socket is needed.
      Specified by:
      name in interface ListenerConfig
      Returns:
      name of the socket
    • host

      public String host()
      Description copied from interface: ListenerConfig
      Host of the default socket. Defaults to all host addresses (0.0.0.0).
      Specified by:
      host in interface ListenerConfig
      Returns:
      host address to listen on (for the default socket)
    • address

      public InetAddress address()
      Description copied from interface: ListenerConfig
      Address to use. If both this and ListenerConfig.host() is configured, this will be used.
      Specified by:
      address in interface ListenerConfig
      Returns:
      address to use
    • port

      public int port()
      Description copied from interface: ListenerConfig
      Port of the default socket. If configured to 0 (the default), server starts on a random port.
      Specified by:
      port in interface ListenerConfig
      Returns:
      port to listen on (for the default socket)
    • backlog

      public int backlog()
      Description copied from interface: ListenerConfig
      Accept backlog.
      Specified by:
      backlog in interface ListenerConfig
      Returns:
      backlog
    • maxPayloadSize

      public long maxPayloadSize()
      Description copied from interface: ListenerConfig
      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).
      Specified by:
      maxPayloadSize in interface ListenerConfig
      Returns:
      maximal number of bytes of entity
    • receiveBufferSize

      public Optional<Integer> receiveBufferSize()
      Description copied from interface: ListenerConfig
      Listener receive buffer size.
      Specified by:
      receiveBufferSize in interface ListenerConfig
      Returns:
      buffer size in bytes
    • writeQueueLength

      public int writeQueueLength()
      Description copied from interface: ListenerConfig
      Number of buffers queued for write operations.
      Specified by:
      writeQueueLength in interface ListenerConfig
      Returns:
      maximal number of queued writes, defaults to 0
    • smartAsyncWrites

      public boolean smartAsyncWrites()
      Description copied from interface: ListenerConfig
      If enabled and ListenerConfig.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.
      Specified by:
      smartAsyncWrites in interface ListenerConfig
      Returns:
      smart async setting
    • writeBufferSize

      public int writeBufferSize()
      Description copied from interface: ListenerConfig
      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.
      Specified by:
      writeBufferSize in interface ListenerConfig
      Returns:
      initial buffer size used for writing
    • shutdownGracePeriod

      public Duration shutdownGracePeriod()
      Description copied from interface: ListenerConfig
      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.

      Specified by:
      shutdownGracePeriod in interface ListenerConfig
      Returns:
      grace period
    • connectionConfig

      public Optional<ConnectionConfig> connectionConfig()
      Description copied from interface: ListenerConfig
      Configuration of a connection (established from client against our server).
      Specified by:
      connectionConfig in interface ListenerConfig
      Returns:
      connection configuration
    • tls

      public Optional<Tls> tls()
      Description copied from interface: ListenerConfig
      Listener TLS configuration.
      Specified by:
      tls in interface ListenerConfig
      Returns:
      tls of this configuration
    • contentEncoding

      public Optional<ContentEncodingContext> contentEncoding()
      Description copied from interface: ListenerConfig
      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.
      Specified by:
      contentEncoding in interface ListenerConfig
      Returns:
      content encoding context
    • mediaContext

      public Optional<MediaContext> mediaContext()
      Description copied from interface: ListenerConfig
      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.
      Specified by:
      mediaContext in interface ListenerConfig
      Returns:
      media context
    • connectionOptions

      public SocketOptions connectionOptions()
      Description copied from interface: ListenerConfig
      Options for connections accepted by this listener. This is not used to setup server connection.
      Specified by:
      connectionOptions in interface ListenerConfig
      Returns:
      socket options
    • maxTcpConnections

      public int maxTcpConnections()
      Description copied from interface: ListenerConfig
      Limits the number of connections that can be opened at a single point in time. Defaults to -1, meaning "unlimited" - what the system allows.
      Specified by:
      maxTcpConnections in interface ListenerConfig
      Returns:
      number of TCP connections that can be opened to this listener, regardless of protocol
    • maxConcurrentRequests

      public int maxConcurrentRequests()
      Description copied from interface: ListenerConfig
      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. 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 ListenerConfig.concurrencyLimit() and will use the FixedLimit.

      Specified by:
      maxConcurrentRequests in interface ListenerConfig
      Returns:
      number of requests that can be processed on this listener, regardless of protocol
    • concurrencyLimit

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

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

      Specified by:
      concurrencyLimit in interface ListenerConfig
      Returns:
      concurrency limit
    • idleConnectionTimeout

      public Duration idleConnectionTimeout()
      Description copied from interface: ListenerConfig
      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).
      Specified by:
      idleConnectionTimeout in interface ListenerConfig
      Returns:
      timeout of idle connections
    • idleConnectionPeriod

      public Duration idleConnectionPeriod()
      Description copied from interface: ListenerConfig
      How often should we check for ListenerConfig.idleConnectionTimeout(). Defaults to PT2M (2 minutes).
      Specified by:
      idleConnectionPeriod in interface ListenerConfig
      Returns:
      period of checking for idle connections
    • maxInMemoryEntity

      public int maxInMemoryEntity()
      Description copied from interface: ListenerConfig
      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.

      Specified by:
      maxInMemoryEntity in interface ListenerConfig
      Returns:
      maximal number of bytes to buffer in memory for supported writers
    • listenerSocketOptions

      public Map<SocketOption<?>,Object> listenerSocketOptions()
      Description copied from interface: ListenerConfig
      Server listener socket options. Unless configured through builder, SO_REUSEADDR is set to true, and SO_RCVBUF is set to 4096.
      Specified by:
      listenerSocketOptions in interface ListenerConfig
      Returns:
      custom socket options
    • connectionSelectors

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

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

      public Optional<Context> listenerContext()
      Description copied from interface: ListenerConfig
      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
      Specified by:
      listenerContext in interface ListenerConfig
      Returns:
      listener context
      See Also:
    • enableProxyProtocol

      public boolean enableProxyProtocol()
      Description copied from interface: ListenerConfig
      Enable proxy protocol support 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.
      Specified by:
      enableProxyProtocol in interface ListenerConfig
      Returns:
      proxy support status
    • requestedUriDiscoveryContext

      public Optional<RequestedUriDiscoveryContext> requestedUriDiscoveryContext()
      Description copied from interface: ListenerConfig
      Requested URI discovery context.
      Specified by:
      requestedUriDiscoveryContext in interface ListenerConfig
      Returns:
      discovery context
    • errorHandling

      public ErrorHandling errorHandling()
      Description copied from interface: ListenerConfig
      Configuration for this listener's error handling.
      Specified by:
      errorHandling in interface ListenerConfig
      Returns:
      error handling
    • restoreResponseHeaders

      public boolean restoreResponseHeaders()
      Description copied from interface: ListenerConfig
      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.
      Specified by:
      restoreResponseHeaders in interface ListenerConfig
      Returns:
      copy/restore header setting
    • ignoreInvalidNamedRouting

      public boolean ignoreInvalidNamedRouting()
      Description copied from interface: ListenerConfig
      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).
      Specified by:
      ignoreInvalidNamedRouting in interface ListenerConfig
      Returns:
      whether to ignore invalid routing name, defaults to false
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • configureSocket

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