Package io.helidon.webserver
Interface WebServer
-
public interface WebServer
Represents a immutably configured WEB server.Provides basic lifecycle and monitoring API.
Instance can be created from
Routing
and optionally fromServerConfiguration
usingcreate(Routing)
,create(ServerConfiguration, Routing)
orbuilder(Routing)
methods and their builder enabled overloads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
WebServer.Builder
WebServer builder class provides a convenient way to set up WebServer with multiple server sockets and optional multiple routings.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static WebServer.Builder
builder(Routing routing)
Creates a builder of theWebServer
.static WebServer.Builder
builder(Supplier<? extends Routing> routingBuilder)
Creates a builder of theWebServer
.ServerConfiguration
configuration()
Gets effective server configuration.ContextualRegistry
context()
Gets aWebServer
context.static WebServer
create(Routing routing)
Creates new instance form provided routing and default configuration.static WebServer
create(ServerConfiguration configuration, Routing routing)
Creates new instance form provided configuration and routing.static WebServer
create(ServerConfiguration configuration, Supplier<? extends Routing> routingBuilder)
Creates new instance form provided configuration and routing.static WebServer
create(Supplier<? extends Routing> routingBuilder)
Creates new instance form provided routing and default configuration.static WebServer
create(Supplier<? extends ServerConfiguration> configurationBuilder, Routing routing)
Creates a new instance from a provided configuration and a routing.static WebServer
create(Supplier<? extends ServerConfiguration> configurationBuilder, Supplier<? extends Routing> routingBuilder)
Creates new instance form provided configuration and routing.boolean
isRunning()
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
port(String socketName)
Returns a port number an additional named server socket is bound to and is listening on; or-1
if unknown or not active.CompletionStage<WebServer>
shutdown()
Attempt to gracefully shutdown server.CompletionStage<WebServer>
start()
Starts the server.void
updateTls(WebServerTls tls)
Update the TLS configuration of the default socketServerConfiguration.DEFAULT_SOCKET_NAME
.void
updateTls(WebServerTls tls, String socketName)
Update the TLS configuration of the named socket.CompletionStage<WebServer>
whenShutdown()
Completion stage is completed when server is shut down.
-
-
-
Method Detail
-
configuration
ServerConfiguration configuration()
Gets effective server configuration.- Returns:
- Server configuration
-
start
CompletionStage<WebServer> start()
Starts the server. Has no effect if server is running.- Returns:
- a completion stage of starting tryProcess
-
whenShutdown
CompletionStage<WebServer> whenShutdown()
Completion stage is completed when server is shut down.- Returns:
- a completion stage of the server
-
shutdown
CompletionStage<WebServer> shutdown()
Attempt to gracefully shutdown server. It is possible to use returnedCompletionStage
to react.RequestMethod can be called periodically.
- Returns:
- to react on finished shutdown tryProcess
- See Also:
start()
-
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
-
context
ContextualRegistry context()
Gets aWebServer
context.- Returns:
- a server context
-
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
int port(String socketName)
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
-
updateTls
void updateTls(WebServerTls tls)
Update the TLS configuration of the default socketServerConfiguration.DEFAULT_SOCKET_NAME
.- Parameters:
tls
- new TLS configuration- Throws:
IllegalStateException
- ifWebServerTls.sslContext()
returnsnull
or ifSocketConfiguration.ssl()
returnsnull
-
updateTls
void updateTls(WebServerTls tls, String socketName)
Update the TLS configuration of the named socket.- Parameters:
tls
- new TLS configurationsocketName
- specific named socket name- Throws:
IllegalStateException
- ifWebServerTls.sslContext()
returnsnull
or ifSocketConfiguration.ssl()
returnsnull
-
create
static WebServer create(Supplier<? extends ServerConfiguration> configurationBuilder, Routing routing)
Creates a new instance from a provided configuration and a routing.- Parameters:
configurationBuilder
- a server configuration builder that will be built as a first step of this method execution; may benull
routing
- a routing instance- Returns:
- a new web server instance
- Throws:
IllegalStateException
- if none SPI implementation foundNullPointerException
- if 'routing' parameter isnull
-
create
static WebServer create(Supplier<? extends ServerConfiguration> configurationBuilder, Supplier<? extends Routing> routingBuilder)
Creates new instance form provided configuration and routing.- Parameters:
configurationBuilder
- a server configuration builder that will be built as a first step of this method execution; may benull
routingBuilder
- a routing builder that will be built as a second step of this method execution- Returns:
- a new web server instance
- Throws:
IllegalStateException
- if none SPI implementation foundNullPointerException
- if 'routingBuilder' parameter isnull
-
create
static WebServer create(ServerConfiguration configuration, Supplier<? extends Routing> routingBuilder)
Creates new instance form provided configuration and routing.- Parameters:
configuration
- a server configuration instanceroutingBuilder
- a routing builder that will be built as a second step of this method execution- Returns:
- a new web server instance
- Throws:
IllegalStateException
- if none SPI implementation foundNullPointerException
- if 'routingBuilder' parameter isnull
-
create
static WebServer create(Routing routing)
Creates new instance form provided routing and default configuration.- Parameters:
routing
- a routing instance- Returns:
- a new web server instance
- Throws:
IllegalStateException
- if none SPI implementation foundNullPointerException
- if 'routing' parameter isnull
-
create
static WebServer create(ServerConfiguration configuration, Routing routing)
Creates new instance form provided configuration and routing.- Parameters:
configuration
- a server configuration instancerouting
- a routing instance- Returns:
- a new web server instance
- Throws:
IllegalStateException
- if none SPI implementation foundNullPointerException
- if 'routing' parameter isnull
-
create
static WebServer create(Supplier<? extends Routing> routingBuilder)
Creates new instance form provided routing and default configuration.- Parameters:
routingBuilder
- a routing builder instance that will be built as a first step of this method execution- Returns:
- a new web server instance
- Throws:
IllegalStateException
- if none SPI implementation foundNullPointerException
- if 'routing' parameter isnull
-
builder
static WebServer.Builder builder(Supplier<? extends Routing> routingBuilder)
Creates a builder of theWebServer
.- Parameters:
routingBuilder
- the routing builder; must not benull
- Returns:
- the builder
-
builder
static WebServer.Builder builder(Routing routing)
Creates a builder of theWebServer
.- Parameters:
routing
- the routing; must not benull
- Returns:
- the builder
-
-