View Javadoc

1   /*
2   Wotonomy: OpenStep design patterns for pure Java applications.
3   Copyright (C) 2003 Intersect Software Corp.
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  Lesser General Public License for more details.
14  
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, see http://www.gnu.org
17  */
18  
19  package net.wotonomy.web;
20  
21  /***
22  * An abstract class defining the requirements for persisting
23  * session state across user transactions.  Used by WOApplication
24  * to persist sessions between requests.
25  *
26  * @author michael@mpowers.net
27  * @author $Author: cgruber $
28  * @version $Revision: 893 $
29  */
30  public abstract class WOSessionStore
31  {
32      private static WOSessionStore serverSessionStore = null;
33      
34      /***
35      * Returns the default session store used by WOApplication.
36      */ 
37      public static WOSessionStore serverSessionStore()
38      {
39          if ( serverSessionStore == null )
40          {
41              serverSessionStore = new WOServletSessionStore();
42          }
43          return serverSessionStore;
44      }
45  
46      /***
47      * Called by WOApplication after the request-response cycle has ended.
48      * The context's session will again be available for subsequent requests.
49      */    
50      public final void checkInSessionForContext(WOContext aContext)
51      {
52          saveSessionForContext( aContext );
53      }
54      
55      /***
56      * Returns the session with the specified id for the specified request,
57      * or null if none exist.  Subsequent calls for the same id will return
58      * null until the session is checked in again.
59      * Called by WOApplication before the request-response cycle starts.
60      */    
61      public final WOSession checkOutSessionWithID(String sessionID, WORequest aRequest)
62      {
63          return restoreSessionWithID( sessionID, aRequest );
64      }
65  
66      /***
67      * Removes the WOSession for the specified ID from the store and returns it.
68      */                                              
69      public abstract WOSession removeSessionWithID(String sessionID);
70      
71      /***
72      * Returns the WOSession for the specified ID from the store.
73      */
74      public abstract WOSession restoreSessionWithID(String sessionID,
75                                                     WORequest aRequest);
76                                                     
77      /***
78      * Places the context's session into the store.
79      */
80      public abstract void saveSessionForContext(WOContext context);
81  }
82  
83  /*
84   * $Log$
85   * Revision 1.1  2006/02/16 13:22:22  cgruber
86   * Check in all sources in eclipse-friendly maven-enabled packages.
87   *
88   * Revision 1.1  2003/01/07 20:48:29  mpowers
89   * Implemented WOSessionStore and WOServletSessionStore.
90   *
91   *
92   */
93