1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.context.servlet;
20
21 import java.util.Enumeration;
22 import java.util.Map;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpSession;
26
27 import org.apache.myfaces.shared_impl.util.NullEnumeration;
28 import org.apache.myfaces.util.AbstractThreadSafeAttributeMap;
29
30
31
32
33
34
35
36
37 public class SessionMap extends AbstractThreadSafeAttributeMap
38 {
39 private final HttpServletRequest _httpRequest;
40
41 SessionMap(HttpServletRequest httpRequest)
42 {
43 _httpRequest = httpRequest;
44 }
45
46 protected Object getAttribute(String key)
47 {
48 HttpSession httpSession = getSession();
49 return (httpSession == null)
50 ? null : httpSession.getAttribute(key.toString());
51 }
52
53 protected void setAttribute(String key, Object value)
54 {
55 _httpRequest.getSession(true).setAttribute(key, value);
56 }
57
58 protected void removeAttribute(String key)
59 {
60 HttpSession httpSession = getSession();
61 if (httpSession != null)
62 {
63 httpSession.removeAttribute(key);
64 }
65 }
66
67 protected Enumeration getAttributeNames()
68 {
69 HttpSession httpSession = getSession();
70 return (httpSession == null)
71 ? NullEnumeration.instance()
72 : httpSession.getAttributeNames();
73 }
74
75 private HttpSession getSession()
76 {
77 return _httpRequest.getSession(false);
78 }
79
80
81 public void putAll(Map t)
82 {
83 throw new UnsupportedOperationException();
84 }
85
86
87 public void clear()
88 {
89 throw new UnsupportedOperationException();
90 }
91 }