aspose file tools*
The moose likes Java in General and the fly likes tomcat style startup - shutdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "tomcat style startup - shutdown" Watch "tomcat style startup - shutdown" New topic
Author

tomcat style startup - shutdown

Ariffin Ahmad
Ranch Hand

Joined: Aug 16, 2001
Posts: 84
i'm interested on knowing, how i can do something like tomcat, i mean, i can start and stop my application in some jvm, using the same class file, with different attribute....
can anybody explain to me how?....
what i know, each time we run our appl, they will run in different jvm, how come in tomcat, we can call the same class which at the same time response to the same jvm?....
can anubody, explain how to do that?.... :roll:
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
You could accomplish something like this by having a never ending java program (like tomcat) that listens for user input (or in the case of tomcat, incoming connections). When input is detected, it would start a new Thread that would run the program's main method. It would have to pass in the correct parameters to the main method in the form of a String[]. The big draw back to this is that System.exit() will exit all the programs. Also System.out and System.in will be shared amoung all the programs. One way around the exit() problem would be to extend the security manager to throw an exception in System.exit() were called. Notice that Tomcat gets around this problem by using servlets which have an expected API that developers are supposed to use which does not have these side effects.
Ariffin Ahmad
Ranch Hand

Joined: Aug 16, 2001
Posts: 84
Originally posted by Steve Deadsea:
You could accomplish something like this by having a never ending java program (like tomcat) that listens for user input (or in the case of tomcat, incoming connections). When input is detected, it would start a new Thread that would run the program's main method. It would have to pass in the correct parameters to the main method in the form of a String[]. The big draw back to this is that System.exit() will exit all the programs. Also System.out and System.in will be shared amoung all the programs. One way around the exit() problem would be to extend the security manager to throw an exception in System.exit() were called. Notice that Tomcat gets around this problem by using servlets which have an expected API that developers are supposed to use which does not have these side effects.

sorry man...
it just get me more confused...
i can understand the never ending java program's part, but, the rest, blur.....
can u give me more info, please..........
 
wood burning stoves
 
subject: tomcat style startup - shutdown