In our Spring application we use the FilterChainProxy in order to use beans as filters in our tomcat web.xml file. This moves the configuration into a different bit of XML, and allows us to configure the URLs that our filters apply to in a more flexable way than that available in the Servlet 2.4 spec.
For example, we can cache some URLs by defining
<bean id="includeFilter" class="org.acegisecurity.util.FilterChainProxy"> <property name="filterInvocationDefinitionSource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON /slowpages/.*=cachingFilter /something/complicated=cachingFilter </value> </property> </bean>
I want to use this for included requests by using the following (and a bit more) in my web.xml.
<filter-mapping> <filter-name>includeFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>INCLUDE</dispatcher> </filter-mapping>
Unfortunately the URLs that are compared in the FilterChainProxy, are those of the original page, not that of the include.
To solve this, I've written IncludedFilterChainProxy.java which extends FilterChainProxy and wraps the setter of the filterInvocationDefinitionSource, so that the source that gets injected has been altered. It will make sure that the FilterInvocation passed to getAttributes will return the included URL, rather than the orginal URL.
I'm not sure that this is the best way, but it seemed the least invasive way of getting the result I want. If anyone knows of a better hook into ACEGI then please let me know.
I also posted to the spring forum about this.