org.apache.wicket.protocol.http
Class AbstractHttpSessionStore

java.lang.Object
  extended by org.apache.wicket.protocol.http.AbstractHttpSessionStore
All Implemented Interfaces:
ISessionStore
Direct Known Subclasses:
HttpSessionStore

public abstract class AbstractHttpSessionStore
extends Object
implements ISessionStore

Abstract implementation of ISessionStore that works with web applications and that provided some specific http servlet/ session related functionality.

Author:
jcompagner, Eelco Hillenius

Nested Class Summary
protected static class AbstractHttpSessionStore.SessionBindingListener
          Reacts on unbinding from the session by cleaning up the session related application data.
 
Field Summary
protected  WebApplication application
          The web application for this store.
 
Constructor Summary
AbstractHttpSessionStore(Application application)
          Construct.
 
Method Summary
 void bind(Request request, Session newSession)
          Adds the provided new session to this facade using the provided request.
 IPageMap createPageMap(String name, Session session)
          Deprecated. remove after deprecation release
 void destroy()
          Called when the WebApplication is destroyed.
protected  javax.servlet.http.HttpSession getHttpSession(WebRequest request)
          Gets the underlying HttpSession object or null.
protected  javax.servlet.http.HttpSession getHttpSession(WebRequest request, boolean create)
          Gets the underlying HttpSession object.
 String getSessionId(Request request, boolean create)
          Get the session id for the provided request.
 void invalidate(Request request)
          Invalidates the session.
 Session lookup(Request request)
          Retrieves the session for the provided request from this facade.
 IPageVersionManager newVersionManager(Page page)
           
 void onBeginRequest(Request request)
          Noop implementation.
protected  void onBind(Request request, Session newSession)
          Template method that is called when a session is being bound to the session store.
 void onEndRequest(Request request)
          Noop implementation.
protected  void onUnbind(String sessionId)
          Template method that is called when the session is being detached from the store, which typically happens when the httpsession was invalidated.
protected  WebRequest toWebRequest(Request request)
          Cast Request to WebRequest.
 void unbind(String sessionId)
          Removes a session from this facade
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.session.ISessionStore
createPageMap, getAttribute, getAttributeNames, removeAttribute, setAttribute
 

Field Detail

application

protected final WebApplication application
The web application for this store. Is never null.

Constructor Detail

AbstractHttpSessionStore

public AbstractHttpSessionStore(Application application)
Construct.

Parameters:
application - The application to construct this store for
Method Detail

bind

public final void bind(Request request,
                       Session newSession)
Description copied from interface: ISessionStore
Adds the provided new session to this facade using the provided request.

Specified by:
bind in interface ISessionStore
Parameters:
request - The request that triggered making a new session
newSession - The new session
See Also:
ISessionStore.bind(org.apache.wicket.Request, org.apache.wicket.Session)

createPageMap

@Deprecated
public final IPageMap createPageMap(String name,
                                               Session session)
Deprecated. remove after deprecation release

DO NOT USE.

Parameters:
name -
session -
Returns:
created pagemap

destroy

public void destroy()
Description copied from interface: ISessionStore
Called when the WebApplication is destroyed.

Specified by:
destroy in interface ISessionStore
See Also:
ISessionStore.destroy()

getSessionId

public String getSessionId(Request request,
                           boolean create)
Description copied from interface: ISessionStore
Get the session id for the provided request. If create is false and the creation of the actual session is deferred, this method should return null to reflect it doesn't have one.

Specified by:
getSessionId in interface ISessionStore
Parameters:
request - The request
create - Whether to create an actual session (typically an instance of HttpSession) when not already done so
Returns:
The session id for the provided request, possibly null if create is false and the creation of the actual session was deferred
See Also:
ISessionStore.getSessionId(org.apache.wicket.Request, boolean)

invalidate

public final void invalidate(Request request)
Description copied from interface: ISessionStore
Invalidates the session.

Specified by:
invalidate in interface ISessionStore
Parameters:
request - the current request
See Also:
ISessionStore.invalidate(Request)

lookup

public Session lookup(Request request)
Description copied from interface: ISessionStore
Retrieves the session for the provided request from this facade.

This method should return null if it is not bound yet, so that Wicket can recognize that it should create a session and call ISessionStore.bind(Request, Session) right after that.

Specified by:
lookup in interface ISessionStore
Parameters:
request - The current request
Returns:
The session for the provided request or null if the session was not bound
See Also:
ISessionStore.lookup(org.apache.wicket.Request)

newVersionManager

public IPageVersionManager newVersionManager(Page page)
Specified by:
newVersionManager in interface ISessionStore
Parameters:
page - The page for which this version manager must be created
Returns:
A instance of a IPageVersionManager that the page will use.
See Also:
ISessionStore.newVersionManager(Page)

onBeginRequest

public void onBeginRequest(Request request)
Noop implementation. Clients can override this method.

Specified by:
onBeginRequest in interface ISessionStore
Parameters:
request - The request object
See Also:
ISessionStore.onBeginRequest(org.apache.wicket.Request)

onEndRequest

public void onEndRequest(Request request)
Noop implementation. Clients can override this method.

Specified by:
onEndRequest in interface ISessionStore
Parameters:
request - The request
See Also:
ISessionStore.onEndRequest(org.apache.wicket.Request)

unbind

public final void unbind(String sessionId)
Description copied from interface: ISessionStore
Removes a session from this facade

Specified by:
unbind in interface ISessionStore
Parameters:
sessionId - The id of the session that must be unbound.
See Also:
ISessionStore.unbind(java.lang.String)

getHttpSession

protected final javax.servlet.http.HttpSession getHttpSession(WebRequest request)
Gets the underlying HttpSession object or null.

WARNING: it is a bad idea to depend on the http session object directly. Please use the classes and methods that are exposed by Wicket instead. Send an email to the mailing list in case it is not clear how to do things or you think you miss functionality which causes you to depend on this directly.

Parameters:
request -
Returns:
The underlying HttpSession object.

getHttpSession

protected final javax.servlet.http.HttpSession getHttpSession(WebRequest request,
                                                              boolean create)
Gets the underlying HttpSession object. If create is set to true a new instance of http session will be created if one does not already exist.

WARNING: it is a bad idea to depend on the http session object directly. Please use the classes and methods that are exposed by Wicket instead. Send an email to the mailing list in case it is not clear how to do things or you think you miss functionality which causes you to depend on this directly.

Parameters:
request -
Returns:
The underlying HttpSession object, or null

onBind

protected void onBind(Request request,
                      Session newSession)
Template method that is called when a session is being bound to the session store. It is called before the session object itself is added to this store (which is done by calling ISessionStore.setAttribute(Request, String, Object) with key Session.SESSION_ATTRIBUTE_NAME.

Parameters:
request - The request
newSession - The new session

onUnbind

protected void onUnbind(String sessionId)
Template method that is called when the session is being detached from the store, which typically happens when the httpsession was invalidated.

Parameters:
sessionId - The session id of the session that was invalidated.

toWebRequest

protected final WebRequest toWebRequest(Request request)
Cast Request to WebRequest.

Parameters:
request - The request to cast
Returns:
The web request


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.