01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.session;
14:
15: /**
16: * A global way to access the current session.
17: *
18: * @author <a href="mailto:engels@mercatis.de">Holger Engels</a>
19: */
20: public final class SessionManager {
21: private static final ThreadLocal currentSession = new ThreadLocal();
22:
23: /**
24: * Get the Session that is currently associated with this Thread.
25: *
26: * @return the Session
27: */
28: public static Session getSession() {
29: return (Session) currentSession.get();
30: }
31:
32: /**
33: * Associate the Session with the current Thread.
34: * This method must only be called by the SessionServlet before
35: * a request is going to be dispatched.
36: *
37: * @param session the Session
38: */
39: public static void setSession(Session session) {
40: currentSession.set(session);
41: }
42:
43: public static void removeSession() {
44: currentSession.set(null);
45: }
46: }
|