public class NettyWebServer extends java.lang.Object implements WebServer
WebServer
that can be used to control a Reactor Netty web server. Usually this
class should be created using the NettyReactiveWebServerFactory
and not
directly.Constructor and Description |
---|
NettyWebServer(reactor.netty.http.server.HttpServer httpServer,
org.springframework.http.server.reactive.ReactorHttpHandlerAdapter handlerAdapter,
java.time.Duration lifecycleTimeout,
Shutdown shutdown) |
Modifier and Type | Method and Description |
---|---|
int |
getPort()
Return the port this server is listening on.
|
void |
setRouteProviders(java.util.List<NettyRouteProvider> routeProviders) |
void |
shutDownGracefully(GracefulShutdownCallback callback)
Initiates a graceful shutdown of the web server.
|
void |
start()
Starts the web server.
|
void |
stop()
Stops the web server.
|
public NettyWebServer(reactor.netty.http.server.HttpServer httpServer, org.springframework.http.server.reactive.ReactorHttpHandlerAdapter handlerAdapter, java.time.Duration lifecycleTimeout, Shutdown shutdown)
public void setRouteProviders(java.util.List<NettyRouteProvider> routeProviders)
public void start() throws WebServerException
WebServer
start
in interface WebServer
WebServerException
- if the server cannot be startedpublic void shutDownGracefully(GracefulShutdownCallback callback)
WebServer
callback
is invoked at the end of the attempt. The
attempt can be explicitly ended by invoking WebServer.stop()
. The default
implementation invokes the callback immediately with
GracefulShutdownResult.IMMEDIATE
, i.e. no attempt is made at a graceful
shutdown.shutDownGracefully
in interface WebServer
callback
- the callback to invoke when the graceful shutdown completespublic void stop() throws WebServerException
WebServer
stop
in interface WebServer
WebServerException
- if the server cannot be stopped