KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > internal > http > HttpSessionWrapper


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.junit.internal.http;
8
9
10 import java.util.Enumeration JavaDoc;
11
12 import javax.servlet.http.HttpSession JavaDoc;
13 import javax.servlet.http.HttpSessionContext JavaDoc;
14
15
16 /**
17  * <p>
18  * A dummy HTTP session object. This object allows much more
19  * flexibility with changing standards as well as changing
20  * requirements on specific projects. For example, if someone
21  * wishes to test session attributes but does not want those
22  * same attributes there for the next test, a sub-class of
23  * this class could store all the session attributes locally.
24  * </p>
25  *
26  * <p>
27  * Overall, this class is empty allowing all the session method
28  * calls to propogate to the original wrapped session.
29  * </p>
30  *
31  * @author Brian Pontarelli
32  * @since 1.0
33  * @version 1.0
34  */

35 public class HttpSessionWrapper implements HttpSession JavaDoc {
36     
37     /**
38      * The original, wrapped session
39      */

40     protected HttpSession JavaDoc session;
41     
42
43     /**
44      * Constructs a new dummy session that will forward all its requests to
45      * the wrapped session
46      *
47      * @param session The session to wrap inside this object
48      */

49     public HttpSessionWrapper(HttpSession JavaDoc session) {
50         this.session = session;
51     }
52     
53
54     /**
55      * Returns the original session
56      */

57     public HttpSession JavaDoc getWrappedSession() {
58         return session;
59     }
60
61     /** Forwards call to wrapped response */
62     public Object JavaDoc getAttribute(String JavaDoc name) {
63         return session.getAttribute(name);
64     }
65
66     /** Forwards call to wrapped response */
67     public Enumeration JavaDoc getAttributeNames() {
68         return session.getAttributeNames();
69     }
70
71     /** Forwards call to wrapped response */
72     public long getCreationTime() {
73         return session.getCreationTime();
74     }
75
76     /** Forwards call to wrapped response */
77     public String JavaDoc getId() {
78         return session.getId();
79     }
80
81     /** Forwards call to wrapped response */
82     public long getLastAccessedTime() {
83         return session.getLastAccessedTime();
84     }
85
86     /** Forwards call to wrapped response */
87     public int getMaxInactiveInterval() {
88         return session.getMaxInactiveInterval();
89     }
90
91     /** Forwards call to wrapped response */
92     public javax.servlet.ServletContext JavaDoc getServletContext() {
93         return session.getServletContext();
94     }
95
96     /**
97      * @deprecated
98      */

99     public HttpSessionContext JavaDoc getSessionContext() {
100         return session.getSessionContext();
101     }
102
103     /**
104      * @deprecated
105      */

106     public Object JavaDoc getValue(String JavaDoc name) {
107         return session.getValue(name);
108     }
109
110     /**
111      * @deprecated
112      */

113     public String JavaDoc[] getValueNames() {
114         return session.getValueNames();
115     }
116
117     /** Forwards call to wrapped response */
118     public void invalidate() {
119         session.invalidate();
120     }
121
122     /** Forwards call to wrapped response */
123     public boolean isNew() {
124         return session.isNew();
125     }
126
127     /**
128      * @deprecated
129      */

130     public void putValue(String JavaDoc name, Object JavaDoc value) {
131         session.putValue(name, value);
132     }
133
134     /** Forwards call to wrapped response */
135     public void removeAttribute(String JavaDoc name) {
136         session.removeAttribute(name);
137     }
138
139     /**
140      * @deprecated
141      */

142     public void removeValue(String JavaDoc name) {
143         session.removeValue(name);
144     }
145
146     /** Forwards call to wrapped response */
147     public void setAttribute(String JavaDoc name, Object JavaDoc value) {
148         session.setAttribute(name, value);
149     }
150
151     /** Forwards call to wrapped response */
152     public void setMaxInactiveInterval(int interval) {
153         session.setMaxInactiveInterval(interval);
154     }
155 }
156
Popular Tags