1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.util.servlet.filters;
16  
17  import java.util.Collections;
18  import java.util.Enumeration;
19  import java.util.LinkedHashMap;
20  import java.util.Map;
21  
22  import javax.servlet.FilterConfig;
23  import javax.servlet.ServletContext;
24  
25  /**
26   * <a href="DynamicFilterConfig.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   * @author Bruno Farache
30   */
31  public class DynamicFilterConfig implements FilterConfig {
32  
33      public DynamicFilterConfig(FilterConfig filterConfig) {
34          Enumeration<String> enu = filterConfig.getInitParameterNames();
35  
36          while (enu.hasMoreElements()) {
37              String name = enu.nextElement();
38  
39              addInitParameter(name, filterConfig.getInitParameter(name));
40          }
41      }
42  
43      public DynamicFilterConfig(
44          String filterName, ServletContext servletContext) {
45  
46          _filterName = filterName;
47          _servletContext = servletContext;
48      }
49  
50      public String getFilterName() {
51          return _filterName;
52      }
53  
54      public ServletContext getServletContext() {
55          return _servletContext;
56      }
57  
58      public void addInitParameter(String name, String value) {
59          _parameters.put(name, value);
60      }
61  
62      public String getInitParameter(String name) {
63          return _parameters.get(name);
64      }
65  
66      public Enumeration<String> getInitParameterNames() {
67          return Collections.enumeration(_parameters.keySet());
68      }
69  
70      private String _filterName;
71      private ServletContext _servletContext;
72      private Map<String, String> _parameters =
73          new LinkedHashMap<String, String>();
74  
75  }