我正在使用OmniFaces (1.7) FullAjaxExceptionHandler在 ajax 请求期间处理 (ViewExpired)Exception。
我不想让 FullAjaxExceptionHandler 像默认实现那样记录具有 SEVERE 级别的异常。所以我确实重写了logException方法,但仍然调用了默认方法而不是被重写的方法。
我注册了以下工厂:
<factory>
<exception-handler-factory>my.package.ViewExpiredExceptionHandlerFactory</exception-handler-factory>
</factory>
<factory>
<exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
</factory>
这是我的ViewExpiredExceptionHandlerFactory
public class ViewExpiredExceptionHandlerFactory extends ExceptionHandlerFactory {
private ExceptionHandlerFactory parent;
public ViewExpiredExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler result = parent.getExceptionHandler();
result = new ViewExpiredExceptionHandler(result);
return result;
}
}
和扩展的FullAjaxExceptionHandler
public class ViewExpiredExceptionHandler extends FullAjaxExceptionHandler {
private static final Logger LOGGER = Logger.getLogger(ViewExpiredExceptionHandler.class);
private ExceptionHandler wrapped;
public ViewExpiredExceptionHandler(ExceptionHandler wrapped) {
super(wrapped);
this.wrapped = wrapped;
}
@Override
public ExceptionHandler getWrapped() {
return this.wrapped;
}
@Override
public void logException(FacesContext context, Throwable exception, String location, String message, Object... parameters) {
String user = UserFilter.readUserIdFromSession();
LOGGER.info("The view/session has expired for user " + (user == null ? "null" : user));
}
}
我错过了什么吗?