Class TomcatWebServer

java.lang.Object
org.springframework.boot.tomcat.TomcatWebServer
All Implemented Interfaces:
org.springframework.boot.web.server.WebServer

public class TomcatWebServer extends Object implements org.springframework.boot.web.server.WebServer
WebServer that can be used to control a Tomcat web server. Usually this class should be created using the TomcatReactiveWebServerFactory or TomcatServletWebServerFactory, but not directly.
Since:
4.0.0
  • Constructor Details

    • TomcatWebServer

      public TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat)
      Create a new TomcatWebServer instance.
      Parameters:
      tomcat - the underlying Tomcat server
    • TomcatWebServer

      public TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart)
      Create a new TomcatWebServer instance.
      Parameters:
      tomcat - the underlying Tomcat server
      autoStart - if the server should be started
    • TomcatWebServer

      public TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart, org.springframework.boot.web.server.Shutdown shutdown)
      Create a new TomcatWebServer instance.
      Parameters:
      tomcat - the underlying Tomcat server
      autoStart - if the server should be started
      shutdown - type of shutdown supported by the server
      Since:
      4.0.0
  • Method Details

    • 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
    • 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
    • destroy

      public void destroy() throws org.springframework.boot.web.server.WebServerException
      Specified by:
      destroy 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
    • getTomcat

      public org.apache.catalina.startup.Tomcat getTomcat()
      Returns access to the underlying Tomcat server.
      Returns:
      the Tomcat server
    • shutDownGracefully

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