public class TomcatWebServer extends Object implements WebServer
WebServer
that can be used to control a Tomcat web server. Usually this class
should be created using the TomcatReactiveWebServerFactory
of
TomcatServletWebServerFactory
, but not directly.Constructor and Description |
---|
TomcatWebServer(Tomcat tomcat)
Create a new
TomcatWebServer instance. |
TomcatWebServer(Tomcat tomcat,
boolean autoStart)
Create a new
TomcatWebServer instance. |
TomcatWebServer(Tomcat tomcat,
boolean autoStart,
Duration shutdownGracePeriod)
Create a new
TomcatWebServer instance. |
Modifier and Type | Method and Description |
---|---|
int |
getPort()
Return the port this server is listening on.
|
Tomcat |
getTomcat()
Returns access to the underlying Tomcat server.
|
boolean |
shutDownGracefully()
Gracefully shuts down the web server by preventing the handling of new requests and
waiting for a configurable period for there to be no active requests.
|
void |
start()
Starts the web server.
|
void |
stop()
Stops the web server.
|
public TomcatWebServer(Tomcat tomcat)
TomcatWebServer
instance.tomcat
- the underlying Tomcat serverpublic TomcatWebServer(Tomcat tomcat, boolean autoStart)
TomcatWebServer
instance.tomcat
- the underlying Tomcat serverautoStart
- if the server should be startedpublic TomcatWebServer(Tomcat tomcat, boolean autoStart, Duration shutdownGracePeriod)
TomcatWebServer
instance.tomcat
- the underlying Tomcat serverautoStart
- if the server should be startedshutdownGracePeriod
- grace period to use when shutting downpublic void start() throws WebServerException
WebServer
start
in interface WebServer
WebServerException
- if the server cannot be startedpublic void stop() throws WebServerException
WebServer
stop
in interface WebServer
WebServerException
- if the server cannot be stoppedpublic int getPort()
WebServer
public Tomcat getTomcat()
public boolean shutDownGracefully()
WebServer
shutDownGracefully
in interface WebServer
true
if graceful shutdown completed within the period, otherwise
false