MCPcopy Index your code
hub / github.com/apache/tomcat / GenericFilter

Class GenericFilter

java/jakarta/servlet/GenericFilter.java:32–100  ·  view source on GitHub ↗

Provides a base class that implements the Filter and FilterConfig interfaces to reduce boilerplate when writing new filters. @see jakarta.servlet.Filter @see jakarta.servlet.FilterConfig @since Servlet 4.0

Source from the content-addressed store, hash-verified

30 * @since Servlet 4.0
31 */
32public abstract class GenericFilter implements Filter, FilterConfig, Serializable {
33
34 @Serial
35 private static final long serialVersionUID = 1L;
36
37 /**
38 * The filter configuration.
39 */
40 private volatile FilterConfig filterConfig;
41
42 /**
43 * Constructs a new GenericFilter.
44 */
45 public GenericFilter() {
46 // NO-OP
47 }
48
49
50 @Override
51 public String getInitParameter(String name) {
52 return getFilterConfig().getInitParameter(name);
53 }
54
55
56 @Override
57 public Enumeration<String> getInitParameterNames() {
58 return getFilterConfig().getInitParameterNames();
59 }
60
61
62 /**
63 * Obtain the FilterConfig used to initialise this Filter instance.
64 *
65 * @return The config previously passed to the {@link #init(FilterConfig)} method
66 */
67 public FilterConfig getFilterConfig() {
68 return filterConfig;
69 }
70
71
72 @Override
73 public ServletContext getServletContext() {
74 return getFilterConfig().getServletContext();
75 }
76
77
78 @Override
79 public void init(FilterConfig filterConfig) throws ServletException {
80 this.filterConfig = filterConfig;
81 init();
82 }
83
84
85 /**
86 * Convenience method for subclasses to save them having to call <code>super.init(config)</code>. This is a NO-OP by
87 * default.
88 *
89 * @throws ServletException If an exception occurs that interrupts the Filter's normal operation

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected