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 Summary
ConstructorDescriptionNettyWebServer
(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 newNettyWebServer
instance. -
Method Summary
Modifier and TypeMethodDescriptionint
getPort()
Return the port this server is listening on.protected String
void
setRouteProviders
(List<NettyRouteProvider> routeProviders) void
shutDownGracefully
(GracefulShutdownCallback callback) Initiates a graceful shutdown of the Netty web server.void
start()
Starts the web server.void
stop()
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 newNettyWebServer
instance.- Parameters:
httpServer
- the HTTP serverhandlerAdapter
- the handler adapterlifecycleTimeout
- the lifecycle timeout, may benull
shutdown
- the shutdown, may benull
-
NettyWebServer
public NettyWebServer(reactor.netty.http.server.HttpServer httpServer, ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown, ReactorResourceFactory resourceFactory) Creates a newNettyWebServer
instance.- Parameters:
httpServer
- the HTTP serverhandlerAdapter
- the handler adapterlifecycleTimeout
- the lifecycle timeout, may benull
shutdown
- the shutdown, may benull
resourceFactory
- the factory for the server'sloop resources
, may benull
- Since:
- 3.2.0
-
-
Method Details
-
setRouteProviders
-
start
Description copied from interface:WebServer
Starts the web server. Calling this method on an already started server has no effect.- Specified by:
start
in interfaceWebServer
- Throws:
WebServerException
- if the server cannot be started
-
getStartedLogMessage
-
shutDownGracefully
Initiates a graceful shutdown of the Netty web server. Handling of new requests is prevented and the givencallback
is invoked at the end of the attempt. The attempt can be explicitly ended by invokingstop()
.Once shutdown has been initiated Netty will reject any new connections. Requests + on existing idle connections will also be rejected.
- Specified by:
shutDownGracefully
in interfaceWebServer
- Parameters:
callback
- the callback to invoke when the graceful shutdown completes
-
stop
Description copied from interface:WebServer
Stops the web server. Calling this method on an already stopped server has no effect.- Specified by:
stop
in interfaceWebServer
- Throws:
WebServerException
- if the server cannot be stopped
-
getPort
public int getPort()Description copied from interface:WebServer
Return the port this server is listening on.
-
NettyWebServer(HttpServer, ReactorHttpHandlerAdapter, Duration, Shutdown, ReactorResourceFactory)