5 Replies Latest reply on Jun 24, 2009 5:31 AM by Walter White

    Subclass the SeamPhaseListener

    Gerson M Newbie

      Is there a easy way to tell Seam to use a non-default SeamPhaseListener by NOT editing the Seam JAR file (faces-config.xml)?

        • 1. Re: Subclass the SeamPhaseListener
          Keith Naas Novice

          What is a nondefault SeamPhaseListener necessary?  Can you react to Seam events instead by observing or configuration actions on the org.jboss.seam.afterPhase, and org.jboss.seam.beforePhase

          • 2. Re: Subclass the SeamPhaseListener
            Gerson M Newbie

            I have a SeamPhaseListener's subclass... I just want to register that to the Seam but without editing the Seam JAR file (faces-config.xml). There is a way to do that?

            • 3. Re: Subclass the SeamPhaseListener
              Keith Naas Novice

              Just to clarify, why do you need a different PhaseListener?

              You can add a PhaseListener in your own application's faces-config.xml since JSF supports having as many as you want.  However, to remove the SeamPhaseListener from automatically registering, I'm not sure. 

              • 4. Re: Subclass the SeamPhaseListener
                Pete Muir Master

                Keith is correct, no you can't. And you shouldn't need to.

                • 5. Re: Subclass the SeamPhaseListener
                  Walter White Novice


                  I know this thread is a little bit old, but I have a question regarding subclassing the SeamPhaseListener.

                  The only reason I would want to subclass the SeamPhaseListener is to support better auditing of any request coming into the system and any response generated by the system for security purposes.

                  If I modified the PhaseListener, I could better control when the Lifecycle methods are executed, specifically, when the request is ended.  For me, it ends a bit too early.

                  I currently have a ServletFilter that logs the response, since it calls chain.doFilter(), it is out of any context by the time it gets back control.  I also have a ServletRequestListener which implements the javax.servlet.ServletRequestListener interface which is responsible for logging the request.  When the request comes into the system, I capture that information and wait till the response is written (requestDestroyedEvent) then update the information with the time it took to generate a response as well as the response sent to the client.

                  I have the response from the ServletFilter that captured the information and attached it to the request attribute.

                  The issue I am having is these operations occur outside of any active context causing an exception.

                  My question is, what is the best way to log this information (I realize the performance hits), and secondly, my approach would be to open a context when the request is destroyed and simply let the Faces Servlet handle all requests so it handles the Lifecycle stuff.  I'm sure this will work, but is it the best way to do it if I want to be able to better log this information?