1) You can write a MBean and use the createService and destroyService methods of MBeanSupport Class to do your startup and shutdown actions. You can also bundle ur ear within the sar so they are treated as a single unit. This wud be a jboss specific solution
2) You can use the unsetContext to do the unloading and setContext to do the startup operations. In our case, we have a few MDBs and they need to grab properties when the app deploys. So we use the setMEssageDrivenContext to get it . Note this is in Weblogic but shud be the same in Jboss.