1 16 package org.apache.commons.chain.web.servlet; 17 18 19 import java.util.Map ; 20 import javax.servlet.ServletContext ; 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 import org.apache.commons.chain.web.WebContext; 24 25 26 35 36 public class ServletWebContext extends WebContext { 37 38 39 41 42 45 public ServletWebContext() { 46 47 ; 48 49 } 50 51 52 60 public ServletWebContext(ServletContext context, 61 HttpServletRequest request, 62 HttpServletResponse response) { 63 64 initialize(context, request, response); 65 66 } 67 68 69 71 72 76 private Map applicationScope = null; 77 78 79 82 protected ServletContext context = null; 83 84 85 89 private Map header = null; 90 91 92 96 private Map headerValues = null; 97 98 99 103 private Map initParam = null; 104 105 106 110 private Map param = null; 111 112 113 117 private Map paramValues = null; 118 119 120 123 protected HttpServletRequest request = null; 124 125 126 130 private Map requestScope = null; 131 132 133 136 protected HttpServletResponse response = null; 137 138 139 143 private Map sessionScope = null; 144 145 146 148 149 152 public ServletContext getContext() { 153 154 return (this.context); 155 156 } 157 158 159 162 public HttpServletRequest getRequest() { 163 164 return (this.request); 165 166 } 167 168 169 172 public HttpServletResponse getResponse() { 173 174 return (this.response); 175 176 } 177 178 179 187 public void initialize(ServletContext context, 188 HttpServletRequest request, 189 HttpServletResponse response) { 190 191 this.context = context; 193 this.request = request; 194 this.response = response; 195 196 198 } 199 200 201 207 public void release() { 208 209 applicationScope = null; 211 header = null; 212 headerValues = null; 213 initParam = null; 214 param = null; 215 paramValues = null; 216 requestScope = null; 217 sessionScope = null; 218 219 context = null; 221 request = null; 222 response = null; 223 224 } 225 226 227 228 230 231 public Map getApplicationScope() { 232 233 if ((applicationScope == null) && (context != null)) { 234 applicationScope = new ServletApplicationScopeMap(context); 235 } 236 return (applicationScope); 237 238 } 239 240 241 public Map getHeader() { 242 243 if ((header == null) && (request != null)) { 244 header = new ServletHeaderMap(request); 245 } 246 return (header); 247 248 } 249 250 251 public Map getHeaderValues() { 252 253 if ((headerValues == null) && (request != null)) { 254 headerValues = new ServletHeaderValuesMap(request); 255 } 256 return (headerValues); 257 258 } 259 260 261 public Map getInitParam() { 262 263 if ((initParam == null) && (context != null)) { 264 initParam = new ServletInitParamMap(context); 265 } 266 return (initParam); 267 268 } 269 270 271 public Map getParam() { 272 273 if ((param == null) && (request != null)) { 274 param = new ServletParamMap(request); 275 } 276 return (param); 277 278 } 279 280 281 public Map getParamValues() { 282 283 if ((paramValues == null) && (request != null)) { 284 paramValues = new ServletParamValuesMap(request); 285 } 286 return (paramValues); 287 288 } 289 290 291 public Map getRequestScope() { 292 293 if ((requestScope == null) && (request != null)) { 294 requestScope = new ServletRequestScopeMap(request); 295 } 296 return (requestScope); 297 298 } 299 300 301 public Map getSessionScope() { 302 303 if ((sessionScope == null) && (request != null)) { 304 sessionScope = new ServletSessionScopeMap(request.getSession()); 305 } 306 return (sessionScope); 307 308 } 309 310 311 312 } 313 | Popular Tags |