public class HttpSessionStore extends Object implements ISessionStore
ISessionStore that works with web applications and provides some
specific http servlet/ session related functionality.| Modifier and Type | Class and Description |
|---|---|
protected static class |
HttpSessionStore.SessionBindingListener
Reacts on unbinding from the session by cleaning up the session related data.
|
ISessionStore.BindListener, ISessionStore.UnboundListener| Constructor and Description |
|---|
HttpSessionStore() |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(org.apache.wicket.request.Request request,
Session newSession)
Adds the provided new session to this facade using the provided request.
|
void |
destroy()
Called when the WebApplication is destroyed.
|
void |
flushSession(org.apache.wicket.request.Request request,
Session session)
Flushes the session.
|
Serializable |
getAttribute(org.apache.wicket.request.Request request,
String name)
Gets the attribute value with the given name
|
List<String> |
getAttributeNames(org.apache.wicket.request.Request request) |
Set<ISessionStore.BindListener> |
getBindListeners() |
protected javax.servlet.http.HttpServletRequest |
getHttpServletRequest(org.apache.wicket.request.Request request) |
String |
getSessionId(org.apache.wicket.request.Request request,
boolean create)
Get the session id for the provided request.
|
Set<ISessionStore.UnboundListener> |
getUnboundListener() |
protected Session |
getWicketSession(org.apache.wicket.request.Request request)
Reads the Wicket
Session from the HttpSession's attribute |
void |
invalidate(org.apache.wicket.request.Request request)
Invalidates the session.
|
Session |
lookup(org.apache.wicket.request.Request request)
Retrieves the session for the provided request from this facade.
|
protected void |
onBind(org.apache.wicket.request.Request request,
Session newSession)
Template method that is called when a session is being bound to the session store.
|
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. |
void |
registerBindListener(ISessionStore.BindListener listener)
Registers listener invoked when session is bound.
|
void |
registerUnboundListener(ISessionStore.UnboundListener listener)
Registers listener invoked when session is unbound.
|
void |
removeAttribute(org.apache.wicket.request.Request request,
String name)
Removes the attribute with the given name.
|
void |
setAttribute(org.apache.wicket.request.Request request,
String name,
Serializable value)
Adds or replaces the attribute with the given name and value.
|
protected void |
setWicketSession(org.apache.wicket.request.Request request,
Session session)
Stores the Wicket
Session in an attribute in the HttpSession |
void |
unregisterBindListener(ISessionStore.BindListener listener)
Unregisters listener invoked when session is bound.
|
void |
unregisterUnboundListener(ISessionStore.UnboundListener listener)
Unregisters listener invoked when session is unbound.
|
protected final javax.servlet.http.HttpServletRequest getHttpServletRequest(org.apache.wicket.request.Request request)
request - The Wicket requestpublic final void bind(org.apache.wicket.request.Request request,
Session newSession)
ISessionStorebind in interface ISessionStorerequest - The request that triggered making a new sessionnewSession - The new sessionpublic void flushSession(org.apache.wicket.request.Request request,
Session session)
ISessionStore
String attr=getSessionAttributeName();
Session session=getAttribute(attr);
setAttribute(attr, session);
If the session is not yet bound it will be.flushSession in interface ISessionStorerequest - current requestsession - session to be flushedpublic void destroy()
ISessionStoredestroy in interface ISessionStorepublic String getSessionId(org.apache.wicket.request.Request request, boolean create)
ISessionStoregetSessionId in interface ISessionStorerequest - The requestcreate - Whether to create an actual session (typically an instance of HttpSession)
when not already done sopublic final void invalidate(org.apache.wicket.request.Request request)
ISessionStoreinvalidate in interface ISessionStorerequest - the current requestpublic final Session lookup(org.apache.wicket.request.Request request)
ISessionStore
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.
lookup in interface ISessionStorerequest - The current requestprotected Session getWicketSession(org.apache.wicket.request.Request request)
Session from the HttpSession's attributerequest - The Wicket requestnullprotected void setWicketSession(org.apache.wicket.request.Request request,
Session session)
Session in an attribute in the HttpSessionrequest - The Wicket requestsession - The Wicket sessionprotected void onBind(org.apache.wicket.request.Request request,
Session newSession)
ISessionStore.setAttribute(Request, String, Serializable) with key
Session.SESSION_ATTRIBUTE_NAME.request - The requestnewSession - The new sessionprotected void onUnbind(String sessionId)
HttpSession was invalidated.sessionId - The session id of the session that was invalidated.public final Serializable getAttribute(org.apache.wicket.request.Request request, String name)
ISessionStoregetAttribute in interface ISessionStorerequest - the current requestname - The name of the attribute to storepublic final List<String> getAttributeNames(org.apache.wicket.request.Request request)
getAttributeNames in interface ISessionStorerequest - the current requestpublic final void removeAttribute(org.apache.wicket.request.Request request,
String name)
ISessionStoreremoveAttribute in interface ISessionStorerequest - the current requestname - the name of the attribute to removepublic final void setAttribute(org.apache.wicket.request.Request request,
String name,
Serializable value)
ISessionStoresetAttribute in interface ISessionStorerequest - the current requestname - the name of the attributevalue - the value of the attributepublic final void registerUnboundListener(ISessionStore.UnboundListener listener)
ISessionStoreregisterUnboundListener in interface ISessionStorepublic final void unregisterUnboundListener(ISessionStore.UnboundListener listener)
ISessionStoreunregisterUnboundListener in interface ISessionStorepublic final Set<ISessionStore.UnboundListener> getUnboundListener()
getUnboundListener in interface ISessionStorepublic void registerBindListener(ISessionStore.BindListener listener)
registerBindListener in interface ISessionStorelistener - public void unregisterBindListener(ISessionStore.BindListener listener)
unregisterBindListener in interface ISessionStorelistener - public Set<ISessionStore.BindListener> getBindListeners()
getBindListeners in interface ISessionStoreCopyright © 2006–2018 Apache Software Foundation. All rights reserved.