org.springframework.boot.web.embedded.tomcat

Class TomcatWebServer

  • java.lang.Object
    • org.springframework.boot.web.embedded.tomcat.TomcatWebServer
    • Constructor Detail

      • 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,
                               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:
        2.3.0
    • Method Detail

      • 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)
      • getTomcat

        public org.apache.catalina.startup.Tomcat getTomcat()
        Returns access to the underlying Tomcat server.
        Returns:
        the Tomcat server
      • 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