KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > session > SessionManager


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: SessionManager.java,v 1.1 2005/07/13 11:09:06 slobodan Exp $
23  *
24  * formatted with JxBeauty (c) johann.langhofer@nextra.at
25  */

26
27
28
29
30 package com.lutris.appserver.server.session;
31
32 import java.util.Date JavaDoc;
33 import java.util.Enumeration JavaDoc;
34
35 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
36 import com.lutris.appserver.server.user.User;
37
38
39 /**
40  * The session management object interface. This class implementing this
41  * interface manage the session state for currently active users
42  * of one or more applications. It allocates sessions and maintains the
43  * mapping between session keys and Session objects.
44  *
45  * @version $Revision: 1.1 $
46  * @author Shawn McMurdo
47  * @author Mark Diekhans
48  */

49 public interface SessionManager {
50     /**
51    * Indicates that url encoding of session ids is never preformed.
52    * @see #getEncodeUrlState
53    **/

54   public static final String JavaDoc ENCODE_URL_NEVER = "Never";
55   /**
56    * Indicates that url encoding of session ids is always preformed.
57    * @see #getEncodeUrlState
58    **/

59   public static final String JavaDoc ENCODE_URL_ALWAYS = "Always";
60   /**
61    * Indicates that url encoding of session ids is preformed only when
62    * cookies are disabled on the client browser. This is automatically
63    * detected.
64    * @see #getEncodeUrlState
65    **/

66   public static final String JavaDoc ENCODE_URL_AUTO = "Auto";
67
68
69
70   /**
71      * Create a new <CODE>Session</CODE> object and an associated unique
72      * random key. No <CODE>User</CODE> object is initially associated with
73      * the session (<CODE>getUser()</CODE> returns <CODE>null</CODE>).
74      *
75      * @return session The new <code>Session</code> object.
76      * @exception SessionException if the session cannot be created.
77      * @see Session
78      */

79     public Session createSession() throws SessionException;
80
81     /**
82      * Create a new <CODE>Session</CODE> object and an associated unique
83      * random key. No <CODE>User</CODE> object is initially associated with
84      * the session (<CODE>getUser()</CODE> returns <CODE>null</CODE>).
85      *
86      * @param ipPortToken
87      * The base64 encoded IP and Port number to include in session key
88      * @return session The new <code>Session</code> object.
89      * @exception SessionException if the session cannot be created.
90      * @see Session
91      */

92     public Session createSession(String JavaDoc ipPortToken) throws SessionException;
93
94     /**
95    * Create a new <CODE>Session</CODE> object and an associated unique
96    * random key. No <CODE>User</CODE> object is initially associated with
97    * the session (<CODE>getUser()</CODE> returns <CODE>null</CODE>).
98    *
99    * @param comms The presentations manager comms object with
100    * all request/response information in it.
101    * @return session The new <code>Session</code> object.
102    * @exception SessionException if the session cannot be created.
103    * @see Session
104    */

105
106   public Session createSession (HttpPresentationComms comms) throws SessionException;
107
108
109
110   /**
111      * Removes a session from the session manager.
112      *
113      * @param session The session object to delete.
114      * @exception SessionException
115      * if the session cannot be deleted.
116      */

117     public void deleteSession(Session session) throws SessionException;
118     
119     /**
120      * Removes a session from the manager.
121      *
122      * @param sessionKey
123      * the session key.
124      * @exception SessionException
125      * if the session cannot be deleted.
126      */

127     public void deleteSession(String JavaDoc sessionKey) throws SessionException;
128     
129     /**
130      * Returns whether the <code>Session</code> object associated with
131      * the specified session key exists.
132      *
133      * @param sessionKey
134      * The String used to reference a <code>Session</code> object.
135      * @return
136      * If the key is associated with an active session, then
137      * return true, otherwise return false.
138      * @exception SessionException
139      * if the existence of the session cannot be determined.
140      */

141     public boolean sessionExists(String JavaDoc sessionKey) throws SessionException;
142
143     /**
144      * Returns the <code>Session</code> object associated with the
145      * specified session key. The session is put in the 'active'
146      * state. If no <code>Session</code> object is
147      * associated with the key then this method returns <code>null</code>.
148      *
149      * @param sessionKey The String used to reference a
150      * <code>Session</code> object.
151      * @return If the key is associated with an active session, then
152      * the corresponding <code>Session</code> object is
153      * returned. Otherwise <code>null</code> is returned.
154      * @see Session
155      * @exception SessionException
156      * if the session cannot be retrieved.
157      */

158     public Session getSession(String JavaDoc sessionKey) throws SessionException;
159
160
161
162   /**
163    * Returns the <code>Session</code> object associated with the
164    * specified session key. The session is put in the 'active'
165    * state. If no <code>Session</code> object is
166    * associated with the key then this method returns <code>null</code>.
167    *
168    * @param thread the thread that should be associated with
169    * the session. Only this thread can subsequently
170    * put the session into the passive state.
171    * @param sessionKey The String used to reference a
172    * <code>Session</code> object.
173    * @return If the key is associated with an active session, then
174    * the corresponding <code>Session</code> object is
175    * returned. Otherwise <code>null</code> is returned.
176    * @see Session
177    * @exception SessionException
178    * if the session cannot be retrieved.
179    */

180   public Session getSession (Thread JavaDoc thread, String JavaDoc sessionKey) throws SessionException;
181
182     /**
183      * Returns the <code>Session</code> object associated with the
184      * specified session key. The session is put in the 'active'
185      * state. If no <code>Session</code> object is
186      * associated with the key then this method returns <code>null</code>.
187      *
188      * @param thread the thread that should be associated with
189      * the session. Only this thread can subsequently
190      * put the session into the passive state.
191    * @param comms The presentations manager comms object with
192    * all request/response information in it.
193      * @param sessionKey The String used to reference a
194      * <code>Session</code> object.
195      * @return If the key is associated with an active session, then
196      * the corresponding <code>Session</code> object is
197      * returned. Otherwise <code>null</code> is returned.
198      * @see Session
199      * @exception SessionException
200      * if the session cannot be retrieved.
201      */

202
203
204   public Session getSession (Thread JavaDoc thread, String JavaDoc sessionKey, HttpPresentationComms comms) throws SessionException;
205
206
207
208     /**
209      * Lookup active sessions keys for a user. A given user may have
210      * multiple sessions associated with it.
211      *
212      * @param user The user to search for.
213      * @return An enumeration of the active sessions keys for the user.
214      * @exception SessionException
215      * if the sessions cannot be retrieved.
216      */

217     public Enumeration JavaDoc getSessionKeys(User user) throws SessionException;
218
219     /**
220      * Puts a session into the 'passive' state. A 'passive'
221      * session may be made persistent.
222      *
223      * @param thread the thread currently associate with the
224      * the session.
225      * @param sessionKey the session key for the session
226      * that will be made persistent.
227      * @exception SessionException
228      * if the session cannot be put into the passive state..
229      */

230   public void passivateSession (Thread JavaDoc thread, String JavaDoc sessionKey) throws SessionException;
231
232
233
234     /**
235      * Gets the number of currently active sessions.
236      *
237      * @return The number of currently active sessions.
238      * @exception SessionException
239      * if the active session count cannot be determined.
240      */

241     public int activeSessionCount() throws SessionException;
242    
243     /**
244      * Gets the maximum number of concurent sessions that existed
245      * at any time since this object was created, or
246      * <CODE>resetMaxSessionCount()</CODE> was called.
247      * This is a historical highwater mark.
248      * If you do not implement this feature, return -1.
249      *
250      * @return The highwater mark for number of sessions, or -1.
251      */

252     public int maxSessionCount();
253
254     /**
255      * Gets the time when the maximum refered to by
256      * <CODE>maxSessionCount()</CODE> occured.
257      *
258      * @return The Date of when the maximum number of sessions occured.
259      */

260     public Date JavaDoc maxSessionCountDate();
261
262     /**
263      * Reset the maximum session count. See <CODE>maxSessionCount()</CODE>.
264      * The highwater mark should be reset to the current number of sessions.
265      *
266      * @exception SessionException
267      * if the max session count cannot be reset.
268      */

269     public void resetMaxSessionCount() throws SessionException;
270
271     /**
272      * Get an enumeration of all session keys.
273      *
274      * @return An enumeration of the session keys.
275      * @exception SessionException
276      * if the session keys cannot be retrieved.
277      */

278     public Enumeration JavaDoc getSessionKeys() throws SessionException;
279
280     /**
281      * Shutdown this session manager as required. The session manager
282      * should not be used after this method has been called
283      */

284     public void shutdown();
285
286
287
288   /**
289    * Returns the url encoding state. Either <code>Never</code>
290    * <code>Always</code> <code>Auto</code>
291    */

292   public String JavaDoc getEncodeUrlState ();
293 }
294
295
296
297
Popular Tags