1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.tiles.request.jsp.extractor;
22
23 import java.util.Enumeration;
24
25 import javax.servlet.jsp.PageContext;
26
27 import org.apache.tiles.request.attribute.AttributeExtractor;
28
29
30
31
32
33
34 public class SessionScopeExtractor implements AttributeExtractor {
35
36
37
38
39 private PageContext context;
40
41
42
43
44
45
46 public SessionScopeExtractor(PageContext context) {
47 this.context = context;
48 }
49
50 @Override
51 public void removeValue(String name) {
52 if (context.getSession() == null) {
53 return;
54 }
55 context.removeAttribute(name, PageContext.SESSION_SCOPE);
56 }
57
58 @Override
59 public Enumeration<String> getKeys() {
60 if (context.getSession() == null) {
61 return null;
62 }
63 return context.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
64 }
65
66 @Override
67 public Object getValue(String key) {
68 if (context.getSession() == null) {
69 return null;
70 }
71 return context.getAttribute(key, PageContext.SESSION_SCOPE);
72 }
73
74 @Override
75 public void setValue(String key, Object value) {
76 if (context.getSession() == null) {
77 return;
78 }
79 context.setAttribute(key, value, PageContext.SESSION_SCOPE);
80 }
81 }