Server that opens server sockets and handles requests through routing.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default server socket configuration name. -
Method Summary
Modifier and TypeMethodDescriptionstatic WebServer.Builderbuilder()A new builder to set up server.context()Context associated with theWebServer, used as a parent for listener contexts.default booleanhasTls()Returnstrueif TLS is configured for the default socket.booleanReturnstrueif TLS is configured for the named socket.booleanReturnstrueif the server is currently running.default intport()Returns a port number the default server socket is bound to and is listening on; or-1if unknown or not active.intReturns a port number an additional named server socket is bound to and is listening on; or-1if unknown or not active.default voidReload TLS keystore and truststore configuration for the default socket.voidReload TLS keystore and truststore configuration for the named socket.start()Starts the server.stop()Attempt to gracefully shutdown the server.
-
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.- See Also:
-
-
Method Details
-
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 Web Server.- 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()Returnstrueif the server is currently running. Running server in stopping phase returnstrueuntil it is not fully stopped.- Returns:
trueif server is running
-
port
default int port()Returns a port number the default server socket is bound to and is listening on; or-1if unknown or not active.It is supported only when server is running.
- Returns:
- a listen port; or
-1if 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-1if unknown or not active.- Parameters:
socketName- the name of an additional named server socket- Returns:
- a listen port; or
-1if socket name is unknown or the server socket is not active
-
hasTls
default boolean hasTls()Returnstrueif 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
Returnstrueif TLS is configured for the named socket.- Parameters:
socketName- the name of a socket- Returns:
- whether TLS is enabled for the socket, returns
falseif 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
-