FilterRegistrationBean

A ServletContextInitializer to register Filters in a Servlet 3.0+ container. Similar to the registration features provided by ServletContext but with a Spring Bean friendly design.

The Filter must be specified before calling onStartup. 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 filter name will be deduced if not specified.

Author

Phillip Webb

Since

1.4.0

Parameters

<T>

the type of Filter to register

See also

Constructors

Link copied to clipboard
constructor()
Create a new FilterRegistrationBean instance.
constructor(filter: T, servletRegistrationBeans: Array<ServletRegistrationBean<out Any>>)
Create a new FilterRegistrationBean instance to be registered with the specified ServletRegistrationBeans.

Properties

Link copied to clipboard
private open var beanName: String
Link copied to clipboard
open var filter: T
Link copied to clipboard
val HIGHEST_PRECEDENCE: Int = -2147483648
Link copied to clipboard
Link copied to clipboard
val LOWEST_PRECEDENCE: Int = 2147483647
Link copied to clipboard
open var order: Int

Functions

Link copied to clipboard
open fun addInitParameter(name: String, value: String)
Add a single init-parameter, replacing any existing parameter with the same name.
Link copied to clipboard
open fun addServletNames(servletNames: Array<String>)
Add servlet names for the filter.
Link copied to clipboard
open fun addServletRegistrationBeans(servletRegistrationBeans: Array<ServletRegistrationBean<out Any>>)
Add ServletRegistrationBeans for the filter.
Link copied to clipboard
open fun addUrlPatterns(urlPatterns: Array<String>)
Add URL patterns, as defined in the Servlet specification, that the filter will be registered against.
Link copied to clipboard
open fun determineDispatcherTypes(): EnumSet<DispatcherType>
Determines the dispatcher types for which the filter should be registered.
Link copied to clipboard
open fun getFilterName(): String
Returns the filter name that will be registered.
Link copied to clipboard
Return a mutable collection of servlet names that the filter will be registered against.
Link copied to clipboard
Return a mutable collection of the ServletRegistrationBean that the filter will be registered against.
Link copied to clipboard
Return a mutable collection of URL patterns, as defined in the Servlet specification, that the filter will be registered against.
Link copied to clipboard
Returns if asynchronous operations are supported for this registration.
Link copied to clipboard
open fun isEnabled(): Boolean
Return if the registration is enabled.
Link copied to clipboard
open fun isMatchAfter(): Boolean
Return if filter mappings should be matched after any declared Filter mappings of the ServletContext.
Link copied to clipboard
fun onStartup(servletContext: ServletContext)
Configure the given ServletContext with any servlets, filters, listeners context-params and attributes necessary for initialization.
Link copied to clipboard
open fun setAsyncSupported(asyncSupported: Boolean)
Sets if asynchronous operations are supported for this registration.
Link copied to clipboard
open fun setDispatcherTypes(dispatcherTypes: EnumSet<DispatcherType>)
Sets the dispatcher types that should be used with the registration.
open fun setDispatcherTypes(first: DispatcherType, rest: Array<DispatcherType>)
Convenience method to set dispatcher types using the specified elements.
Link copied to clipboard
open fun setEnabled(enabled: Boolean)
Flag to indicate that the registration is enabled.
Link copied to clipboard
open fun setIgnoreRegistrationFailure(ignoreRegistrationFailure: Boolean)
Sets whether registration failures should be ignored.
Link copied to clipboard
open fun setMatchAfter(matchAfter: Boolean)
Set if the filter mappings should be matched after any declared filter mappings of the ServletContext.
Link copied to clipboard
open fun setName(name: String)
Set the name of this registration.
Link copied to clipboard
open fun setServletNames(servletNames: Collection<String>)
Set servlet names that the filter will be registered against.
Link copied to clipboard
open fun setServletRegistrationBeans(servletRegistrationBeans: Collection<out ServletRegistrationBean<out Any>>)
Set ServletRegistrationBeans that the filter will be registered against.
Link copied to clipboard
open fun setUrlPatterns(urlPatterns: Collection<String>)
Set the URL patterns that the filter will be registered against.
Link copied to clipboard
open fun toString(): String