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
or
TomcatServletWebServerFactory
, but not directly.Constructor and Description |
---|
TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat)
Create a new
TomcatWebServer instance. |
TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat,
boolean autoStart)
Create a new
TomcatWebServer instance. |
TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat,
boolean autoStart,
Shutdown shutdown)
Create a new
TomcatWebServer instance. |
Modifier and Type | Method and Description |
---|---|
int |
getPort()
Return the port this server is listening on.
|
org.apache.catalina.startup.Tomcat |
getTomcat()
Returns access to the underlying Tomcat server.
|
void |
shutDownGracefully(GracefulShutdownCallback callback)
Initiates a graceful shutdown of the web server.
|
void |
start()
Starts the web server.
|
void |
stop()
Stops the web server.
|
public TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat)
TomcatWebServer
instance.tomcat
- the underlying Tomcat serverpublic TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart)
TomcatWebServer
instance.tomcat
- the underlying Tomcat serverautoStart
- if the server should be startedpublic TomcatWebServer(org.apache.catalina.startup.Tomcat tomcat, boolean autoStart, Shutdown shutdown)
TomcatWebServer
instance.tomcat
- the underlying Tomcat serverautoStart
- if the server should be startedshutdown
- type of shutdown supported by the serverpublic 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 org.apache.catalina.startup.Tomcat getTomcat()
public void shutDownGracefully(GracefulShutdownCallback callback)
WebServer
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.shutDownGracefully
in interface WebServer
callback
- the callback to invoke when the graceful shutdown completes