Class NettyWebServer

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

public class NettyWebServer extends Object implements org.springframework.boot.web.server.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:
4.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    NettyWebServer(reactor.netty.http.server.HttpServer httpServer, org.springframework.http.server.reactive.ReactorHttpHandlerAdapter handlerAdapter, @Nullable Duration lifecycleTimeout, @Nullable org.springframework.boot.web.server.Shutdown shutdown, @Nullable org.springframework.http.client.ReactorResourceFactory resourceFactory)
    Creates a new NettyWebServer instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    protected String
     
    void
     
    void
    shutDownGracefully(org.springframework.boot.web.server.GracefulShutdownCallback callback)
    Initiates a graceful shutdown of the Netty web server.
    void
     
    void
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.boot.web.server.WebServer

    destroy
  • Constructor Details

    • NettyWebServer

      public NettyWebServer(reactor.netty.http.server.HttpServer httpServer, org.springframework.http.server.reactive.ReactorHttpHandlerAdapter handlerAdapter, @Nullable Duration lifecycleTimeout, @Nullable org.springframework.boot.web.server.Shutdown shutdown, @Nullable 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:
      4.0.0
  • Method Details

    • setRouteProviders

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

      public void start() throws org.springframework.boot.web.server.WebServerException
      Specified by:
      start in interface org.springframework.boot.web.server.WebServer
      Throws:
      org.springframework.boot.web.server.WebServerException
    • getStartedLogMessage

      protected String getStartedLogMessage()
    • shutDownGracefully

      public void shutDownGracefully(org.springframework.boot.web.server.GracefulShutdownCallback callback)
      Initiates a graceful shutdown of the Netty 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 stop().

      Once shutdown has been initiated Netty will reject any new connections. Requests + on existing idle connections will also be rejected.

      Specified by:
      shutDownGracefully in interface org.springframework.boot.web.server.WebServer
    • stop

      public void stop() throws org.springframework.boot.web.server.WebServerException
      Specified by:
      stop in interface org.springframework.boot.web.server.WebServer
      Throws:
      org.springframework.boot.web.server.WebServerException
    • getPort

      public int getPort()
      Specified by:
      getPort in interface org.springframework.boot.web.server.WebServer