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.ServletConfig ; 27 import javax.servlet.ServletContext ; 28 29 37 public abstract class AbstractServletConfigWrapper 38 implements ServletConfig 39 { 40 43 protected ServletConfig originalConfig; 44 45 48 protected Hashtable initParameters; 49 50 53 protected String servletName; 54 55 58 public AbstractServletConfigWrapper(ServletConfig theOriginalConfig) 59 { 60 this.originalConfig = theOriginalConfig; 61 this.initParameters = new Hashtable (); 62 } 63 64 70 public void setInitParameter(String theName, String theValue) 71 { 72 this.initParameters.put(theName, theValue); 73 } 74 75 81 public void setServletName(String theServletName) 82 { 83 this.servletName = theServletName; 84 } 85 86 90 public ServletConfig getOriginalConfig() 91 { 92 return this.originalConfig; 93 } 94 95 97 100 public ServletContext getServletContext() 101 { 102 return new ServletContextWrapper( 103 this.originalConfig.getServletContext()); 104 } 105 106 112 public String getInitParameter(String theName) 113 { 114 String value = (String ) this.initParameters.get(theName); 117 118 if (value == null) 119 { 120 value = this.originalConfig.getInitParameter(theName); 121 } 122 123 return value; 124 } 125 126 131 public Enumeration getInitParameterNames() 132 { 133 Vector names = new Vector (); 134 135 Enumeration en = this.initParameters.keys(); 137 138 while (en.hasMoreElements()) 139 { 140 String value = (String ) en.nextElement(); 141 142 names.add(value); 143 } 144 145 en = this.originalConfig.getInitParameterNames(); 147 148 while (en.hasMoreElements()) 149 { 150 String value = (String ) en.nextElement(); 151 152 if (!names.contains(value)) 155 { 156 names.add(value); 157 } 158 } 159 160 return names.elements(); 161 } 162 163 167 public String getServletName() 168 { 169 if (this.servletName != null) 170 { 171 return this.servletName; 172 } 173 174 return this.originalConfig.getServletName(); 175 } 176 } 177 | Popular Tags |