The JBoss way is to create a .sar file and an MBean that receives lifecycle events.
Here's an article I found quickly on creating services.
http://blog.platinumsolutions.com/node/85
Your .sar gets bundled with your .ear ...
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070293#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...