1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.tapestry;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.abstracthorizon.danube.http.session.Session;
19 import org.apache.tapestry.describe.DescriptionReceiver;
20 import org.apache.tapestry.web.WebSession;
21
22
23
24
25
26
27 public class DanubeSession implements WebSession {
28
29
30 public static final String SESSION_ATTRIBUTE = "org.abstracthorizon.danube.tapestry.WebSession";
31
32
33 protected Session session;
34
35
36 protected boolean isNew = true;
37
38
39
40
41
42 public DanubeSession(Session session) {
43 this.session = session;
44 session.getAttributes().put(SESSION_ATTRIBUTE, this);
45 }
46
47
48
49
50
51 public String getId() {
52 return session.getSessionId();
53 }
54
55
56
57
58
59 public boolean isNew() {
60 return isNew;
61 }
62
63
64
65
66 protected void clearNew() {
67 isNew = false;
68 }
69
70
71
72
73 public void invalidate() {
74 session.getAttributes().remove(SESSION_ATTRIBUTE);
75 }
76
77
78
79
80
81 @SuppressWarnings("unchecked")
82 public List getAttributeNames() {
83 ArrayList<String> names = new ArrayList<String>(session.getAttributes().keySet());
84 return names;
85 }
86
87
88
89
90
91
92 public Object getAttribute(String key) {
93 return session.getAttributes().get(key);
94 }
95
96
97
98
99
100
101 public void setAttribute(String key, Object value) {
102 session.getAttributes().put(key, value);
103 }
104
105
106
107
108 public void describeTo(DescriptionReceiver descriptionReceiver) {
109 }
110
111 }