Question

I want to intercept all method invocations to all seam components to see if that would help in logging exceptions. I was thinking that I could do this by getting the list of all components and registered interceptors and simply adding the one I want to that list.

Walter

Was it helpful?

Solution

Try to override the default ExceptionFilter with your own at a higher precedence.


@Name("org.jboss.seam.web.exceptionFilter")
@Install(precedence = MOCK, classDependencies="javax.faces.context.FacesContext")
@BypassInterceptors
@Filter(within="org.jboss.seam.web.ajax4jsfFilter")
public class ExceptionFilter extends org.jboss.seam.web.ExceptionFilter

  @Override
  protected endWebRequestAfterException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception e)  {
  // here you log exceptions
  }
}

OTHER TIPS

Its better to use Seam's Exception handler. This is how you can do it:

@Name("org.jboss.seam.exception.exceptions")
@Scope(ScopeType.APPLICATION)
@Install(precedence = Install.APPLICATION)
@BypassInterceptors
public class ExceptionHandler extends org.jboss.seam.exception.Exceptions {

    public void handle(Exception e) throws Exception {
            //Log your exception here if you want 
            Events.instance().raiseAsynchronousEvent("SomeListener",e.getMessage());
    super.handle(e);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top