Class AbstractFilterRegistrationBean<T extends javax.servlet.Filter>
- 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<T>
- Type Parameters:
T
- the type ofFilter
to register
- All Implemented Interfaces:
ServletContextInitializer
,org.springframework.core.Ordered
- Direct Known Subclasses:
DelegatingFilterProxyRegistrationBean
,FilterRegistrationBean
public abstract class AbstractFilterRegistrationBean<T extends javax.servlet.Filter> extends DynamicRegistrationBean<javax.servlet.FilterRegistration.Dynamic>
Abstract baseServletContextInitializer
to registerFilter
s in a Servlet 3.0+ container.- Since:
- 2.0.1
Field Summary
Fields Modifier and Type Field Description protected static int
REQUEST_WRAPPER_FILTER_MAX_ORDER
Deprecated.since 2.1.0 in favor ofOrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected javax.servlet.FilterRegistration.Dynamic
addRegistration(String description, javax.servlet.ServletContext servletContext)
void
addServletNames(String... servletNames)
Add servlet names for the filter.void
addServletRegistrationBeans(ServletRegistrationBean<?>... servletRegistrationBeans)
AddServletRegistrationBean
s for the filter.void
addUrlPatterns(String... urlPatterns)
Add URL patterns, as defined in the Servlet specification, that the filter will be registered against.protected void
configure(javax.servlet.FilterRegistration.Dynamic registration)
Configure registration settings.protected String
getDescription()
Return a description of the registration.abstract T
getFilter()
Return theFilter
to be registered.Collection<String>
getServletNames()
Return a mutable collection of servlet names that the filter will be registered against.Collection<ServletRegistrationBean<?>>
getServletRegistrationBeans()
Return a mutable collection of theServletRegistrationBean
that the filter will be registered against.Collection<String>
getUrlPatterns()
Return a mutable collection of URL patterns, as defined in the Servlet specification, that the filter will be registered against.boolean
isMatchAfter()
Return if filter mappings should be matched after any declared Filter mappings of the ServletContext.void
setDispatcherTypes(EnumSet<javax.servlet.DispatcherType> dispatcherTypes)
Sets the dispatcher types that should be used with the registration.void
setDispatcherTypes(javax.servlet.DispatcherType first, javax.servlet.DispatcherType... rest)
Convenience method toset dispatcher types
using the specified elements.void
setMatchAfter(boolean matchAfter)
Set if the filter mappings should be matched after any declared filter mappings of the ServletContext.void
setServletNames(Collection<String> servletNames)
Set servlet names that the filter will be registered against.void
setServletRegistrationBeans(Collection<? extends ServletRegistrationBean<?>> servletRegistrationBeans)
SetServletRegistrationBean
s that the filter will be registered against.void
setUrlPatterns(Collection<String> urlPatterns)
Set the URL patterns that the filter will be registered against.String
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
Field Detail
REQUEST_WRAPPER_FILTER_MAX_ORDER
@Deprecated protected static final int REQUEST_WRAPPER_FILTER_MAX_ORDER
Deprecated.since 2.1.0 in favor ofOrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER
Filters that wrap the servlet request should be ordered less than or equal to this.- See Also:
- Constant Field Values
Method Detail
setServletRegistrationBeans
public void setServletRegistrationBeans(Collection<? extends ServletRegistrationBean<?>> servletRegistrationBeans)
SetServletRegistrationBean
s that the filter will be registered against.- Parameters:
servletRegistrationBeans
- the Servlet registration beans
getServletRegistrationBeans
public Collection<ServletRegistrationBean<?>> getServletRegistrationBeans()
Return a mutable collection of theServletRegistrationBean
that the filter will be registered against.ServletRegistrationBean
s.- Returns:
- the Servlet registration beans
- See Also:
setServletNames(java.util.Collection<java.lang.String>)
,setUrlPatterns(java.util.Collection<java.lang.String>)
addServletRegistrationBeans
public void addServletRegistrationBeans(ServletRegistrationBean<?>... servletRegistrationBeans)
AddServletRegistrationBean
s for the filter.- Parameters:
servletRegistrationBeans
- the servlet registration beans to add- See Also:
setServletRegistrationBeans(java.util.Collection<? extends org.springframework.boot.web.servlet.ServletRegistrationBean<?>>)
setServletNames
public void setServletNames(Collection<String> servletNames)
Set servlet names that the filter will be registered against. This will replace any previously specified servlet names.- Parameters:
servletNames
- the servlet names- See Also:
setServletRegistrationBeans(java.util.Collection<? extends org.springframework.boot.web.servlet.ServletRegistrationBean<?>>)
,setUrlPatterns(java.util.Collection<java.lang.String>)
getServletNames
public Collection<String> getServletNames()
Return a mutable collection of servlet names that the filter will be registered against.- Returns:
- the servlet names
addServletNames
public void addServletNames(String... servletNames)
Add servlet names for the filter.- Parameters:
servletNames
- the servlet names to add
setUrlPatterns
public void setUrlPatterns(Collection<String> urlPatterns)
Set the URL patterns that the filter will be registered against. This will replace any previously specified URL patterns.- Parameters:
urlPatterns
- the URL patterns- See Also:
setServletRegistrationBeans(java.util.Collection<? extends org.springframework.boot.web.servlet.ServletRegistrationBean<?>>)
,setServletNames(java.util.Collection<java.lang.String>)
getUrlPatterns
public Collection<String> getUrlPatterns()
Return a mutable collection of URL patterns, as defined in the Servlet specification, that the filter will be registered against.- Returns:
- the URL patterns
addUrlPatterns
public void addUrlPatterns(String... urlPatterns)
Add URL patterns, as defined in the Servlet specification, that the filter will be registered against.- Parameters:
urlPatterns
- the URL patterns
setDispatcherTypes
public void setDispatcherTypes(javax.servlet.DispatcherType first, javax.servlet.DispatcherType... rest)
Convenience method toset dispatcher types
using the specified elements.- Parameters:
first
- the first dispatcher typerest
- additional dispatcher types
setDispatcherTypes
public void setDispatcherTypes(EnumSet<javax.servlet.DispatcherType> dispatcherTypes)
Sets the dispatcher types that should be used with the registration. If not specified the types will be deduced based on the value ofDynamicRegistrationBean.isAsyncSupported()
.- Parameters:
dispatcherTypes
- the dispatcher types
setMatchAfter
public void setMatchAfter(boolean matchAfter)
Set if the filter mappings should be matched after any declared filter mappings of the ServletContext. Defaults tofalse
indicating the filters are supposed to be matched before any declared filter mappings of the ServletContext.- Parameters:
matchAfter
- if filter mappings are matched after
isMatchAfter
public boolean isMatchAfter()
Return if filter mappings should be matched after any declared Filter mappings of the ServletContext.- Returns:
- if filter mappings are matched after
getDescription
protected String getDescription()
Description copied from class:RegistrationBean
Return a description of the registration. For example "Servlet resourceServlet"- Specified by:
getDescription
in classRegistrationBean
- Returns:
- a description of the registration
addRegistration
protected javax.servlet.FilterRegistration.Dynamic addRegistration(String description, javax.servlet.ServletContext servletContext)
- Specified by:
addRegistration
in classDynamicRegistrationBean<javax.servlet.FilterRegistration.Dynamic>
configure
protected void configure(javax.servlet.FilterRegistration.Dynamic registration)
Configure registration settings. Subclasses can override this method to perform additional configuration if required.- Overrides:
configure
in classDynamicRegistrationBean<javax.servlet.FilterRegistration.Dynamic>
- Parameters:
registration
- the registration