View Javadoc
1   package com.atlassian.plugin.servlet.filter;
2   
3   import com.atlassian.plugin.servlet.descriptors.ServletFilterModuleDescriptor;
4   
5   import javax.servlet.Filter;
6   import javax.servlet.FilterConfig;
7   import javax.servlet.ServletContext;
8   import java.util.Collections;
9   import java.util.Enumeration;
10  
11  /**
12   * Instances of the PluginFilterConfig are passed to plugins {@link Filter} init() method. It provides
13   * access to the init parameters defined in the plugin xml as well as the ServletContext shared by other filters and
14   * servlets in the plugin.
15   *
16   * @since 2.1.0
17   */
18  public class PluginFilterConfig implements FilterConfig {
19      private final ServletFilterModuleDescriptor descriptor;
20      private final ServletContext servletContext;
21  
22      public PluginFilterConfig(ServletFilterModuleDescriptor descriptor, ServletContext servletContext) {
23          this.descriptor = descriptor;
24          this.servletContext = servletContext;
25      }
26  
27      public String getFilterName() {
28          return descriptor.getDisplayName();
29      }
30  
31      public String getInitParameter(String name) {
32          return descriptor.getInitParams().get(name);
33      }
34  
35      public Enumeration<String> getInitParameterNames() {
36          return Collections.enumeration(descriptor.getInitParams().keySet());
37      }
38  
39      public ServletContext getServletContext() {
40          return servletContext;
41      }
42  
43  }