1 Reply Latest reply on Mar 17, 2011 11:14 AM by Tim Haley

    POJO Service in an ear to provide lifecycle hooks?

    Tim Haley Newbie

      I have an enterprise application that currently deploys and runs on WebSphere and Weblogic that I would like to port to JBoss.

      • When the application is started, there is some initialization code that needs to be run.
      • When the application is stopped, there is some cleanup code that needs to be run.


      I am trying to determine the proper way to do this in JBoss 5. On another thread, I read that a Service MBean could provide that functionality.


      Can I simply annotate an EJB 3.0 stateful session bean with @Service to make it a singleton, @Management to make it an MBean, implement the management lifecycle methods and package the bean inside my ear file? The documentation says that the lifecycle methods are for the lifecycle of the bean, will my bean have the same lifecycle as my application? How can I ensure that it does?


      I would appreciate any help you can provide, including pointing me to the right place in the documentation.