public interface WebServer
Provides basic lifecycle and monitoring API.
Instance can be created from Routing and optionally from ServerConfiguration using
create(Routing), create(ServerConfiguration, Routing) or builder(Routing)methods and their builder
enabled overloads.
| Modifier and Type | Interface and Description |
|---|---|
static class |
WebServer.Builder
WebServer builder class provides a convenient way to set up WebServer with multiple server
sockets and optional multiple routings.
|
| Modifier and Type | Method and Description |
|---|---|
static WebServer.Builder |
builder(Routing routing)
Creates a builder of the
WebServer. |
static WebServer.Builder |
builder(Supplier<? extends Routing> routingBuilder)
Creates a builder of the
WebServer. |
ServerConfiguration |
configuration()
Gets effective server configuration.
|
ContextualRegistry |
context()
Gets a
WebServer 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()
Returns
true 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.
|
CompletionStage<WebServer> |
whenShutdown()
Completion stage is completed when server is shut down.
|
ServerConfiguration configuration()
CompletionStage<WebServer> start()
CompletionStage<WebServer> whenShutdown()
CompletionStage<WebServer> shutdown()
CompletionStage to react.
RequestMethod can be called periodically.
start()boolean isRunning()
true if the server is currently running. Running server in stopping phase returns true until it
is not fully stopped.true if server is runningContextualRegistry context()
WebServer context.default int port()
-1 if unknown or not active.
It is supported only when server is running.
-1 if unknown or the default server socket is not activeint port(String socketName)
-1 if unknown or not active.socketName - the name of an additional named server socket-1 if socket name is unknown or the server socket is not activestatic WebServer create(Supplier<? extends ServerConfiguration> configurationBuilder, Routing routing)
configurationBuilder - a server configuration builder that will be built as a first step
of this method execution; may be nullrouting - a routing instanceIllegalStateException - if none SPI implementation foundNullPointerException - if 'routing' parameter is nullstatic WebServer create(Supplier<? extends ServerConfiguration> configurationBuilder, Supplier<? extends Routing> routingBuilder)
configurationBuilder - a server configuration builder that will be built as a first step
of this method execution; may be nullroutingBuilder - a routing builder that will be built as a second step of this method executionIllegalStateException - if none SPI implementation foundNullPointerException - if 'routingBuilder' parameter is nullstatic WebServer create(ServerConfiguration configuration, Supplier<? extends Routing> routingBuilder)
configuration - a server configuration instanceroutingBuilder - a routing builder that will be built as a second step of this method executionIllegalStateException - if none SPI implementation foundNullPointerException - if 'routingBuilder' parameter is nullstatic WebServer create(Routing routing)
routing - a routing instanceIllegalStateException - if none SPI implementation foundNullPointerException - if 'routing' parameter is nullstatic WebServer create(ServerConfiguration configuration, Routing routing)
configuration - a server configuration instancerouting - a routing instanceIllegalStateException - if none SPI implementation foundNullPointerException - if 'routing' parameter is nullstatic WebServer create(Supplier<? extends Routing> routingBuilder)
routingBuilder - a routing builder instance that will be built as a first step
of this method executionIllegalStateException - if none SPI implementation foundNullPointerException - if 'routing' parameter is nullstatic WebServer.Builder builder(Supplier<? extends Routing> routingBuilder)
WebServer.routingBuilder - the routing builder; must not be nullstatic WebServer.Builder builder(Routing routing)
WebServer.routing - the routing; must not be nullCopyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.