Module io.helidon.nima.webserver
Package io.helidon.nima.webserver
Class WebServerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends WebServerConfig>
java.lang.Object
io.helidon.nima.webserver.ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>
io.helidon.nima.webserver.WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>
- Type Parameters:
BUILDER- type of the builder extending this abstract builderPROTOTYPE- type of the prototype interface that would be built byPrototype.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> io.helidon.builder.api.Prototype.Factory<WebServer>,ListenerConfig,WebServerConfig
- Direct Known Subclasses:
WebServerConfig.Builder
- Enclosing interface:
WebServerConfig
public abstract static class WebServerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends WebServerConfig>
extends ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>
implements io.helidon.builder.api.Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>, WebServerConfig
Fluent API builder base for
WebServer.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classGenerated implementation of the prototype, can be extended by descendant prototype implementations.Nested classes/interfaces inherited from class io.helidon.nima.webserver.ListenerConfig.BuilderBase
ListenerConfig.BuilderBase.ListenerConfigImplNested classes/interfaces inherited from interface io.helidon.nima.webserver.ListenerConfig
ListenerConfig.Builder, ListenerConfig.BuilderBase<BUILDER extends ListenerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends ListenerConfig> Nested classes/interfaces inherited from interface io.helidon.nima.webserver.WebServerConfig
WebServerConfig.Builder, WebServerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddress()Address to use.addSockets(Map<? extends String, ? extends ListenerConfig> sockets) Socket configurations.intbacklog()Accept backlog.Clear existing value of this property.Optional<io.helidon.common.config.Config>config()If this instance was configured, this would be the config instance used.config(io.helidon.common.config.Config config) Update builder from configuration (node of this type).default voidconfigureSocket(ServerSocket socket) Update the server socket with configured socket options.Configuration of a connection (established from client against our server).Options for connections accepted by this listener.Explicitly defined connection selectors to be used with this socket.Configure the listener specificContentEncodingContext.Direct handlers specific for this listener.from(WebServerConfig prototype) Update this builder from an existing prototype instance.from(WebServerConfig.BuilderBase<?, ?> builder) Update this builder from an existing prototype builder instance.host()Host of the default socket.Listener scoped context to be used as a parent for webserver request contexts (if used).Map<SocketOption<?>,Object> Server listener socket options.longMaximal number of bytes an entity may have.Configure the listener specificMediaContext.name()Name of this socket.intport()Port of the default socket.protected voidHandles providers and interceptors.Configuration of protocols.putSocket(String key, ListenerConfig socket) Socket configurations.putSocket(String key, Consumer<ListenerConfig.Builder> consumer) Socket configurations.Listener receive buffer size.Requested URI discovery context.routing()Http routing.routings()List of all routings (possibly for multiple protocols).Context for the WebServer, if none defined, a new one will be created with global context as the root.serverContext(Context serverContext) Context for the WebServer, if none defined, a new one will be created with global context as the root.serverContext(Consumer<Context.Builder> consumer) Context for the WebServer, if none defined, a new one will be created with global context as the root.booleanWhen true the webserver registers a shutdown hook with the JVM Runtime.shutdownHook(boolean shutdownHook) When true the webserver registers a shutdown hook with the JVM Runtime.sockets()Socket configurations.sockets(Map<? extends String, ? extends ListenerConfig> sockets) Socket configurations.tls()Listener TLS configuration.toString()protected voidValidates required properties.intInitial buffer size in bytes ofBufferedOutputStreamcreated internally to write data to a socket connection.intNumber of buffers queued for write operations.Methods inherited from class io.helidon.nima.webserver.ListenerConfig.BuilderBase
addConnectionSelector, addConnectionSelectors, addListenerSocketOptions, addProtocol, addProtocols, address, address, addRouting, addRoutings, backlog, backlog, clearConnectionConfig, clearContentEncoding, clearDirectHandlers, clearListenerContext, clearMediaContext, clearReceiveBufferSize, clearRouting, clearTls, connectionConfig, connectionConfig, connectionConfig, connectionOptions, connectionOptions, connectionOptions, connectionSelectors, connectionSelectors, contentEncoding, contentEncoding, contentEncoding, contentEncoding, directHandlers, directHandlers, directHandlers, from, from, host, host, listenerContext, listenerContext, listenerContext, listenerSocketOptions, listenerSocketOptions, maxPayloadSize, maxPayloadSize, mediaContext, mediaContext, mediaContext, mediaContext, name, name, port, port, protocols, protocols, protocolsDiscoverServices, putListenerSocketOption, receiveBufferSize, receiveBufferSize, requestedUriDiscoveryContext, requestedUriDiscoveryContext, requestedUriDiscoveryContext, routing, routing, routing, routings, routings, tls, tls, tls, tls, writeBufferSize, writeBufferSize, writeQueueLength, writeQueueLengthMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.helidon.builder.api.Prototype.Builder
buildPrototype, resolveBuilder, selfMethods inherited from interface io.helidon.builder.api.Prototype.ConfiguredBuilder
discoverServicesMethods inherited from interface io.helidon.builder.api.Prototype.Factory
build
-
Constructor Details
-
BuilderBase
protected BuilderBase()Protected to support extensibility.
-
-
Method Details
-
from
Update this builder from an existing prototype instance.- Parameters:
prototype- existing prototype to update this builder from- Returns:
- updated builder instance
-
from
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.- Overrides:
preBuildPrototypein classListenerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig>
-
validatePrototype
protected void validatePrototype()Validates required properties.- Overrides:
validatePrototypein classListenerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig>
-
config
Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.- Specified by:
configin interfaceio.helidon.builder.api.Prototype.ConfiguredBuilder<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig> - Overrides:
configin classListenerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig> - Parameters:
config- configuration instance used to obtain values to update this builder- Returns:
- updated builder instance
-
shutdownHook
When true the webserver registers a shutdown hook with the JVM Runtime.Defaults to true. Set this to false such that a shutdown hook is not registered.
- Parameters:
shutdownHook- whether to register a shutdown hook- Returns:
- updated builder instance
- See Also:
-
sockets
Socket configurations. Note that socket named "@default" cannot be used, configure the values on the server directly. This method replaces all values with the new ones.- Parameters:
sockets- map of listener configurations, except for the default one- Returns:
- updated builder instance
- See Also:
-
addSockets
Socket configurations. Note that socket named "@default" cannot be used, configure the values on the server directly. This method keeps existing values, then puts all new values into the map.- Parameters:
sockets- map of listener configurations, except for the default one- Returns:
- updated builder instance
- See Also:
-
putSocket
Socket configurations. Note that socket named "@default" cannot be used, configure the values on the server directly. This method adds a new value to the map, or replaces it if the key already exists.- Parameters:
key- key to add or replacesocket- new value for the key- Returns:
- updated builder instance
- See Also:
-
putSocket
Socket configurations. Note that socket named "@default" cannot be used, configure the values on the server directly. This method adds a new value to the map, or replaces it if the key already exists.- Parameters:
key- key to add or replaceconsumer- builder consumer to create new value for the key- Returns:
- updated builder instance
- See Also:
-
clearServerContext
Clear existing value of this property.- Returns:
- updated builder instance
- See Also:
-
serverContext
Context for the WebServer, if none defined, a new one will be created with global context as the root.- Parameters:
serverContext- server context- Returns:
- updated builder instance
- See Also:
-
serverContext
Context for the WebServer, if none defined, a new one will be created with global context as the root.- Parameters:
consumer- server context- Returns:
- updated builder instance
- See Also:
-
shutdownHook
public boolean shutdownHook()When true the webserver registers a shutdown hook with the JVM Runtime.Defaults to true. Set this to false such that a shutdown hook is not registered.
- Returns:
- the shutdown hook
-
sockets
Socket configurations. Note that socket named "@default" cannot be used, configure the values on the server directly.- Returns:
- the sockets
-
serverContext
Context for the WebServer, if none defined, a new one will be created with global context as the root.- Returns:
- the server context
-
config
If this instance was configured, this would be the config instance used.- Overrides:
configin classListenerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig> - Returns:
- config node used to configure this builder, or empty if not configured
-
toString
- Overrides:
toStringin classListenerConfig.BuilderBase<BUILDER extends WebServerConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends WebServerConfig>
-
protocols
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
-
routing
Optional<HttpRouting> routing()Http routing. This will always be added to the resultingRouter, 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
List of all routings (possibly for multiple protocols). This allows adding non-http protocols as well, as opposed torouting()- Returns:
- router for this listener/server
-
name
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
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
InetAddress address()Address to use. If both this andhost()is configured, this will be used.- Returns:
- address to use
-
port
int port()Port of the default socket. If configured to0(the default), server starts on a random port.- Returns:
- port to listen on (for the default socket)
-
backlog
int backlog()Accept backlog.- Returns:
- backlog
-
maxPayloadSize
long maxPayloadSize()Maximal number of bytes an entity may have. IfHttp.Header.CONTENT_LENGTHis used, this is checked immediately, ifHttp.HeaderValues.TRANSFER_ENCODING_CHUNKEDis 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
-
receiveBufferSize
Listener receive buffer size.- Returns:
- buffer size in bytes
-
writeQueueLength
int writeQueueLength()Number of buffers queued for write operations.- Returns:
- maximal number of queued writes, defaults to 0
-
writeBufferSize
int writeBufferSize()Initial buffer size in bytes ofBufferedOutputStreamcreated internally to write data to a socket connection. Default is512.- Returns:
- initial buffer size used for writing
-
connectionConfig
Optional<ConnectionConfig> connectionConfig()Configuration of a connection (established from client against our server).- Returns:
- connection configuration
-
tls
Listener TLS configuration.- Returns:
- tls of this configuration
-
contentEncoding
Optional<ContentEncodingContext> contentEncoding()Configure the listener specificContentEncodingContext. 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
Optional<MediaContext> mediaContext()Configure the listener specificMediaContext. 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
SocketOptions connectionOptions()Options for connections accepted by this listener. This is not used to setup server connection.- Returns:
- socket options
-
listenerSocketOptions
Map<SocketOption<?>,Object> listenerSocketOptions()Server listener socket options. Unless configured through builder,SO_REUSEADDRis set totrue, andSO_RCVBUFis set to4096.- Returns:
- custom socket options
-
connectionSelectors
List<ServerConnectionSelector> connectionSelectors()Explicitly defined connection selectors to be used with this socket. This list is augmented with the result ofprotocols(), but custom selectors are always used first.- Returns:
- connection selectors to be used for this socket
-
directHandlers
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
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:
-
requestedUriDiscoveryContext
RequestedUriDiscoveryContext requestedUriDiscoveryContext()Requested URI discovery context.- Returns:
- discovery context
-
configureSocket
Update the server socket with configured socket options.- Parameters:
socket- socket to update
-