Package org.apache.wicket.session
Interface ISessionStore
-
- All Known Implementing Classes:
HttpSessionStore
,MockSessionStore
public interface ISessionStore
The actual store that is used bySession
to store its attributes.This class is intended for internal framework use.
- Author:
- Eelco Hillenius, Johan Compagner, Matej Knopp
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ISessionStore.BindListener
Listener invoked when session is bound.static interface
ISessionStore.UnboundListener
Listener invoked when session is unbound.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
bind(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(Request request, Session session)
Flushes the session.Serializable
getAttribute(Request request, String name)
Gets the attribute value with the given nameList<String>
getAttributeNames(Request request)
Set<ISessionStore.BindListener>
getBindListeners()
String
getSessionId(Request request, boolean create)
Get the session id for the provided request.Set<ISessionStore.UnboundListener>
getUnboundListener()
void
invalidate(Request request)
Invalidates the session.Session
lookup(Request request)
Retrieves the session for the provided request from this facade.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(Request request, String name)
Removes the attribute with the given name.void
setAttribute(Request request, String name, Serializable value)
Adds or replaces the attribute with the given name and value.void
unregisterBindListener(ISessionStore.BindListener listener)
Unregisters listener invoked when session is bound.void
unregisterUnboundListener(ISessionStore.UnboundListener listener)
Unregisters listener invoked when session is unbound.
-
-
-
Method Detail
-
getAttribute
Serializable getAttribute(Request request, String name)
Gets the attribute value with the given name- Parameters:
request
- the current requestname
- The name of the attribute to store- Returns:
- The value of the attribute
-
getAttributeNames
List<String> getAttributeNames(Request request)
- Parameters:
request
- the current request- Returns:
- List of attributes for this session
-
setAttribute
void setAttribute(Request request, String name, Serializable value)
Adds or replaces the attribute with the given name and value.- Parameters:
request
- the current requestname
- the name of the attributevalue
- the value of the attribute
-
removeAttribute
void removeAttribute(Request request, String name)
Removes the attribute with the given name.- Parameters:
request
- the current requestname
- the name of the attribute to remove
-
invalidate
void invalidate(Request request)
Invalidates the session.- Parameters:
request
- the current request
-
getSessionId
String getSessionId(Request request, boolean create)
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.- Parameters:
request
- The requestcreate
- Whether to create an actual session (typically an instance ofHttpSession
) 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
-
lookup
Session lookup(Request request)
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
bind(Request, Session)
right after that.- Parameters:
request
- The current request- Returns:
- The session for the provided request or null if the session was not bound
-
bind
void bind(Request request, Session newSession)
Adds the provided new session to this facade using the provided request.- Parameters:
request
- The request that triggered making a new sessionnewSession
- The new session
-
flushSession
void flushSession(Request request, Session session)
Flushes the session. Flushing the session generally means setting the attribute with the value of the current session. Some servlet containers use the setAttribute() as a signal that the value is dirty and needs to be replicated. Essentially this call comes down to:String attr=getSessionAttributeName(); Session session=getAttribute(attr); setAttribute(attr, session);
If the session is not yet bound it will be.- Parameters:
request
- current requestsession
- session to be flushed
-
destroy
void destroy()
Called when the WebApplication is destroyed.
-
registerUnboundListener
void registerUnboundListener(ISessionStore.UnboundListener listener)
Registers listener invoked when session is unbound.- Parameters:
listener
-
-
unregisterUnboundListener
void unregisterUnboundListener(ISessionStore.UnboundListener listener)
Unregisters listener invoked when session is unbound.- Parameters:
listener
-
-
getUnboundListener
Set<ISessionStore.UnboundListener> getUnboundListener()
- Returns:
- The list of registered unbound listeners
-
registerBindListener
void registerBindListener(ISessionStore.BindListener listener)
Registers listener invoked when session is bound.- Parameters:
listener
-
-
unregisterBindListener
void unregisterBindListener(ISessionStore.BindListener listener)
Unregisters listener invoked when session is bound.- Parameters:
listener
-
-
getBindListeners
Set<ISessionStore.BindListener> getBindListeners()
- Returns:
- The list of registered bind listeners
-
-