1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.container.invoker;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletRequestWrapper;
24
25 /***
26 * Local servlet request wrapper. The purpose of this wrapper is to hold
27 * attribute information that is need for each request. In a threaded environment,
28 * each thread needs to have its own copy of this information so that there is
29 * not a timing issue with the original request object.
30 * Also, since the original request is no longer "holding" the attributes,
31 * there is no reason to remove them in the finally block.
32 * The LocalServletRequest object is automatically garbage collected at then
33 * end of this method.
34 *
35 * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
36 * @author <a href="">David Gurney</a>
37 * @version $Id: $
38 */
39 public class LocalServletRequest extends HttpServletRequestWrapper
40 {
41 private Map attributeMap = new HashMap();
42
43 private HttpServletRequest originalRequest = null;
44
45 public LocalServletRequest(HttpServletRequest request)
46 {
47 super(request);
48 originalRequest = request;
49 }
50
51 public Object getAttribute(String p_sKey)
52 {
53 Object a_oValue = attributeMap.get(p_sKey);
54 if (a_oValue == null)
55 {
56 a_oValue = originalRequest.getAttribute(p_sKey);
57 }
58
59 return a_oValue;
60 }
61
62 public void removeAttribute(String key)
63 {
64 Object value = attributeMap.remove(key);
65 if (value == null)
66 {
67 originalRequest.removeAttribute(key);
68 }
69 }
70
71 public void setAttribute(String key, Object value)
72 {
73 attributeMap.put(key, value);
74 }
75
76 }