@Test public void testDoFilter() throws Exception { MockFilterConfig config = new MockFilterConfig(); config.setFilterName("abc"); config.setInitParameter(WebConfiguration.EXTRA_MODULES_PARAMETER, CayenneFilter_DispatchModule.class.getName()); MockServletContext context = new MockServletContext(); config.setupServletContext(context); CayenneFilter filter = new CayenneFilter(); filter.init(config); CayenneRuntime runtime = WebUtil.getCayenneRuntime(context); CayenneFilter_DispatchRequestHandler handler = (CayenneFilter_DispatchRequestHandler) runtime.getInjector() .getInstance(RequestHandler.class); assertEquals(0, handler.getStarted()); assertEquals(0, handler.getEnded()); filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain()); assertEquals(1, handler.getStarted()); assertEquals(1, handler.getEnded()); filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain()); assertEquals(2, handler.getStarted()); assertEquals(2, handler.getEnded()); }
@Override public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext); RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class); handler.requestStart(request, response); try { chain.doFilter(request, response); } finally { handler.requestEnd(request, response); } }
CayenneFilter implements Filter { @Override public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext); RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class); handler.requestStart(request, response); try { chain.doFilter(request, response); } finally { handler.requestEnd(request, response); } } }
CayenneFilter implements Filter { @Override public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext); RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class); handler.requestStart(request, response); try { chain.doFilter(request, response); } finally { handler.requestEnd(request, response); } }  }
CayenneFilter implements Filter { @Override public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext); RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class); handler.requestStart(request, response); try { chain.doFilter(request, response); } finally { handler.requestEnd(request, response); } }  @Override void init(FilterConfig config); @Override void destroy(); @Override void doFilter(
            ServletRequest request,
            ServletResponse response,
            FilterChain chain); }
CayenneFilter implements Filter { @Override public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext); RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class); handler.requestStart(request, response); try { chain.doFilter(request, response); } finally { handler.requestEnd(request, response); } }  @Override void init(FilterConfig config); @Override void destroy(); @Override void doFilter(
            ServletRequest request,
            ServletResponse response,
            FilterChain chain);  }