KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > session > SessionManager


1 /*
2  * $Id: SessionManager.java,v 1.6 2005/05/18 15:21:10 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.session;
15
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18
19
20
21 /**
22  * A global way to access the current session. FIXME: should this be
23  * called SessionManager, then ?
24  *
25  * @author <a HREF="mailto:engels@mercatis.de">Holger Engels</a>
26  * @version $Revision: 1.6 $
27  */

28 public class SessionManager {
29     private final transient static Log log = LogFactory.getLog(SessionManager.class);
30     private static final ThreadLocal JavaDoc currentSession = new ThreadLocal JavaDoc();
31
32     /**
33      * Get the Session that is currently associated with this Thread.
34      *
35      * @return the Session
36      */

37     public static Session getSession() {
38         return (Session) currentSession.get();
39     }
40
41     /**
42      * Associate the Session with the current Thread.
43      * This method must only be called by the SessionServlet before
44      * a request is going to be dispatched.
45      *
46      * @param session the Session
47      */

48     public static void setSession(Session session) {
49         currentSession.set(session);
50     }
51
52     public static void removeSession() {
53         currentSession.set(null);
54     }
55 }
56
57
58
Popular Tags