import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletResponse; import javax.faces.context.FacesContext; import javax.faces.application.Application; import javax.faces.application.ApplicationWrapper; public class FakeFacesFilter implements Filter { private FilterConfig filterConfig = null; public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; } public void destroy() { this.filterConfig = null; } public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletResponse httpResp = (HttpServletResponse) resp; System.out.println("FakeFacesFilter " + new FakeFacesContext()); chain.doFilter(req, resp); } } class FakeFacesContext extends FacesContext { public FakeFacesContext() { setCurrentInstance(this); } public javax.faces.application.Application getApplication() { return new FakeFacesApplication(); } public java.util.Iterator getClientIdsWithMessages(){ return null; } public javax.faces.context.ExternalContext getExternalContext(){ return null; } public javax.faces.application.FacesMessage.Severity getMaximumSeverity(){ return null; } public java.util.Iterator getMessages(){ return null; } public java.util.Iterator getMessages(java.lang.String category){ return null; } public javax.faces.render.RenderKit getRenderKit() { return null; } public boolean getRenderResponse(){ return false; } public boolean getResponseComplete(){ return false; } public javax.faces.context.ResponseStream getResponseStream(){ return null; } public void setResponseStream(javax.faces.context.ResponseStream stream){ return; } public javax.faces.context.ResponseWriter getResponseWriter(){ return null; } public void setResponseWriter(javax.faces.context.ResponseWriter writer){ return; } public javax.faces.component.UIViewRoot getViewRoot(){ return null; } public void setViewRoot(javax.faces.component.UIViewRoot viewRoot){ return; } public void addMessage(java.lang.String name, javax.faces.application.FacesMessage message){ return; } public void release(){ return; } public void renderResponse(){ return; } public void responseComplete(){ return; } } class FakeFacesApplication extends ApplicationWrapper { public FakeFacesApplication() { } public javax.el.ELContextListener[] getELContextListeners() { return null; } public java.util.ResourceBundle getResourceBundle(FacesContext ctx, java.lang.String name) { return null; } public Application getWrapped() { return null; } }