2 Replies Latest reply on Jun 17, 2008 1:54 PM by heffner

    Observe shutdown of a seam application

    heffner

      I'm using an observer class annotated like this:


          @Observer("org.jboss.seam.postInitialization")
          public void seamInitialized() {
              // doing many things with Seam components :-)
          }
      


      Works fine as expected.


      But, I would also like to know when the application stops or will be restarted. Within the Seam Sources I havn't found any Event like "preShutdown".


      I've tried to solve this using a MBean, but there I can't use the Seam components.


      Is there any way to get notified within the Seam application context?


      Stephan

        • 1. Re: Observe shutdown of a seam application
          leonardinius

          Hi,
          My proposed solution would be


          @Name("applicationLifecycle")
          @Startup
          @Scope(ScopeType.APPLICATION)
          public class ApplicationLifecycle {
          
               @Logger
               Log logger;
          
               public ApplicationLifecycle() {
               }
          
               @Create
               public void onCreate() {
                    logger.info("applicationLifecycle started");
               }
          
               @Observer("org.jboss.seam.preDestroyContext." + "APPLICATION")
               public void onDestroy() {
               }
          
          }
          

          • 2. Re: Observe shutdown of a seam application
            heffner

            Many thanks! I tried that approach before but made a mistake setting the Scope.