KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > session > SessionService


1 package org.apache.turbine.services.session;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.Collection JavaDoc;
20 import javax.servlet.http.HttpSession JavaDoc;
21
22 import org.apache.turbine.om.security.User;
23 import org.apache.turbine.services.Service;
24
25 /**
26  * The SessionService allows access to the current sessions of the current context.
27  * The session objects that are cached by this service are obtained through
28  * a listener. The listener must be configured in your web.xml file.
29  *
30  * @author <a HREF="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
31  * @since 2.3
32  * @see org.apache.turbine.services.session.SessionListener
33  * @version $Id: SessionService.java,v 1.7.2.2 2004/05/20 03:06:50 seade Exp $
34  */

35 public interface SessionService extends Service
36 {
37
38     /**
39      * The key under which this service is stored in TurbineServices.
40      */

41     static final String JavaDoc SERVICE_NAME = "SessionService";
42
43     /**
44      * Gets all active sessions
45      *
46      * @return Collection of HttpSession objects
47      */

48     Collection JavaDoc getActiveSessions();
49
50     /**
51      * Adds a session to the current list. This method should only be
52      * called by the listener.
53      *
54      * @param session Session to add
55      */

56     void addSession(HttpSession JavaDoc session);
57
58     /**
59      * Removes a session from the current list. This method should only be
60      * called by the listener.
61      *
62      * @param session Session to remove
63      */

64     void removeSession(HttpSession JavaDoc session);
65
66     /**
67      * Determines if a given user is currently logged in. The actual
68      * implementation of the User object must implement the equals()
69      * method. By default, Torque based objects (liek TurbineUser)
70      * have an implementation of equals() that will compare the
71      * result of getPrimaryKey().
72      *
73      * @param user User to check for
74      * @return true if the user is logged in on one of the
75      * active sessions.
76      */

77     boolean isUserLoggedIn(User user);
78
79     /**
80      * Gets a collection of all user objects representing the users currently
81      * logged in. This will exclude any instances of anonymous user that
82      * Turbine will use before the user actually logs on.
83      *
84      * @return collection of org.apache.turbine.om.security.User objects
85      */

86     Collection JavaDoc getActiveUsers();
87
88     /**
89      * Gets the User object of the the specified HttpSession.
90      *
91      * @param session The session from which to extract a user.
92      * @return The Turbine User object.
93      */

94     User getUserFromSession(HttpSession JavaDoc session);
95
96     /**
97      * Gets the HttpSession by the session identifier
98      *
99      * @param sessionId The unique session identifier.
100      * @return The session keyed by the specified identifier.
101      */

102     HttpSession JavaDoc getSession(String JavaDoc sessionId);
103
104     /**
105      * Get a collection of all session on which the given user
106      * is logged in.
107      *
108      * @param user the user
109      * @return Collection of HtttSession objects
110      */

111     Collection JavaDoc getSessionsForUser(User user);
112
113 }
114
Popular Tags