/** * Builds {@link ActionRequest} and invokes it. If action result is a chain, it repeats the process. */ @Override public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String actionPath = DispatcherUtil.getServletPath(request); try { MadvocResponseWrapper madvocResponse = new MadvocResponseWrapper(response); actionPath = madvocController.invoke(actionPath, request, madvocResponse); } catch (Exception ex) { log.error("Invoking action path failed: " + actionPath, ex); throw new ServletException(ex); } if (actionPath != null) { // action path is not consumed boolean pathProcessed = processUnhandledPath(actionPath, req, res); if (!pathProcessed) { chain.doFilter(request, response); } } }
/** * Filter initialization. */ public void init(FilterConfig filterConfig) throws ServletException { ServletContext servletContext = filterConfig.getServletContext(); madvoc = Madvoc.get(servletContext); if (madvoc == null) { madvoc = createMadvoc(filterConfig); try { madvoc.startNewWebApplication(servletContext); } catch (Exception ex) { throw new ServletException("Unable to start Madvoc web application.", ex); } } log = Log.getLogger(MadvocServletFilter.class); madvocController = madvoc.getMadvocController(); }
/** * Builds {@link ActionRequest} and invokes it. If action result is a chain, it repeats the process. */ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String actionPath = DispatcherUtil.getServletPath(request); try { actionPath = madvocController.invoke(actionPath, request, response); } catch (Exception ex) { log.error("Exception while invoking action path: " + actionPath, ex); ex.printStackTrace(); throw new ServletException(ex); } if (actionPath != null) { // action path is not consumed actionPath = processUnhandledPath(actionPath, req, res); if (actionPath != null) { chain.doFilter(request, response); } } }