public class BypassableDelegatingFilterProxy
extends org.springframework.web.filter.DelegatingFilterProxy
DelegatingFilterProxy which bypasses the filter if there is no
Spring WebApplicationContext available.
The default behaviour of the base class is to throw an IllegalStateException if, by the time the filter
is invoked for the first time, no context is available. This subclass bypasses that behaviour and invokes the
filter chain instead. This is necessary to allow redirects to the configured Johnson error page to make it through
a filter chain which includes delegating filters.
Note: This class preserves the behaviour from the base class where the proxy will fail if it cannot find a bean with the correct name. It only suppresses failing if Spring is completely unavailable.
| Constructor and Description |
|---|
BypassableDelegatingFilterProxy() |
| Modifier and Type | Method and Description |
|---|---|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain filterChain)
Bypasses execution of the filter if no
WebApplicationContext is available, delegating directly to the
filter chain, or performs normal filtering if a context is available. |
protected javax.servlet.Filter |
initDelegate(org.springframework.web.context.WebApplicationContext wac)
As an optimisation to this approach, once the delegate is initialised we set a flag indicating the filter is
no longer bypassable.
|
destroy, destroyDelegate, findWebApplicationContext, getContextAttribute, getTargetBeanName, initFilterBean, invokeDelegate, isTargetFilterLifecycle, setContextAttribute, setTargetBeanName, setTargetFilterLifecyclepublic void doFilter(@Nonnull javax.servlet.ServletRequest request, @Nonnull javax.servlet.ServletResponse response, @Nonnull javax.servlet.FilterChain filterChain) throws javax.servlet.ServletException, IOException
WebApplicationContext is available, delegating directly to the
filter chain, or performs normal filtering if a context is available.
Once a WebApplicationContext is available once, this filter will never bypass again (even if, for some
reason, the context later disappears).
doFilter in interface javax.servlet.FilterdoFilter in class org.springframework.web.filter.DelegatingFilterProxyrequest - the servlet request to filterresponse - the servlet responsefilterChain - the filter chainjavax.servlet.ServletException - May be thrown by the base class or the chain; never thrown locally.IOException - May be thrown by the base class or the chain; never thrown locally.protected javax.servlet.Filter initDelegate(org.springframework.web.context.WebApplicationContext wac)
throws javax.servlet.ServletException
WebApplicationContext unnecessarily
on every request.initDelegate in class org.springframework.web.filter.DelegatingFilterProxywac - the resolved WebApplicationContextjavax.servlet.ServletException - See documentation for the base class.DelegatingFilterProxy.initDelegate(org.springframework.web.context.WebApplicationContext)Copyright © 2017 Atlassian. All rights reserved.