1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.command;
24
25 import javax.servlet.http.HttpSession;
26
27 /**
28 * Implementation of <code>Session</code> interface.
29 *
30 * @author Jose M. Palomar
31 * @version $Revision: 113 $
32 */
33 public final class SessionImpl implements Session {
34
35
36
37
38 /**
39 * Source HttpSession.
40 */
41 private final HttpSession httpSession;
42
43
44 /**
45 * Constructs a new <code>SessionImpl</code> object.
46 *
47 * @param httpSession HttpSession source HttpSession.
48 */
49 public SessionImpl(HttpSession httpSession) {
50 this.httpSession = httpSession;
51 }
52
53
54 /**
55 * Returns a string containing the unique identifier assigned to this session.
56 *
57 * @return String string containing the unique identifier assigned to this
58 * session.
59 * @see org.talika.tarsis.command.Session#getId()
60 */
61 public String getId() {
62 return httpSession.getId();
63 }
64
65 /**
66 * Binds an object to this session, using the name specified. If an object of
67 * the same name is already bound to the session, the object is replaced.
68 *
69 * @param name String the name to which the object is bound; cannot be
70 * <code>null</code>.
71 * @param value Object the object to be bound.
72 * @see org.talika.tarsis.command.Session#setAttribute(String, Object)
73 */
74 public void setAttribute(String name, Object value) {
75 httpSession.setAttribute(name, value);
76 }
77
78 /**
79 * Returns the object bound with the specified name in this session, or
80 * <code>null</code> if no object is bound under the name.
81 *
82 * @param name String a string specifying the name of the object.
83 * @return Object the object with the specified name.
84 * @see org.talika.tarsis.command.Session#getAttribute(String)
85 */
86 public Object getAttribute(String name) {
87 return httpSession.getAttribute(name);
88 }
89
90 /**
91 * Removes the object bound with the specified name from this session. If the
92 * session does not have an object bound with the specified name, this method
93 * does nothing.
94 *
95 * @param name String the name of the object to remove from this session.
96 * @see org.talika.tarsis.command.Session#removeAttribute(String)
97 */
98 public void removeAttribute(String name) {
99 httpSession.removeAttribute(name);
100 }
101
102 }