public class DelegatingFilterProxyRegistrationBean extends AbstractFilterRegistrationBean implements ApplicationContextAware
ServletContextInitializer
to register DelegatingFilterProxy
s 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 via a
ServletRegistrationBean
s. 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.
ServletContextInitializer
,
ServletContext.addFilter(String, Filter)
,
FilterRegistrationBean
,
DelegatingFilterProxy
REQUEST_WRAPPER_FILTER_MAX_ORDER
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
DelegatingFilterProxyRegistrationBean(String targetBeanName,
ServletRegistrationBean... servletRegistrationBeans)
Create a new
DelegatingFilterProxyRegistrationBean instance to be
registered with the specified ServletRegistrationBean s. |
Modifier and Type | Method and Description |
---|---|
Filter |
getFilter()
Return the
Filter to be registered. |
protected String |
getTargetBeanName() |
void |
setApplicationContext(ApplicationContext applicationContext) |
addServletNames, addServletRegistrationBeans, addUrlPatterns, configure, getServletNames, getServletRegistrationBeans, getUrlPatterns, isMatchAfter, onStartup, setDispatcherTypes, setDispatcherTypes, setMatchAfter, setServletNames, setServletRegistrationBeans, setUrlPatterns
addInitParameter, configure, getInitParameters, getOrDeduceName, getOrder, isAsyncSupported, isEnabled, setAsyncSupported, setEnabled, setInitParameters, setName, setOrder
public DelegatingFilterProxyRegistrationBean(String targetBeanName, ServletRegistrationBean... servletRegistrationBeans)
DelegatingFilterProxyRegistrationBean
instance to be
registered with the specified ServletRegistrationBean
s.targetBeanName
- name of the target filter bean to look up in the Spring
application context (must not be null
).servletRegistrationBeans
- associate ServletRegistrationBean
spublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
protected String getTargetBeanName()
public Filter getFilter()
AbstractFilterRegistrationBean
Filter
to be registered.getFilter
in class AbstractFilterRegistrationBean
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.