Class AbstractFilterRegistrationBean<T extends jakarta.servlet.Filter>
java.lang.Object
org.springframework.boot.web.servlet.RegistrationBean
org.springframework.boot.web.servlet.DynamicRegistrationBean<jakarta.servlet.FilterRegistration.Dynamic>
org.springframework.boot.web.servlet.AbstractFilterRegistrationBean<T>
- Type Parameters:
T
- the type ofFilter
to register
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,ServletContextInitializer
,org.springframework.core.Ordered
- Direct Known Subclasses:
DelegatingFilterProxyRegistrationBean
,FilterRegistrationBean
public abstract class AbstractFilterRegistrationBean<T extends jakarta.servlet.Filter>
extends DynamicRegistrationBean<jakarta.servlet.FilterRegistration.Dynamic>
Abstract base
ServletContextInitializer
to register Filter
s in a
Servlet 3.0+ container.- Since:
- 1.5.22
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.servlet.FilterRegistration.Dynamic
addRegistration
(String description, jakarta.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
(jakarta.servlet.FilterRegistration.Dynamic registration) Configure registration settings.EnumSet<jakarta.servlet.DispatcherType>
Determines thedispatcher types
for which the filter should be registered.protected String
Return a description of the registration.abstract T
Return theFilter
to be registered.Returns the filter name that will be registered.Return a mutable collection of servlet names that the filter will be registered against.Return a mutable collection of theServletRegistrationBean
that the filter will be registered against.Return a mutable collection of URL patterns, as defined in the Servlet specification, that the filter will be registered against.boolean
Return if filter mappings should be matched after any declared Filter mappings of the ServletContext.void
setDispatcherTypes
(jakarta.servlet.DispatcherType first, jakarta.servlet.DispatcherType... rest) Convenience method toset dispatcher types
using the specified elements.void
setDispatcherTypes
(EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes) Sets the dispatcher types that should be used with the registration.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.toString()
Methods inherited from class org.springframework.boot.web.servlet.DynamicRegistrationBean
addInitParameter, getInitParameters, getOrDeduceName, isAsyncSupported, register, setAsyncSupported, setBeanName, setIgnoreRegistrationFailure, setInitParameters, setName
Methods inherited from class org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, setOrder
-
Method Details
-
setServletRegistrationBeans
public void setServletRegistrationBeans(Collection<? extends ServletRegistrationBean<?>> servletRegistrationBeans) SetServletRegistrationBean
s that the filter will be registered against.- Parameters:
servletRegistrationBeans
- the Servlet registration beans
-
getServletRegistrationBeans
Return a mutable collection of theServletRegistrationBean
that the filter will be registered against.ServletRegistrationBean
s.- Returns:
- the Servlet registration beans
- See Also:
-
addServletRegistrationBeans
AddServletRegistrationBean
s for the filter.- Parameters:
servletRegistrationBeans
- the servlet registration beans to add- See Also:
-
setServletNames
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:
-
getServletNames
Return a mutable collection of servlet names that the filter will be registered against.- Returns:
- the servlet names
-
addServletNames
Add servlet names for the filter.- Parameters:
servletNames
- the servlet names to add
-
setUrlPatterns
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:
-
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
Add URL patterns, as defined in the Servlet specification, that the filter will be registered against.- Parameters:
urlPatterns
- the URL patterns
-
determineDispatcherTypes
Determines thedispatcher types
for which the filter should be registered. Applies defaults based on the type of filter being registered if none have been configured. Modifications to the returnedEnumSet
will have no effect on the registration.- Returns:
- the dispatcher types, never
null
- Since:
- 3.2.0
-
setDispatcherTypes
public void setDispatcherTypes(jakarta.servlet.DispatcherType first, jakarta.servlet.DispatcherType... rest) Convenience method toset dispatcher types
using the specified elements.- Parameters:
first
- the first dispatcher typerest
- additional dispatcher types
-
setDispatcherTypes
Sets the dispatcher types that should be used with the registration.- 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
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 jakarta.servlet.FilterRegistration.Dynamic addRegistration(String description, jakarta.servlet.ServletContext servletContext) - Specified by:
addRegistration
in classDynamicRegistrationBean<jakarta.servlet.FilterRegistration.Dynamic>
-
configure
protected void configure(jakarta.servlet.FilterRegistration.Dynamic registration) Configure registration settings. Subclasses can override this method to perform additional configuration if required.- Overrides:
configure
in classDynamicRegistrationBean<jakarta.servlet.FilterRegistration.Dynamic>
- Parameters:
registration
- the registration
-
getFilter
Return theFilter
to be registered.- Returns:
- the filter
-
getFilterName
Returns the filter name that will be registered.- Returns:
- the filter name
- Since:
- 3.2.0
-
toString
-