wicket.protocol.http.portlet
Class PortletSessionStore

java.lang.Object
  extended by wicket.protocol.http.portlet.PortletSessionStore
All Implemented Interfaces:
ISessionStore

public class PortletSessionStore
extends java.lang.Object
implements ISessionStore

Abstract implementation of ISessionStore that works with portlets

Author:
Janne Hietamäki, jcompagner, Eelco Hillenius

Field Summary
protected  PortletApplication application
           
protected static org.apache.commons.logging.Log log
          log.
 
Constructor Summary
PortletSessionStore()
          Construct.
 
Method Summary
 void bind(Request request, Session newSession)
          Adds the provided new session to this facade using the provided request.
 java.lang.Object getAttribute(Request request, java.lang.String name)
          Gets the attribute value with the given name
 java.util.List getAttributeNames(Request request)
           
protected  javax.portlet.PortletSession getPortletSession(WicketPortletRequest request)
          Gets the underlying HttpSession object or null.
 java.lang.String getSessionId(Request request)
          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.
protected  void onBind(Request request, Session newSession)
          Template method that is called when a session is being bound to the session store.
protected  void onUnbind(java.lang.String sessionId)
          Template method that is called when the session is being detached from the store, which typically happens when the portlet session was invalidated.
 void removeAttribute(Request request, java.lang.String name)
          Removes the attribute with the given name.
 void setAttribute(Request request, java.lang.String name, java.lang.Object value)
          Adds or replaces the attribute with the given name and value.
protected  WicketPortletRequest toPortletRequest(Request request)
          Cast Request to WebRequest.
 void unbind(java.lang.String sessionId)
          Adds the provided new session to this facade using the provided request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
log.


application

protected final PortletApplication application
Constructor Detail

PortletSessionStore

public PortletSessionStore()
Construct.

Method Detail

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)

getSessionId

public final java.lang.String getSessionId(Request request)
Description copied from interface: ISessionStore
Get the session id for the provided request.

Specified by:
getSessionId in interface ISessionStore
Parameters:
request - The request
Returns:
The session id for the provided request
See Also:
ISessionStore.getSessionId(wicket.Request)

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 sesion
newSession - The new session
See Also:
ISessionStore.bind(wicket.Request, wicket.Session)

unbind

public final void unbind(java.lang.String sessionId)
Description copied from interface: ISessionStore
Adds the provided new session to this facade using the provided request.

Specified by:
unbind in interface ISessionStore
Parameters:
sessionId - The SessionId that must be unbinded.
See Also:
ISessionStore.unbind(java.lang.String)

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(wicket.Request)

toPortletRequest

protected final WicketPortletRequest toPortletRequest(Request request)
Cast Request to WebRequest.

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

getPortletSession

protected final javax.portlet.PortletSession getPortletSession(WicketPortletRequest 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 funcionality which causes you to depend on this directly.

Parameters:
request -
Returns:
The underlying PortletSession object.

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(java.lang.String sessionId)
Template method that is called when the session is being detached from the store, which typically happens when the portlet session was invalidated.

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

setAttribute

public void setAttribute(Request request,
                         java.lang.String name,
                         java.lang.Object value)
Description copied from interface: ISessionStore
Adds or replaces the attribute with the given name and value.

Specified by:
setAttribute in interface ISessionStore
Parameters:
request - the current request
name - the name of the attribute
value - the value of the attribute
See Also:
ISessionStore.setAttribute(Request,java.lang.String, java.lang.Object)

getAttribute

public java.lang.Object getAttribute(Request request,
                                     java.lang.String name)
Description copied from interface: ISessionStore
Gets the attribute value with the given name

Specified by:
getAttribute in interface ISessionStore
Parameters:
request - the current request
name - The name of the attribute to store
Returns:
The value of the attribute
See Also:
ISessionStore.getAttribute(wicket.Request, java.lang.String)

removeAttribute

public void removeAttribute(Request request,
                            java.lang.String name)
Description copied from interface: ISessionStore
Removes the attribute with the given name.

Specified by:
removeAttribute in interface ISessionStore
Parameters:
request - the current request
name - the name of the attribute to remove
See Also:
ISessionStore.removeAttribute(Request,java.lang.String)

getAttributeNames

public java.util.List getAttributeNames(Request request)
Specified by:
getAttributeNames in interface ISessionStore
Parameters:
request - the current request
Returns:
List of attributes for this session
See Also:
ISessionStore.getAttributeNames(Request)


Copyright © 2004-2007 Wicket developers. All Rights Reserved.