Class NettyWebServer
java.lang.Object
org.springframework.boot.web.embedded.netty.NettyWebServer
- All Implemented Interfaces:
- 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.- Since:
- 2.0.0
- Author:
- Brian Clozel, Madhura Bhave, Andy Wilkinson
- 
Constructor SummaryConstructorsConstructorDescriptionNettyWebServer(reactor.netty.http.server.HttpServer httpServer, ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown) Deprecated, for removal: This API element is subject to removal in a future version.NettyWebServer(reactor.netty.http.server.HttpServer httpServer, ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown, ReactorResourceFactory resourceFactory) Creates a newNettyWebServerinstance.
- 
Method SummaryModifier and TypeMethodDescriptionintgetPort()Return the port this server is listening on.protected StringvoidsetRouteProviders(List<NettyRouteProvider> routeProviders) voidshutDownGracefully(GracefulShutdownCallback callback) Initiates a graceful shutdown of the web server.voidstart()Starts the web server.voidstop()Stops the web server.
- 
Constructor Details- 
NettyWebServer@Deprecated(since="3.2.0", forRemoval=true) public NettyWebServer(reactor.netty.http.server.HttpServer httpServer, ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown) Deprecated, for removal: This API element is subject to removal in a future version.since 3.2.0 for removal in 3.4.0 in favor ofNettyWebServer(HttpServer, ReactorHttpHandlerAdapter, Duration, Shutdown, ReactorResourceFactory)Creates a newNettyWebServerinstance.- Parameters:
- httpServer- the HTTP server
- handlerAdapter- the handler adapter
- lifecycleTimeout- the lifecycle timeout, may be- null
- shutdown- the shutdown, may be- null
 
- 
NettyWebServerpublic NettyWebServer(reactor.netty.http.server.HttpServer httpServer, ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown, ReactorResourceFactory resourceFactory) Creates a newNettyWebServerinstance.- Parameters:
- httpServer- the HTTP server
- handlerAdapter- the handler adapter
- lifecycleTimeout- the lifecycle timeout, may be- null
- shutdown- the shutdown, may be- null
- resourceFactory- the factory for the server's- loop resources, may be- null
- Since:
- 3.2.0
 
 
- 
- 
Method Details- 
setRouteProviders
- 
startDescription copied from interface:WebServerStarts the web server. Calling this method on an already started server has no effect.- Specified by:
- startin interface- WebServer
- Throws:
- WebServerException- if the server cannot be started
 
- 
getStartedLogMessage
- 
shutDownGracefullyDescription copied from interface:WebServerInitiates a graceful shutdown of the web server. Handling of new requests is prevented and the givencallbackis invoked at the end of the attempt. The attempt can be explicitly ended by invokingWebServer.stop(). The default implementation invokes the callback immediately withGracefulShutdownResult.IMMEDIATE, i.e. no attempt is made at a graceful shutdown.- Specified by:
- shutDownGracefullyin interface- WebServer
- Parameters:
- callback- the callback to invoke when the graceful shutdown completes
 
- 
stopDescription copied from interface:WebServerStops the web server. Calling this method on an already stopped server has no effect.- Specified by:
- stopin interface- WebServer
- Throws:
- WebServerException- if the server cannot be stopped
 
- 
getPortpublic int getPort()Description copied from interface:WebServerReturn the port this server is listening on.
 
- 
NettyWebServer(HttpServer, ReactorHttpHandlerAdapter, Duration, Shutdown, ReactorResourceFactory)