View Javadoc

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