Annotation of java/classes/org/w3c/jigsaw/servlet/JigsawHttpSessionContext.java, revision 1.2
1.1 bmahe 1: // JigsawHttpSessionContext.java
1.2 ! bmahe 2: // $Id: JigsawHttpSessionContext.java,v 1.1 1998/05/14 15:04:32 bmahe Exp $
1.1 bmahe 3: // (c) COPYRIGHT MIT and INRIA, 1998.
4: // Please first read the full copyright statement in file COPYRIGHT.html
5:
6: package org.w3c.jigsaw.servlet;
7:
8: import java.io.*;
9: import javax.servlet.*;
10: import javax.servlet.http.*;
11: import java.net.*;
12: import java.util.*;
13:
14: /**
1.2 ! bmahe 15: * @version $Revision: 1.1 $
1.1 bmahe 16: * @author Benoît Mahé (bmahe@w3.org)
17: */
18: public class JigsawHttpSessionContext implements HttpSessionContext {
19:
20: private Hashtable sessions;
21: private int sessionNb = 0;
22:
23: public Enumeration getIds()
24: {
25: return sessions.keys();
26: }
27:
28: public HttpSession getSession(String sessionId) {
29: return (HttpSession)sessions.get(sessionId);
30: }
31:
32: public synchronized String addSession(JigsawHttpSession session) {
33: String id = getNewSessionId();
34: sessions.put(id, session);
35: return id;
36: }
37:
38: public void removeSession(String id) {
39: sessions.remove(id);
40: }
41:
42: String getNewSessionId() {
1.2 ! bmahe 43: return "J"+String.valueOf(new Date().hashCode())+"-"+(sessionNb++);
1.1 bmahe 44: }
45:
46: public JigsawHttpSessionContext() {
47: sessions = new Hashtable(3);
48: }
49:
50: }
Webmaster