Added toString method to FilterChainProxy.

This commit is contained in:
Luke Taylor 2008-01-18 22:16:41 +00:00
parent 462b4b450f
commit 84815df529

View File

@ -23,6 +23,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.security.intercept.web.*; import org.springframework.security.intercept.web.*;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.filter.DelegatingFilterProxy;
import javax.servlet.*; import javax.servlet.*;
import java.io.IOException; import java.io.IOException;
@ -35,11 +36,10 @@ import java.util.*;
* context unless you need very fine control over the filter chain contents. Most cases should be adequately covered * context unless you need very fine control over the filter chain contents. Most cases should be adequately covered
* by the default <tt>&lt;security:http /&gt</tt> namespace configuration options. * by the default <tt>&lt;security:http /&gt</tt> namespace configuration options.
* *
* <p>The <code>FilterChainProxy</code> is loaded via a standard * <p>The <code>FilterChainProxy</code> is loaded via a standard Spring {@link DelegatingFilterProxy} declaration in
* {@link org.springframework.security.util.FilterToBeanProxy} declaration in <code>web.xml</code>. * <code>web.xml</code>. <code>FilterChainProxy</code> will then pass {@link #init(FilterConfig)}, {@link #destroy()}
* <code>FilterChainProxy</code> will then pass {@link #init(FilterConfig)}, {@link #destroy()} and {@link * and {@link #doFilter(ServletRequest, ServletResponse, FilterChain)} invocations through to each <code>Filter</code>
* #doFilter(ServletRequest, ServletResponse, FilterChain)} invocations through to each <code>Filter</code> defined * defined against <code>FilterChainProxy</code>.
* against <code>FilterChainProxy</code>.</p>
* *
* <p>As of version 2.0, <tt>FilterChainProxy</tt> is configured using an ordered Map of path patterns to <tt>List</tt>s * <p>As of version 2.0, <tt>FilterChainProxy</tt> is configured using an ordered Map of path patterns to <tt>List</tt>s
* of <tt>Filter</tt> objects. In previous * of <tt>Filter</tt> objects. In previous
@ -64,26 +64,27 @@ import java.util.*;
* application context. The order of the names defines the order in which the filters will be applied. As shown above, * application context. The order of the names defines the order in which the filters will be applied. As shown above,
* use of the value "none" for the "filters" can be used to exclude * use of the value "none" for the "filters" can be used to exclude
* Please consult the security namespace schema file for a full list of available configuration options. * Please consult the security namespace schema file for a full list of available configuration options.
* </p>
* *
*<p> * <p>
* Each possible URI pattern that <code>FilterChainProxy</code> should service must be entered. * Each possible URI pattern that <code>FilterChainProxy</code> should service must be entered.
* The first matching URI pattern for a given request will be used to define all of the * The first matching URI pattern for a given request will be used to define all of the
* <code>Filter</code>s that apply to that request. NB: This means you must put most specific URI patterns at the top * <code>Filter</code>s that apply to that request. NB: This means you must put most specific URI patterns at the top
* of the list, and ensure all <code>Filter</code>s that should apply for a given URI pattern are entered against the * of the list, and ensure all <code>Filter</code>s that should apply for a given URI pattern are entered against the
* respective entry. The <code>FilterChainProxy</code> will not iterate the remainder of the URI patterns to locate * respective entry. The <code>FilterChainProxy</code> will not iterate the remainder of the URI patterns to locate
* additional <code>Filter</code>s.</p> * additional <code>Filter</code>s.
* <p><code>FilterChainProxy</code> respects normal handling of <code>Filter</code>s that elect not to call {@link *
* <p><code>FilterChainProxy</code> respects normal handling of <code>Filter</code>s that elect not to call {@link
* javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, * javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
* javax.servlet.FilterChain)}, in that the remainder of the original or <code>FilterChainProxy</code>-declared filter * javax.servlet.FilterChain)}, in that the remainder of the original or <code>FilterChainProxy</code>-declared filter
* chain will not be called.</p> * chain will not be called.
* <p>It is particularly noted the <code>Filter</code> lifecycle mismatch between the servlet container and IoC *
* container. As per {@link org.springframework.security.util.FilterToBeanProxy} JavaDocs, we recommend you allow the IoC * <p>It is particularly noted the <code>Filter</code> lifecycle mismatch between the servlet container and IoC
* container to manage lifecycle instead of the servlet container. By default the <code>FilterToBeanProxy</code> will * container. As per {@link DelegatingFilterProxy} JavaDocs, we recommend you allow the IoC
* never call this class' {@link #init(FilterConfig)} and {@link #destroy()} methods, meaning each of the filters * container to manage lifecycle instead of the servlet container. By default the <code>DelegatingFilterProxy</code>
* will never call this class' {@link #init(FilterConfig)} and {@link #destroy()} methods, meaning each of the filters
* defined in the filter chain map will not be called. If you do need your filters to be * defined in the filter chain map will not be called. If you do need your filters to be
* initialized and destroyed, please set the <code>lifecycle</code> initialization parameter against the * initialized and destroyed, please set the <code>lifecycle</code> initialization parameter against the
* <code>FilterToBeanProxy</code> to specify servlet container lifecycle management.</p> * <code>DelegatingFilterProxy</code> to specify servlet container lifecycle management.
* *
* @author Carlos Sanchez * @author Carlos Sanchez
* @author Ben Alex * @author Ben Alex
@ -317,6 +318,17 @@ public class FilterChainProxy implements Filter, InitializingBean, ApplicationCo
return matcher; return matcher;
} }
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("FilterChainProxy[");
sb.append(" UrlMatcher = ").append(matcher);
sb.append("; Filter Chains: ");
sb.append(uncompiledFilterChainMap);
sb.append("]");
return sb.toString();
}
//~ Inner Classes ================================================================================================== //~ Inner Classes ==================================================================================================
/** /**