You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/12/23 12:08:32 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup Catalina.java
remm 2003/12/23 03:08:32
Modified: catalina/src/share/org/apache/catalina/startup Catalina.java
Log:
- Allow disabling the shutdown hook. This is useful in embedded mode
(since the main class is not so bad for embedding).
Revision Changes Path
1.23 +31 -7 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/Catalina.java
Index: Catalina.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/Catalina.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Catalina.java 14 Nov 2003 10:02:10 -0000 1.22
+++ Catalina.java 23 Dec 2003 11:08:32 -0000 1.23
@@ -139,10 +139,17 @@
*/
protected boolean stopping = false;
+
+ /**
+ * Use shutdown hook flag.
+ */
+ protected boolean useShutdownHook = true;
+
+
/**
* Shutdown hook.
*/
- protected Thread shutdownHook = new CatalinaShutdownHook();
+ protected Thread shutdownHook = null;
// ------------------------------------------------------------- Properties
@@ -163,6 +170,16 @@
}
+ public void setUseShutdownHook(boolean useShutdownHook) {
+ this.useShutdownHook = useShutdownHook;
+ }
+
+
+ public boolean getUseShutdownHook() {
+ return useShutdownHook;
+ }
+
+
/**
* Set the shared extensions class loader.
*
@@ -589,7 +606,12 @@
try {
// Register shutdown hook
- Runtime.getRuntime().addShutdownHook(shutdownHook);
+ if (useShutdownHook) {
+ if (shutdownHook == null) {
+ shutdownHook = new CatalinaShutdownHook();
+ }
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ }
} catch (Throwable t) {
// This will fail on JDK 1.2. Ignoring, as Tomcat can run
// fine without the shutdown hook.
@@ -611,7 +633,9 @@
try {
// Remove the ShutdownHook first so that server.stop()
// doesn't get invoked twice
- Runtime.getRuntime().removeShutdownHook(shutdownHook);
+ if (useShutdownHook) {
+ Runtime.getRuntime().removeShutdownHook(shutdownHook);
+ }
} catch (Throwable t) {
// This will fail on JDK 1.2. Ignoring, as Tomcat can run
// fine without the shutdown hook.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org