André Warnier wrote:
> - we have a JVM.  That is the real process that is running, at the OS
> level.  That process can be killed, or decide to stop running, at which
> point we don't have a JVM process anymore, and thus no Tomcat and no
> webapps at all.  That's kind of drastic and definitive.
Yes.

> - "inside" the JVM, we have a Tomcat.  Basically, that is only code
> which the JVM is "running" (a bit like a Perl interpreter process runs
> the list of Perl opcodes it has compiled a perl script into).  Tomcat
> can somehow decide that it is tired of living, and tell the JVM to stop
> running it.  At which point we have no webapps and no Tomcat anymore,
> and consequently (I presume, but this is already a bit less clear), no
> JVM anymore either, because not having anything to do anymore, it would
> also exit. Or ?
When Tomcat stops, it stops the JVM.

> - then inside Tomcat, we have webapps.  It's already getting more
> mysterious there for me, but I resolve this intellectually by imagining
> that a webapp is just a "subroutine" which Tomcat runs from time to
> time, in response to a HTTP request for example.  So a webapp in fact
> "is" Tomcat, in the sense that when it runs it does so as an integral
> part of the Tomcat process.  So much so that if a webapp were to execute
> a "system.exit()", it would take the whole Tomcat (and JVM) with it. Yes ?
Correct. Unless you use a security manager which would stop the webapp calling
system.exit()

> So now, when the Tomcat Manager application decides to "stop a web
> application", what it really does is just to prevent any further calls
> to this web application in the future, by removing some entry in a table
> of "runnable webapps".  In other words, it does not really "stop" or
> "kill" any currently running instance of that webapp (those are allowed
> to finish what they are doing and "return()" to Tomcat main code), but
> it makes it so that any further call to "/mywebapp" will be met by a
> "what ?" response.
It depends :). Normally a 404 (not found) will be sent.

> Is this a correct interpretation ?
Almost. New requests are rejected. Tomcat gives current requests a 'reasonable'
period to stop processing. I forget what this is but it is of the order of tens
of seconds.

> Now comes the basic question : can a webapp stop itself, without taking
> the whole Tomcat and JVM with it ?  In other words, in response to
> something (a variable being a certain value, or the interception of some
> event or whatever), can my webapp decide to stop doing what it is
> currently doing, clean up after itself, and then do something to prevent
> itself ever being called again in the future of this Tomcat instance ?
> (or say at least until some external intervention activates it again).
Yes. It should be able to ask the manager to stop it or undeploy it.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to