|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.appserver.WOSessionStore
WOSessionStore, an abstract superclass, offers an object abstraction for
storing client state per session. The application object (WOApplication)
uses an instance of a concrete WOSessionStore subclass to implement a
strategy for storing and retrieving session state. Set the
WOSessionStore during application initialization through WOApplication's
setSessionStore
method.
An application first creates a session (WOSession) when it receives a
request without a session ID. When this first request has been handled,
the application stores the WOSession object under a randomly generated
session ID by invoking its own saveSessionForContext
method.
This method by default forwards the method to the chosen WOSessionStore
and that WOSessionStore takes care of the details of saving session state.
When the next request comes in for that session, the application restores
the session by sending itself restoreSessionWithID
, which by
default is forwarded to the application's WOSessionStore. The
WOSessionStore then asks the WOContext of the transaction for the session
ID of the session. Based on the implementation of the WOSessionStore, the
session object is located and returned.
There is one subclass of WOSessionStore implemented for the developer's
convenience. A server WOSessionStore (the default) stores session state
in the server, in application memory. The serverSessionStore
method returns this WOSessionStore.
You can create a custom session store by making a subclass of WOSessionStore.
The subclass should properly implement the saveSessionForContext
and
restoreSessionWithID
methods and should have a public method that
the application object can use to obtain an instance. Some interesting session stores
could be:
saveSessionForContext(WOContext)
,
restoreSessionWithID(String, WORequest)
,
serverSessionStore()
,
WOApplication.setSessionStore(WOSessionStore)
Constructor Summary | |
WOSessionStore()
Creates a default WOSessionStore. |
Method Summary | |
void |
checkInSessionForContext(WOContext context)
Checks in the session in context so that pending (and future) requests for
the same session may proceed. |
WOSession |
checkOutSessionWithID(String id,
WORequest aRequest)
Checks out a session using id , which is the session id associated with
the session. |
void |
finalize()
Inherited finalize() method from java.lang.Object . |
abstract WOSession |
removeSessionWithID(String sessionID)
Removes a WOSession instance from storage in order to make it eligible for garbage collection. |
abstract WOSession |
restoreSessionWithID(String sessionID,
WORequest aRequest)
Restores a WOSession associated with sessionID from storage. |
abstract void |
saveSessionForContext(WOContext context)
Saves the current WOSession in context into storage. |
static WOSessionStore |
serverSessionStore()
Gets the default WOSessionStore object that saves and restores session states using application memory. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WOSessionStore()
Method Detail |
public final void checkInSessionForContext(WOContext context)
context
so that pending (and future) requests for
the same session may proceed. This method is called by WOApplication to save
the session even if the session was not previously checked out via
checkOutSessionWithID
(that is, the session is a new session which
was just created and, therefore, not restored).
Internally, this method calls saveSessionForContext
(implemented in the
concrete subclass) to save the session in context
using whatever storage technique is supported by the subclass.
context
- the WOContext to retrieve the current session to be checked insaveSessionForContext(WOContext)
,
checkOutSessionWithID(String, WORequest)
public final WOSession checkOutSessionWithID(String id, WORequest aRequest)
id
, which is the session id associated with
the session. This method calls restoreSessionWithID
(implemented in the
concrete subclass) to do the actual session restoration using whatever
storage technique is supported by the subclass. If the session is located
and restored, this method ensures that simultaneous access to the same session is
precluded. The session should have been checked in using
checkInSessionForContext
.
id
- the session id associated with the session to be checked outaRequest
- the input HTTP request for the session restoration
null
otherwiserestoreSessionWithID(String, WORequest)
,
checkInSessionForContext(WOContext)
public void finalize() throws Throwable
java.lang.Object
.
the
- Exception raised by this method
Throwable
public abstract WOSession removeSessionWithID(String sessionID)
This method should be implemented by concrete WOSessionStore subclasses.
sessionID
- the session id associated with the WOSession to be removed
null
otherwisepublic abstract WOSession restoreSessionWithID(String sessionID, WORequest aRequest)
sessionID
from storage. This method
is called from checkOutSessionWithID
and is to be implemented
by a concrete WOSessionStore subclass. The subclass is free to decide on the kind of
suitable storage and the algorithm for restoration.
The default implementation does nothing.
sessionID
- the session id associated with the WOSession to be restoredaRequest
- the input HTTP request for session restoration
null
otherwisecheckOutSessionWithID(String, WORequest)
public abstract void saveSessionForContext(WOContext context)
context
into storage. This method
is called from checkInSessionForContext
and is to implemented
by a concrete WOSessionStore subclass. The subclass is free to decided on the kind of
suitable storage and the algorithm for saving.
The default implementation does nothing.
context
- the WOContext to retrieve the current session to be savedcheckInSessionForContext(WOContext)
public static WOSessionStore serverSessionStore()
State storage in the server's application memory is the easiest strategy and is usually good enough for most general use. You can also easily manage the amount of storage consumed by setting session timeouts, limiting the size of the page-instance cache, and page uniquing.
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |