Class DelegatingFilterProxyRegistrationBean
- java.lang.Object
- org.springframework.boot.web.servlet.RegistrationBean
- org.springframework.boot.web.servlet.DynamicRegistrationBean<javax.servlet.FilterRegistration.Dynamic>
- org.springframework.boot.web.servlet.AbstractFilterRegistrationBean<org.springframework.web.filter.DelegatingFilterProxy>
- org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,ServletContextInitializer
,org.springframework.context.ApplicationContextAware
,org.springframework.core.Ordered
public class DelegatingFilterProxyRegistrationBean extends AbstractFilterRegistrationBean<org.springframework.web.filter.DelegatingFilterProxy> implements org.springframework.context.ApplicationContextAware
AServletContextInitializer
to registerDelegatingFilterProxy
s in a Servlet 3.0+ container. Similar to theregistration
features provided byServletContext
but with a Spring Bean friendly design.The bean name of the actual delegate
Filter
should be specified using thetargetBeanName
constructor argument. Unlike theFilterRegistrationBean
, referenced filters are not instantiated early. In fact, if the delegate filter bean is marked@Lazy
it won't be instantiated at all until the filter is called.Registrations can be associated with
URL patterns
and/or servlets (either byname
or via aServletRegistrationBean
s. When no URL pattern or servlets are specified the filter will be associated to '/*'. The targetBeanName will be used as the filter name if not otherwise specified.- Since:
- 1.4.0
- See Also:
ServletContextInitializer
,ServletContext.addFilter(String, Filter)
,FilterRegistrationBean
,DelegatingFilterProxy
Field Summary
Fields inherited from class org.springframework.boot.web.servlet.AbstractFilterRegistrationBean
REQUEST_WRAPPER_FILTER_MAX_ORDER
Constructor Summary
Constructors Constructor Description DelegatingFilterProxyRegistrationBean(String targetBeanName, ServletRegistrationBean<?>... servletRegistrationBeans)
Create a newDelegatingFilterProxyRegistrationBean
instance to be registered with the specifiedServletRegistrationBean
s.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.web.filter.DelegatingFilterProxy
getFilter()
Return theFilter
to be registered.protected String
getTargetBeanName()
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Methods inherited from class org.springframework.boot.web.servlet.AbstractFilterRegistrationBean
addRegistration, addServletNames, addServletRegistrationBeans, addUrlPatterns, configure, getDescription, getServletNames, getServletRegistrationBeans, getUrlPatterns, isMatchAfter, setDispatcherTypes, setDispatcherTypes, setMatchAfter, setServletNames, setServletRegistrationBeans, setUrlPatterns, toString
Methods inherited from class org.springframework.boot.web.servlet.DynamicRegistrationBean
addInitParameter, getInitParameters, getOrDeduceName, isAsyncSupported, register, setAsyncSupported, setInitParameters, setName
Methods inherited from class org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, setOrder
Constructor Detail
DelegatingFilterProxyRegistrationBean
public DelegatingFilterProxyRegistrationBean(String targetBeanName, ServletRegistrationBean<?>... servletRegistrationBeans)
Create a newDelegatingFilterProxyRegistrationBean
instance to be registered with the specifiedServletRegistrationBean
s.- Parameters:
targetBeanName
- name of the target filter bean to look up in the Spring application context (must not benull
).servletRegistrationBeans
- associateServletRegistrationBean
s
Method Detail
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
getTargetBeanName
protected String getTargetBeanName()
getFilter
public org.springframework.web.filter.DelegatingFilterProxy getFilter()
Description copied from class:AbstractFilterRegistrationBean
Return theFilter
to be registered.- Specified by:
getFilter
in classAbstractFilterRegistrationBean<org.springframework.web.filter.DelegatingFilterProxy>
- Returns:
- the filter