This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes JBoss Startup and Shutdown classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBoss Startup and Shutdown classes" Watch "JBoss Startup and Shutdown classes" New topic
Author

JBoss Startup and Shutdown classes

Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
How can I execute my startup and shutdown classes in JBOSS. Like we do in weblogic.

Thnx
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have a look in run.bat and shutdown.bat. These call org.jboss.Main and org.jboss.Shutdown so should give you some clue.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

What exactly do you want to do? Do you want to run code when your app is deployed and undeployed?
Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
exactly. I want to execute some piece of code when my server starts and stops.
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

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

Joined: Jan 24, 2006
Posts: 106
Instead of load-on-startup, using ServletContextInitializer is more elegant, as it provides both initialized() and destroyed() callback methods.
Wiley Snyder
Greenhorn

Joined: Oct 26, 2005
Posts: 23
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

Joined: Jan 24, 2006
Posts: 106
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JBoss Startup and Shutdown classes
 
Similar Threads
Shut Down a SSL Enabled JBOSS
JBoss Startup and Shutdown classes
Could not delete temporary files and directories
Application server start/stop event
Application Lifecycle Events