接缝 - 拦截器

发布于 2024-08-06 23:23:00 字数 98 浏览 3 评论 0原文

我想拦截对所有接缝组件的所有方法调用,看看这是否有助于记录异常。我想我可以通过获取所有组件和注册拦截器的列表并简单地将我想要的组件添加到该列表中来做到这一点。

沃尔特

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爺獨霸怡葒院 2024-08-13 23:23:00

最好使用 Seam 的异常处理程序。
您可以这样做:

@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);
}

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);
}
倚栏听风 2024-08-13 23:23:00

尝试以更高的优先级使用您自己的 ExceptionFilter 覆盖默认的 ExceptionFilter。


@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
  }
}

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
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文