Class DelegatingFilterProxyRegistrationBean

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<org.springframework.web.filter.DelegatingFilterProxy>
org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, ServletContextInitializer, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered

public class DelegatingFilterProxyRegistrationBean extends AbstractFilterRegistrationBean<org.springframework.web.filter.DelegatingFilterProxy> implements org.springframework.context.ApplicationContextAware
A ServletContextInitializer to register DelegatingFilterProxys in a Servlet 3.0+ container. Similar to the registration features provided by ServletContext but with a Spring Bean friendly design.

The bean name of the actual delegate Filter should be specified using the targetBeanName constructor argument. Unlike the FilterRegistrationBean, 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 by name or through a ServletRegistrationBeans). 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:
  • Constructor Details

  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.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 the Filter to be registered.
      Specified by:
      getFilter in class AbstractFilterRegistrationBean<org.springframework.web.filter.DelegatingFilterProxy>
      Returns:
      the filter