KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > equinox > http > servlet > internal > HttpSessionAdaptor


1 /*******************************************************************************
2  * Copyright (c) 2005-2007 Cognos Incorporated, IBM Corporation and others
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Cognos Incorporated - initial API and implementation
10  * IBM Corporation - bug fixes and enhancements
11  *******************************************************************************/

12 package org.eclipse.equinox.http.servlet.internal;
13
14 import java.util.Enumeration JavaDoc;
15 import javax.servlet.Servlet JavaDoc;
16 import javax.servlet.ServletContext JavaDoc;
17 import javax.servlet.http.HttpSession JavaDoc;
18
19 // This class adapts HttpSessions in order to return the right ServletContext
20
public class HttpSessionAdaptor implements HttpSession JavaDoc {
21
22     private HttpSession JavaDoc session;
23     private Servlet JavaDoc servlet;
24
25     public HttpSessionAdaptor(HttpSession JavaDoc session, Servlet JavaDoc servlet) {
26         this.session = session;
27         this.servlet = servlet;
28     }
29
30     public ServletContext JavaDoc getServletContext() {
31         return servlet.getServletConfig().getServletContext();
32     }
33
34     public Object JavaDoc getAttribute(String JavaDoc arg0) {
35         return session.getAttribute(arg0);
36     }
37
38     public Enumeration JavaDoc getAttributeNames() {
39         return session.getAttributeNames();
40     }
41
42     public long getCreationTime() {
43         return session.getCreationTime();
44     }
45
46     public String JavaDoc getId() {
47         return session.getId();
48     }
49
50     public long getLastAccessedTime() {
51         return session.getLastAccessedTime();
52     }
53
54     public int getMaxInactiveInterval() {
55         return session.getMaxInactiveInterval();
56     }
57
58     /**@deprecated*/
59     public javax.servlet.http.HttpSessionContext JavaDoc getSessionContext() {
60         return session.getSessionContext();
61     }
62
63     /**@deprecated*/
64     public Object JavaDoc getValue(String JavaDoc arg0) {
65         return session.getValue(arg0);
66     }
67
68     /**@deprecated*/
69     public String JavaDoc[] getValueNames() {
70         return session.getValueNames();
71     }
72
73     public void invalidate() {
74         session.invalidate();
75     }
76
77     public boolean isNew() {
78         return session.isNew();
79     }
80
81     /**@deprecated*/
82     public void putValue(String JavaDoc arg0, Object JavaDoc arg1) {
83         session.putValue(arg0, arg1);
84     }
85
86     public void removeAttribute(String JavaDoc arg0) {
87         session.removeAttribute(arg0);
88     }
89
90     /**@deprecated*/
91     public void removeValue(String JavaDoc arg0) {
92         session.removeValue(arg0);
93     }
94
95     public void setAttribute(String JavaDoc arg0, Object JavaDoc arg1) {
96         session.setAttribute(arg0, arg1);
97     }
98
99     public void setMaxInactiveInterval(int arg0) {
100         session.setMaxInactiveInterval(arg0);
101     }
102
103 }
104
Popular Tags