Class NettyWebServer

java.lang.Object
org.springframework.boot.web.embedded.netty.NettyWebServer
All Implemented Interfaces:
WebServer

public class NettyWebServer extends 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.
Since:
2.0.0
  • Constructor Details

    • NettyWebServer

      @Deprecated(since="3.2.0", forRemoval=true) public NettyWebServer(reactor.netty.http.server.HttpServer httpServer, org.springframework.http.server.reactive.ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new NettyWebServer instance.
      Parameters:
      httpServer - the HTTP server
      handlerAdapter - the handler adapter
      lifecycleTimeout - the lifecycle timeout, may be null
      shutdown - the shutdown, may be null
    • NettyWebServer

      public NettyWebServer(reactor.netty.http.server.HttpServer httpServer, org.springframework.http.server.reactive.ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout, Shutdown shutdown, org.springframework.http.client.ReactorResourceFactory resourceFactory)
      Creates a new NettyWebServer instance.
      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

      public void setRouteProviders(List<NettyRouteProvider> routeProviders)
    • start

      public void start() throws WebServerException
      Description copied from interface: WebServer
      Starts the web server. Calling this method on an already started server has no effect.
      Specified by:
      start in interface WebServer
      Throws:
      WebServerException - if the server cannot be started
    • getStartedLogMessage

      protected String getStartedLogMessage()
    • shutDownGracefully

      public void shutDownGracefully(GracefulShutdownCallback callback)
      Description copied from interface: WebServer
      Initiates a graceful shutdown of the web server. Handling of new requests is prevented and the given 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.
      Specified by:
      shutDownGracefully in interface WebServer
      Parameters:
      callback - the callback to invoke when the graceful shutdown completes
    • stop

      public void stop() throws WebServerException
      Description copied from interface: WebServer
      Stops the web server. Calling this method on an already stopped server has no effect.
      Specified by:
      stop in interface WebServer
      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.
      Specified by:
      getPort in interface WebServer
      Returns:
      the port (or -1 if none)