@Test(expected = ServletException.class) public void shoudlComplainIfNotInAServletEnviroment() throws IOException, ServletException { ServletRequest request = mock(ServletRequest.class); ServletResponse response = mock(ServletResponse.class); new VRaptor().doFilter(request, response, null); }
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest) || !(res instanceof HttpServletResponse)) { throw new ServletException( "VRaptor must be run inside a Servlet environment. Portlets and others aren't supported."); } final HttpServletRequest baseRequest = (HttpServletRequest) req; final HttpServletResponse baseResponse = (HttpServletResponse) res; if (staticHandler.requestingStaticFile(baseRequest)) { staticHandler.deferProcessingToContainer(chain, baseRequest, baseResponse); } else { logger.debug("VRaptor received a new request"); logger.trace("Request: {}", req); VRaptorRequest mutableRequest = new VRaptorRequest(baseRequest); VRaptorResponse mutableResponse = new VRaptorResponse(baseResponse); final RequestInfo request = new RequestInfo(servletContext, chain, mutableRequest, mutableResponse); Execution<Object> execution = new Execution<Object>() { public Object insideRequest(Container container) { container.instanceFor(EncodingHandler.class).setEncoding(baseRequest, baseResponse); container.instanceFor(RequestExecution.class).execute(); return null; } }; try { provider.provideForRequest(request, execution); } catch (ApplicationLogicException e) { throw new ServletException(e.getMessage(), e.getCause()); } logger.debug("VRaptor ended the request"); } }
VRaptor implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest) || !(res instanceof HttpServletResponse)) { throw new ServletException( "VRaptor must be run inside a Servlet environment. Portlets and others aren't supported."); } final HttpServletRequest baseRequest = (HttpServletRequest) req; final HttpServletResponse baseResponse = (HttpServletResponse) res; if (staticHandler.requestingStaticFile(baseRequest)) { staticHandler.deferProcessingToContainer(chain, baseRequest, baseResponse); } else { logger.debug("VRaptor received a new request"); logger.trace("Request: {}", req); VRaptorRequest mutableRequest = new VRaptorRequest(baseRequest); VRaptorResponse mutableResponse = new VRaptorResponse(baseResponse); final RequestInfo request = new RequestInfo(servletContext, chain, mutableRequest, mutableResponse); Execution<Object> execution = new Execution<Object>() { public Object insideRequest(Container container) { container.instanceFor(EncodingHandler.class).setEncoding(baseRequest, baseResponse); container.instanceFor(RequestExecution.class).execute(); return null; } }; try { provider.provideForRequest(request, execution); } catch (ApplicationLogicException e) { throw new ServletException(e.getMessage(), e.getCause()); } logger.debug("VRaptor ended the request"); } } }
VRaptor implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest) || !(res instanceof HttpServletResponse)) { throw new ServletException( "VRaptor must be run inside a Servlet environment. Portlets and others aren't supported."); } final HttpServletRequest baseRequest = (HttpServletRequest) req; final HttpServletResponse baseResponse = (HttpServletResponse) res; if (staticHandler.requestingStaticFile(baseRequest)) { staticHandler.deferProcessingToContainer(chain, baseRequest, baseResponse); } else { logger.debug("VRaptor received a new request"); logger.trace("Request: {}", req); VRaptorRequest mutableRequest = new VRaptorRequest(baseRequest); VRaptorResponse mutableResponse = new VRaptorResponse(baseResponse); final RequestInfo request = new RequestInfo(servletContext, chain, mutableRequest, mutableResponse); Execution<Object> execution = new Execution<Object>() { public Object insideRequest(Container container) { container.instanceFor(EncodingHandler.class).setEncoding(baseRequest, baseResponse); container.instanceFor(RequestExecution.class).execute(); return null; } }; try { provider.provideForRequest(request, execution); } catch (ApplicationLogicException e) { throw new ServletException(e.getMessage(), e.getCause()); } logger.debug("VRaptor ended the request"); } }  }
VRaptor implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest) || !(res instanceof HttpServletResponse)) { throw new ServletException( "VRaptor must be run inside a Servlet environment. Portlets and others aren't supported."); } final HttpServletRequest baseRequest = (HttpServletRequest) req; final HttpServletResponse baseResponse = (HttpServletResponse) res; if (staticHandler.requestingStaticFile(baseRequest)) { staticHandler.deferProcessingToContainer(chain, baseRequest, baseResponse); } else { logger.debug("VRaptor received a new request"); logger.trace("Request: {}", req); VRaptorRequest mutableRequest = new VRaptorRequest(baseRequest); VRaptorResponse mutableResponse = new VRaptorResponse(baseResponse); final RequestInfo request = new RequestInfo(servletContext, chain, mutableRequest, mutableResponse); Execution<Object> execution = new Execution<Object>() { public Object insideRequest(Container container) { container.instanceFor(EncodingHandler.class).setEncoding(baseRequest, baseResponse); container.instanceFor(RequestExecution.class).execute(); return null; } }; try { provider.provideForRequest(request, execution); } catch (ApplicationLogicException e) { throw new ServletException(e.getMessage(), e.getCause()); } logger.debug("VRaptor ended the request"); } }  void destroy(); void doFilter(ServletRequest req, ServletResponse res, FilterChain chain); void init(FilterConfig cfg); }
VRaptor implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest) || !(res instanceof HttpServletResponse)) { throw new ServletException( "VRaptor must be run inside a Servlet environment. Portlets and others aren't supported."); } final HttpServletRequest baseRequest = (HttpServletRequest) req; final HttpServletResponse baseResponse = (HttpServletResponse) res; if (staticHandler.requestingStaticFile(baseRequest)) { staticHandler.deferProcessingToContainer(chain, baseRequest, baseResponse); } else { logger.debug("VRaptor received a new request"); logger.trace("Request: {}", req); VRaptorRequest mutableRequest = new VRaptorRequest(baseRequest); VRaptorResponse mutableResponse = new VRaptorResponse(baseResponse); final RequestInfo request = new RequestInfo(servletContext, chain, mutableRequest, mutableResponse); Execution<Object> execution = new Execution<Object>() { public Object insideRequest(Container container) { container.instanceFor(EncodingHandler.class).setEncoding(baseRequest, baseResponse); container.instanceFor(RequestExecution.class).execute(); return null; } }; try { provider.provideForRequest(request, execution); } catch (ApplicationLogicException e) { throw new ServletException(e.getMessage(), e.getCause()); } logger.debug("VRaptor ended the request"); } }  void destroy(); void doFilter(ServletRequest req, ServletResponse res, FilterChain chain); void init(FilterConfig cfg);  }