01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/tool/tags/sakai_2-4-1/tool-api/api/src/java/org/sakaiproject/tool/api/SessionManager.java $
03: * $Id: SessionManager.java 22832 2007-03-17 23:22:16Z ggolden@umich.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.api;
21:
22: /**
23: * <p>
24: * SessionManager keeps track of Sakai-wide and Tool placement specific user sessions, modeled on the HttpSession of the Servlet API.
25: * </p>
26: */
27: public interface SessionManager {
28: /** Key in the ThreadLocalManager for the case where a session requested was invalid, and we started a new one. */
29: final static String CURRENT_INVALID_SESSION = "sakai:session.was.invalid";
30:
31: /**
32: * Access the known session with this id.
33: *
34: * @return The Session object that has this id, or null if the id is not known.
35: */
36: Session getSession(String sessionId);
37:
38: /**
39: * Start a new session.
40: *
41: * @return The new UsageSession.
42: */
43: Session startSession();
44:
45: /**
46: * Start a new session, using this session id.
47: *
48: * @param id
49: * The session Id to use.
50: * @return The new UsageSession.
51: */
52: Session startSession(String id);
53:
54: /**
55: * Access the session associated with the current request or processing thread.
56: *
57: * @return The session associatd with the current request or processing thread.
58: */
59: Session getCurrentSession();
60:
61: /**
62: * Access the current session's user id, or return null if there is no current session.
63: *
64: * @return The current session's user id, or null if there is no current session or it has no user id.
65: */
66: String getCurrentSessionUserId();
67:
68: /**
69: * Access the tool session associated with the current request or processing thread.
70: *
71: * @return The tool session associatd with the current request or processing thread.
72: */
73: ToolSession getCurrentToolSession();
74:
75: /**
76: * Set this session as the current one for this request processing or thread.
77: *
78: * @param s
79: * The session to set as the current session.
80: */
81: void setCurrentSession(Session s);
82:
83: /**
84: * Set this session as the current tool session for this request processing or thread.
85: *
86: * @param s
87: * The session to set as the current tool session.
88: */
89: void setCurrentToolSession(ToolSession s);
90:
91: /**
92: * Count the number of users with sessions recently active (within the given number of seconds)
93: *
94: * @param secs
95: * Elapsed time within which sessions have been active
96: */
97: int getActiveUserCount(int secs);
98: }
|