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 Summary
ConstructorsConstructorDescriptionTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat) Create a newTomcatWebServerinstance.TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart) Create a newTomcatWebServerinstance.TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart, org.springframework.boot.web.server.Shutdown shutdown) Create a newTomcatWebServerinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()intgetPort()org.apache.catalina.startup.TomcatReturns access to the underlying Tomcat server.voidshutDownGracefully(org.springframework.boot.web.server.GracefulShutdownCallback callback) Initiates a graceful shutdown of the Tomcat web server.voidstart()voidstop()
-
Constructor Details
-
TomcatWebServer
public TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat) Create a newTomcatWebServerinstance.- Parameters:
tomcat- the underlying Tomcat server
-
TomcatWebServer
public TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart) Create a newTomcatWebServerinstance.- Parameters:
tomcat- the underlying Tomcat serverautoStart- 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 newTomcatWebServerinstance.- Parameters:
tomcat- the underlying Tomcat serverautoStart- if the server should be startedshutdown- 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:
startin interfaceorg.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:
stopin interfaceorg.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:
destroyin interfaceorg.springframework.boot.web.server.WebServer- Throws:
org.springframework.boot.web.server.WebServerException
-
getPort
public int getPort()- Specified by:
getPortin interfaceorg.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 givencallbackis invoked at the end of the attempt. The attempt can be explicitly ended by invokingstop().Once shutdown has been initiated Tomcat will reject any new connections. Requests on existing idle connections will also be rejected.
- Specified by:
shutDownGracefullyin interfaceorg.springframework.boot.web.server.WebServer
-