Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBoss Startup and Shutdown classes

 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I execute my startup and shutdown classes in JBOSS. Like we do in weblogic.

Thnx
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look in run.bat and shutdown.bat. These call org.jboss.Main and org.jboss.Shutdown so should give you some clue.
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you want to do? Do you want to run code when your app is deployed and undeployed?
 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
exactly. I want to execute some piece of code when my server starts and stops.
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want some code to run at startup, you could either put it in a servlet and specify the load-on-startup flag, or you could write an MBean which will get initialised at system startup.

I'm not sure how you would run code at shutdown though...
 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of load-on-startup, using ServletContextInitializer is more elegant, as it provides both initialized() and destroyed() callback methods.
 
Wiley Snyder
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not put some perl at the top of your run.sh file ......
or if your using windows ... um I don't know good luck ....
 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it depends upon the purpose of startup tasks. If the startup task needs to use the resources started by the server, then the ServletContextInitializer is a right place.
Whereas, If the startup task needs just setting up some data, testing some external connections (out side the J2EE container), then these can go as part of run.sh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic