1 20 package org.apache.cactus.server; 21 22 import java.util.Enumeration ; 23 import java.util.Hashtable ; 24 import java.util.Vector ; 25 26 import javax.servlet.FilterConfig ; 27 import javax.servlet.ServletContext ; 28 29 37 public class FilterConfigWrapper implements FilterConfig 38 { 39 42 private FilterConfig originalConfig; 43 44 47 private Hashtable initParameters; 48 49 52 private String filterName; 53 54 57 public FilterConfigWrapper(FilterConfig theOriginalConfig) 58 { 59 this.originalConfig = theOriginalConfig; 60 this.initParameters = new Hashtable (); 61 } 62 63 69 public void setInitParameter(String theName, String theValue) 70 { 71 this.initParameters.put(theName, theValue); 72 } 73 74 80 public void setFilterName(String theFilterName) 81 { 82 this.filterName = theFilterName; 83 } 84 85 87 91 public String getFilterName() 92 { 93 if (this.filterName != null) 94 { 95 return this.filterName; 96 } 97 98 return this.originalConfig.getFilterName(); 99 } 100 101 104 public ServletContext getServletContext() 105 { 106 return new ServletContextWrapper( 107 this.originalConfig.getServletContext()); 108 } 109 110 118 public Enumeration getInitParameterNames() 119 { 120 Vector names = new Vector (); 121 122 Enumeration en = this.initParameters.keys(); 124 125 while (en.hasMoreElements()) 126 { 127 String value = (String ) en.nextElement(); 128 129 names.add(value); 130 } 131 132 en = this.originalConfig.getInitParameterNames(); 134 135 while (en.hasMoreElements()) 136 { 137 String value = (String ) en.nextElement(); 138 139 if (!names.contains(value)) 140 { 141 names.add(value); 142 } 143 } 144 145 return names.elements(); 146 } 147 148 154 public String getInitParameter(String theName) 155 { 156 String value = (String ) this.initParameters.get(theName); 159 160 if (value == null) 161 { 162 value = this.originalConfig.getInitParameter(theName); 163 } 164 165 return value; 166 } 167 } 168 | Popular Tags |