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 ofFilterto 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 Filters 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.DynamicaddRegistration(String description, jakarta.servlet.ServletContext servletContext) voidaddServletNames(String... servletNames) Add servlet names for the filter.voidaddServletRegistrationBeans(ServletRegistrationBean<?>... servletRegistrationBeans) AddServletRegistrationBeans for the filter.voidaddUrlPatterns(String... urlPatterns) Add URL patterns, as defined in the Servlet specification, that the filter will be registered against.protected voidconfigure(jakarta.servlet.FilterRegistration.Dynamic registration) Configure registration settings.EnumSet<jakarta.servlet.DispatcherType>Determines thedispatcher typesfor which the filter should be registered.protected StringReturn a description of the registration.abstract TReturn theFilterto 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 theServletRegistrationBeanthat 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.booleanReturn if filter mappings should be matched after any declared Filter mappings of the ServletContext.voidsetDispatcherTypes(jakarta.servlet.DispatcherType first, jakarta.servlet.DispatcherType... rest) Convenience method toset dispatcher typesusing the specified elements.voidsetDispatcherTypes(EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes) Sets the dispatcher types that should be used with the registration.voidsetMatchAfter(boolean matchAfter) Set if the filter mappings should be matched after any declared filter mappings of the ServletContext.voidsetServletNames(Collection<String> servletNames) Set servlet names that the filter will be registered against.voidsetServletRegistrationBeans(Collection<? extends ServletRegistrationBean<?>> servletRegistrationBeans) SetServletRegistrationBeans that the filter will be registered against.voidsetUrlPatterns(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, setNameMethods inherited from class org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, setOrder
-
Method Details
-
setServletRegistrationBeans
public void setServletRegistrationBeans(Collection<? extends ServletRegistrationBean<?>> servletRegistrationBeans) SetServletRegistrationBeans that the filter will be registered against.- Parameters:
servletRegistrationBeans- the Servlet registration beans
-
getServletRegistrationBeans
Return a mutable collection of theServletRegistrationBeanthat the filter will be registered against.ServletRegistrationBeans.- Returns:
- the Servlet registration beans
- See Also:
-
addServletRegistrationBeans
AddServletRegistrationBeans 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 typesfor which the filter should be registered. Applies defaults based on the type of filter being registered if none have been configured. Modifications to the returnedEnumSetwill 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 typesusing 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 tofalseindicating 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:RegistrationBeanReturn a description of the registration. For example "Servlet resourceServlet"- Specified by:
getDescriptionin classRegistrationBean- Returns:
- a description of the registration
-
addRegistration
protected jakarta.servlet.FilterRegistration.Dynamic addRegistration(String description, jakarta.servlet.ServletContext servletContext) - Specified by:
addRegistrationin 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:
configurein classDynamicRegistrationBean<jakarta.servlet.FilterRegistration.Dynamic>- Parameters:
registration- the registration
-
getFilter
Return theFilterto be registered.- Returns:
- the filter
-
getFilterName
Returns the filter name that will be registered.- Returns:
- the filter name
- Since:
- 3.2.0
-
toString
-