public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
      throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    try {
      if (excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) {
        request.setAttribute(REQUEST_EXCLUDED_FROM_ACTION_MAPPING, new Object());
      } else {
        prepare.setEncodingAndLocale(request, response);
        prepare.createActionContext(request, response);
        prepare.assignDispatcherToThread();
        request = prepare.wrapRequest(request);
        prepare.findActionMapping(request, response);
      }
      chain.doFilter(request, response);
    } finally {
      prepare.cleanupRequest(request);
    }
  }
 public void destroy() {
   prepare.cleanupDispatcher();
 }