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 of Filter 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 Filters in a Servlet 3.0+ container.
Since:
1.5.22
  • Method Details

    • setServletRegistrationBeans

      public void setServletRegistrationBeans(Collection<? extends ServletRegistrationBean<?>> servletRegistrationBeans)
      Set ServletRegistrationBeans that the filter will be registered against.
      Parameters:
      servletRegistrationBeans - the Servlet registration beans
    • getServletRegistrationBeans

      public Collection<ServletRegistrationBean<?>> getServletRegistrationBeans()
      Return a mutable collection of the ServletRegistrationBean that the filter will be registered against. ServletRegistrationBeans.
      Returns:
      the Servlet registration beans
      See Also:
    • addServletRegistrationBeans

      public void addServletRegistrationBeans(ServletRegistrationBean<?>... servletRegistrationBeans)
      Add ServletRegistrationBeans for the filter.
      Parameters:
      servletRegistrationBeans - the servlet registration beans to add
      See Also:
    • 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:
    • 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:
    • 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
    • determineDispatcherTypes

      public EnumSet<jakarta.servlet.DispatcherType> determineDispatcherTypes()
      Determines the dispatcher 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 returned EnumSet 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 to set dispatcher types using the specified elements.
      Parameters:
      first - the first dispatcher type
      rest - additional dispatcher types
    • setDispatcherTypes

      public void setDispatcherTypes(EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes)
      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 to false 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 class RegistrationBean
      Returns:
      a description of the registration
    • addRegistration

      protected jakarta.servlet.FilterRegistration.Dynamic addRegistration(String description, jakarta.servlet.ServletContext servletContext)
      Specified by:
      addRegistration in class DynamicRegistrationBean<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 class DynamicRegistrationBean<jakarta.servlet.FilterRegistration.Dynamic>
      Parameters:
      registration - the registration
    • getFilter

      public abstract T getFilter()
      Return the Filter to be registered.
      Returns:
      the filter
    • getFilterName

      public String getFilterName()
      Returns the filter name that will be registered.
      Returns:
      the filter name
      Since:
      3.2.0
    • toString

      public String toString()
      Overrides:
      toString in class Object