Class CompositeFilter
java.lang.Object
org.springframework.web.filter.CompositeFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
A generic composite servlet
Filter that just delegates its behavior
to a chain (list) of user-supplied filters, achieving the functionality of a
FilterChain, but conveniently using only Filter instances.
This is useful for filters that require dependency injection, and can
therefore be set up in a Spring application context. Typically, this
composite would be used in conjunction with DelegatingFilterProxy,
so that it can be declared in Spring but applied to a servlet context.
- Since:
- 3.1
- Author:
- Dave Syer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.voiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) Forms a temporary chain from the list of delegate filters supplied (setFilters(List)) and executes them in order.voidinit(jakarta.servlet.FilterConfig config) Initialize all the filters, calling each one's init method in turn in the order supplied.voidsetFilters(List<? extends jakarta.servlet.Filter> filters)
-
Constructor Details
-
CompositeFilter
public CompositeFilter()
-
-
Method Details
-
setFilters
-
init
public void init(jakarta.servlet.FilterConfig config) throws jakarta.servlet.ServletException Initialize all the filters, calling each one's init method in turn in the order supplied.- Specified by:
initin interfacejakarta.servlet.Filter- Throws:
jakarta.servlet.ServletException- See Also:
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException Forms a temporary chain from the list of delegate filters supplied (setFilters(List)) and executes them in order. Each filter delegates to the next one in the list, achieving the normal behavior of aFilterChain, despite the fact that this is aFilter.- Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
IOExceptionjakarta.servlet.ServletException- See Also:
-
destroy
public void destroy()Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.- Specified by:
destroyin interfacejakarta.servlet.Filter- See Also:
-