1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.context.portlet;
20
21 import java.util.Enumeration;
22 import java.util.Map;
23
24 import javax.portlet.PortletRequest;
25 import javax.portlet.PortletSession;
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 public class SessionMap extends AbstractThreadSafeAttributeMap
37 {
38 private final PortletRequest _portletRequest;
39
40 SessionMap(PortletRequest portletRequest)
41 {
42 _portletRequest = portletRequest;
43 }
44
45 protected Object getAttribute(String key)
46 {
47 PortletSession portletSession = getSession();
48 return (portletSession == null)
49 ? null : portletSession.getAttribute(key.toString(), PortletSession.PORTLET_SCOPE);
50 }
51
52 protected void setAttribute(String key, Object value)
53 {
54 _portletRequest.getPortletSession(true).setAttribute(key, value, PortletSession.PORTLET_SCOPE);
55 }
56
57 protected void removeAttribute(String key)
58 {
59 PortletSession portletSession = getSession();
60 if (portletSession != null)
61 {
62 portletSession.removeAttribute(key, PortletSession.PORTLET_SCOPE);
63 }
64 }
65
66 protected Enumeration getAttributeNames()
67 {
68 PortletSession portletSession = getSession();
69 return (portletSession == null)
70 ? NullEnumeration.instance()
71 : portletSession.getAttributeNames(PortletSession.PORTLET_SCOPE);
72 }
73
74 private PortletSession getSession()
75 {
76 return _portletRequest.getPortletSession(false);
77 }
78
79 public void putAll(Map t)
80 {
81 throw new UnsupportedOperationException();
82 }
83
84
85 public void clear()
86 {
87 throw new UnsupportedOperationException();
88 }
89 }