/** * Return name of the request attribute that identifies that a request has already been filtered. * <p/> * The default implementation takes the configured {@link #getName() name} and appends "{@code .FILTERED}". * If the filter is not fully initialized, it falls back to the implementation's class name. * * @return the name of the request attribute that identifies that a request has already been filtered. * @see #getName * @see #ALREADY_FILTERED_SUFFIX */ protected String getAlreadyFilteredAttributeName() { String name = getName(); if (name == null) { name = getClass().getName(); } return name + ALREADY_FILTERED_SUFFIX; }
String alreadyFilteredAttributeName = getAlreadyFilteredAttributeName(); if ( request.getAttribute(alreadyFilteredAttributeName) != null ) { log.trace("Filter '{}' already executed. Proceeding without invoking this filter.", getName()); filterChain.doFilter(request, response); } else //noinspection deprecation getName()); filterChain.doFilter(request, response); } else { log.trace("Filter '{}' not yet executed. Executing now.", getName()); request.setAttribute(alreadyFilteredAttributeName, Boolean.TRUE);