This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat style startup - shutdown

 
Ariffin Ahmad
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..........
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic