Class TomcatWebServer
java.lang.Object
org.springframework.boot.web.embedded.tomcat.TomcatWebServer
- All Implemented Interfaces:
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:
- 2.0.0
- Author:
- Brian Clozel, Kristine Jetzke
-
Constructor Summary
ConstructorsConstructorDescriptionTomcatWebServer(Tomcat tomcat) Create a newTomcatWebServerinstance.TomcatWebServer(Tomcat tomcat, boolean autoStart) Create a newTomcatWebServerinstance.TomcatWebServer(Tomcat tomcat, boolean autoStart, Shutdown shutdown) Create a newTomcatWebServerinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys the web server such that it cannot be started again.intgetPort()Return the port this server is listening on.Returns access to the underlying Tomcat server.voidshutDownGracefully(GracefulShutdownCallback callback) Initiates a graceful shutdown of the Tomcat web server.voidstart()Starts the web server.voidstop()Stops the web server.
-
Constructor Details
-
TomcatWebServer
Create a newTomcatWebServerinstance.- Parameters:
tomcat- the underlying Tomcat server
-
TomcatWebServer
Create a newTomcatWebServerinstance.- Parameters:
tomcat- the underlying Tomcat serverautoStart- if the server should be started
-
TomcatWebServer
Create a newTomcatWebServerinstance.- Parameters:
tomcat- the underlying Tomcat serverautoStart- if the server should be startedshutdown- type of shutdown supported by the server- Since:
- 2.3.0
-
-
Method Details
-
start
Description copied from interface:WebServerStarts the web server. Calling this method on an already started server has no effect.- Specified by:
startin interfaceWebServer- Throws:
WebServerException- if the server cannot be started
-
stop
Description copied from interface:WebServerStops the web server. Calling this method on an already stopped server has no effect.- Specified by:
stopin interfaceWebServer- Throws:
WebServerException- if the server cannot be stopped
-
destroy
Description copied from interface:WebServerDestroys the web server such that it cannot be started again.- Specified by:
destroyin interfaceWebServer- Throws:
WebServerException
-
getPort
public int getPort()Description copied from interface:WebServerReturn the port this server is listening on. -
getTomcat
Returns access to the underlying Tomcat server.- Returns:
- the Tomcat server
-
shutDownGracefully
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 interfaceWebServer- Parameters:
callback- the callback to invoke when the graceful shutdown completes
-