001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/tool/tags/sakai_2-4-1/tool-api/api/src/java/org/sakaiproject/tool/cover/SessionManager.java $
003: * $Id: SessionManager.java 22832 2007-03-17 23:22:16Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.cover;
021:
022: import org.sakaiproject.component.cover.ComponentManager;
023:
024: /**
025: * <p>
026: * SessionManager is a static Cover for the {@link org.sakaiproject.tool.api.SessionManager SessionManager}; see that interface for usage details.
027: * </p>
028: */
029: public class SessionManager {
030: /** Possibly cached component instance. */
031: private static org.sakaiproject.tool.api.SessionManager m_instance = null;
032:
033: /** Key in the ThreadLocalManager for the case where a session requested was invalid, and we started a new one. */
034: public final static String CURRENT_INVALID_SESSION = org.sakaiproject.tool.api.SessionManager.CURRENT_INVALID_SESSION;
035:
036: /**
037: * Access the component instance: special cover only method.
038: *
039: * @return the component instance.
040: */
041: public static org.sakaiproject.tool.api.SessionManager getInstance() {
042: if (ComponentManager.CACHE_COMPONENTS) {
043: if (m_instance == null) {
044: m_instance = (org.sakaiproject.tool.api.SessionManager) ComponentManager
045: .get(org.sakaiproject.tool.api.SessionManager.class);
046: }
047: return m_instance;
048: } else {
049: return (org.sakaiproject.tool.api.SessionManager) ComponentManager
050: .get(org.sakaiproject.tool.api.SessionManager.class);
051: }
052: }
053:
054: public static org.sakaiproject.tool.api.Session startSession() {
055: org.sakaiproject.tool.api.SessionManager manager = getInstance();
056: if (manager == null)
057: return null;
058:
059: return manager.startSession();
060: }
061:
062: public static org.sakaiproject.tool.api.Session startSession(
063: java.lang.String param0) {
064: org.sakaiproject.tool.api.SessionManager manager = getInstance();
065: if (manager == null)
066: return null;
067:
068: return manager.startSession(param0);
069: }
070:
071: public static org.sakaiproject.tool.api.Session getSession(
072: java.lang.String param0) {
073: org.sakaiproject.tool.api.SessionManager manager = getInstance();
074: if (manager == null)
075: return null;
076:
077: return manager.getSession(param0);
078: }
079:
080: public static org.sakaiproject.tool.api.Session getCurrentSession() {
081: org.sakaiproject.tool.api.SessionManager manager = getInstance();
082: if (manager == null)
083: return null;
084:
085: return manager.getCurrentSession();
086: }
087:
088: public static java.lang.String getCurrentSessionUserId() {
089: org.sakaiproject.tool.api.SessionManager manager = getInstance();
090: if (manager == null)
091: return null;
092:
093: return manager.getCurrentSessionUserId();
094: }
095:
096: public static org.sakaiproject.tool.api.ToolSession getCurrentToolSession() {
097: org.sakaiproject.tool.api.SessionManager manager = getInstance();
098: if (manager == null)
099: return null;
100:
101: return manager.getCurrentToolSession();
102: }
103:
104: public static void setCurrentSession(
105: org.sakaiproject.tool.api.Session param0) {
106: org.sakaiproject.tool.api.SessionManager manager = getInstance();
107: if (manager == null)
108: return;
109:
110: manager.setCurrentSession(param0);
111: }
112:
113: public static void setCurrentToolSession(
114: org.sakaiproject.tool.api.ToolSession param0) {
115: org.sakaiproject.tool.api.SessionManager manager = getInstance();
116: if (manager == null)
117: return;
118:
119: manager.setCurrentToolSession(param0);
120: }
121:
122: public static int getActiveUserCount(int param0) {
123: org.sakaiproject.tool.api.SessionManager manager = getInstance();
124: if (manager == null)
125: return 0;
126:
127: return manager.getActiveUserCount(param0);
128: }
129: }
|