- All Superinterfaces:
RuntimeType.Api<WebServerConfig>
Server that opens server sockets and handles requests through routing.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default server socket configuration name. -
Method Summary
Modifier and TypeMethodDescriptionstatic WebServerConfig.Builder
builder()
A new builder to set up server.context()
Context associated with theWebServer
, used as a parent for listener contexts.static WebServer
create
(WebServerConfig serverConfig) Create a new web server from its configuration.static WebServer
create
(Consumer<WebServerConfig.Builder> builderConsumer) Create a new webserver customizing its configuration.default boolean
hasTls()
Returnstrue
if TLS is configured for the default socket.boolean
Returnstrue
if TLS is configured for the named socket.boolean
Returnstrue
if the server is currently running.default int
port()
Returns a port number the default server socket is bound to and is listening on; or-1
if unknown or not active.int
Returns a port number an additional named server socket is bound to and is listening on; or-1
if unknown or not active.default void
Reload TLS keystore and truststore configuration for the default socket.void
Reload TLS keystore and truststore configuration for the named socket.start()
Starts the server.stop()
Attempt to gracefully shutdown the server.Methods inherited from interface io.helidon.builder.api.RuntimeType.Api
prototype
-
Field Details
-
DEFAULT_SOCKET_NAME
The default server socket configuration name. All the default server socket configuration such asport(String)
is accessible using this name. The value is "@default".- See Also:
-
-
Method Details
-
create
Create a new web server from its configuration.- Parameters:
serverConfig
- configuration- Returns:
- a new web server
-
create
Create a new webserver customizing its configuration.- Parameters:
builderConsumer
- consumer of configuration builder- Returns:
- a new web server
-
builder
A new builder to set up server.- Returns:
- builder
-
start
WebServer start()Starts the server. Has no effect if server is running. The start will fail on a server that is shut down, or that failed to start. In such cases, create a new instance of WebServer.- Returns:
- a started server
- Throws:
IllegalStateException
- when startup fails, in such a case all channels are shut down
-
stop
WebServer stop()Attempt to gracefully shutdown the server.- Returns:
- a stopped server
- See Also:
-
isRunning
boolean isRunning()Returnstrue
if the server is currently running. Running server in stopping phase returnstrue
until it is not fully stopped.- Returns:
true
if server is running
-
port
default int port()Returns a port number the default server socket is bound to and is listening on; or-1
if unknown or not active.It is supported only when server is running.
- Returns:
- a listen port; or
-1
if unknown or the default server socket is not active
-
port
Returns a port number an additional named server socket is bound to and is listening on; or-1
if unknown or not active.- Parameters:
socketName
- the name of an additional named server socket- Returns:
- a listen port; or
-1
if socket name is unknown or the server socket is not active
-
hasTls
default boolean hasTls()Returnstrue
if TLS is configured for the default socket.- Returns:
- whether TLS is enabled for the default socket
-
context
Context context()Context associated with theWebServer
, used as a parent for listener contexts.- Returns:
- a server context
-
hasTls
Returnstrue
if TLS is configured for the named socket.- Parameters:
socketName
- the name of a socket- Returns:
- whether TLS is enabled for the socket, returns
false
if the socket does not exists
-
reloadTls
Reload TLS keystore and truststore configuration for the default socket.- Parameters:
tls
- new TLS configuration
-
reloadTls
Reload TLS keystore and truststore configuration for the named socket.- Parameters:
socketName
- socket name to reload TLS configuration ontls
- new TLS configuration
-