|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.Session
public abstract class Session
Holds information about a user session, including some fixed number of most recent pages (and all their nested component information).
RequestCycle
can be retrieved by
calling RequestCycle#getSession()
.
Component.getSession()
. As currently implemented,
each Component does not itself have a reference to the session that contains it. However, the
Page component at the root of the containment hierarchy does have a reference to the Session that
holds the Page. So Component.getSession()
traverses the component hierarchy to the root
Page and then calls Component.getSession()
.
setLocale(Locale)
. The Locale for a Session
determines how localized resources are found and loaded.
Application
for details). To
discourage non-typesafe access to Session properties, no setProperty() or getProperty() method is
provided. In a clustered environment, you should take care to call the dirty() method when you
change a property on your own. This way the session will be reset again in the http session so
that the http session knows the session is changed.
IClassResolver
)
implementation that is used to locate classes for components such as pages.
IPageFactory
is used to
instantiate pages for the session.
Field Summary | |
---|---|
protected ClientInfo |
clientInfo
Cached instance of agent info which is typically designated by calling RequestCycle#newClientInfo() . |
static java.lang.String |
SESSION_ATTRIBUTE_NAME
Name of session attribute under which this session is stored |
Constructor Summary | |
---|---|
Session(Request request)
Constructor. |
Method Summary | ||
---|---|---|
void |
bind()
Force binding this session to the application's session store if not
already done so. |
|
abstract void |
cleanupFeedbackMessages()
Cleans up all rendered feedback messages and any unrendered, dangling feedback messages there may be left after that. |
|
void |
clear()
Removes all pages from the session. |
|
void |
debug(java.io.Serializable message)
Registers an debug feedback message for this session |
|
void |
detach()
Any detach logic for session subclasses. |
|
void |
dirty()
Marks session state as dirty so that it will be flushed at the end of the request. |
|
void |
error(java.io.Serializable message)
Registers an error feedback message for this session |
|
static boolean |
exists()
Checks if the Session threadlocal is set in this thread |
|
void |
fatal(java.io.Serializable message)
Registers an fatal feedback message for this session |
|
static Session |
get()
Returns session associated to current thread. |
|
Application |
getApplication()
Get the application that is currently working with this session. |
|
java.io.Serializable |
getAttribute(java.lang.String name)
Gets the attribute value with the given name |
|
protected java.util.List<java.lang.String> |
getAttributeNames()
|
|
IAuthorizationStrategy |
getAuthorizationStrategy()
|
|
IClassResolver |
getClassResolver()
|
|
abstract ClientInfo |
getClientInfo()
Gets the client info object for this session. |
|
FeedbackMessages |
getFeedbackMessages()
Gets feedback messages stored in session |
|
java.lang.String |
getId()
Gets the unique id for this session from the underlying SessionStore. |
|
java.util.Locale |
getLocale()
Get this session's locale. |
|
|
getMetaData(MetaDataKey<M> key)
Gets metadata for this session using the given key. |
|
IPageFactory |
getPageFactory()
|
|
IPageManager |
getPageManager()
Returns the IPageManager instance. |
|
protected ISessionStore |
getSessionStore()
Gets the session store. |
|
long |
getSizeInBytes()
|
|
java.lang.String |
getStyle()
Get the style (see Session ). |
|
void |
info(java.io.Serializable message)
Registers an informational feedback message for this session |
|
void |
internalDetach()
NOT PART OF PUBLIC API, DO NOT CALL Detaches internal state of Session |
|
void |
invalidate()
Invalidates this session at the end of the current request. |
|
void |
invalidateNow()
Invalidates this session immediately. |
|
protected boolean |
isCurrentRequestValid(RequestCycle lockedRequestCycle)
When a regular request on certain page with certain version is being processed, we don't allow ajax requests to same page and version. |
|
boolean |
isSessionInvalidated()
Whether the session is invalid now, or will be invalidated by the end of the request. |
|
boolean |
isTemporary()
Whether this session is temporary. |
|
int |
nextPageId()
|
|
int |
nextSequenceValue()
Retrieves the next available session-unique value |
|
void |
onEvent(IEvent<?> event)
Called when an event is sent to this sink |
|
protected void |
removeAttribute(java.lang.String name)
Removes the attribute with the given name. |
|
void |
replaceSession()
Replaces the underlying (Web)Session, invalidating the current one and creating a new one. |
|
void |
setAttribute(java.lang.String name,
java.io.Serializable value)
Adds or replaces the attribute with the given name and value. |
|
void |
setClientInfo(ClientInfo clientInfo)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
|
void |
setLocale(java.util.Locale locale)
Set the locale for this session. |
|
void |
setMetaData(MetaDataKey<?> key,
java.io.Serializable object)
Sets the metadata for this session using the given key. |
|
Session |
setStyle(java.lang.String style)
Set the style (see Session ). |
|
void |
success(java.io.Serializable message)
Registers an success feedback message for this session |
|
void |
warn(java.io.Serializable message)
Registers a warning feedback message for this session |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SESSION_ATTRIBUTE_NAME
protected ClientInfo clientInfo
RequestCycle#newClientInfo()
.
Constructor Detail |
---|
public Session(Request request)
RequestCycle
is not available until this constructor returns.
request
- The current requestMethod Detail |
---|
public static boolean exists()
Session
threadlocal is set in this thread
get()
can return the instance of session, false otherwisepublic static Session get()
public final void bind()
session store
if not
already done so.
A Wicket application can operate in a session-less mode as long as stateless pages are used.
Session objects will be then created for each request, but they will only live for that
request. You can recognize temporary sessions by calling isTemporary()
which
basically checks whether the session's id is null. Hence, temporary sessions have no session
id.
By calling this method, the session will be bound (made not-temporary) if it was not bound
yet. It is useful for cases where you want to be absolutely sure this session object will be
available in next requests. If the session was already bound (
returns a session
), this call will be a noop.
public abstract void cleanupFeedbackMessages()
public final void clear()
public final void error(java.io.Serializable message)
message
- The feedback messagepublic final void fatal(java.io.Serializable message)
message
- The feedback messagepublic final void debug(java.io.Serializable message)
message
- The feedback messagepublic final Application getApplication()
public IAuthorizationStrategy getAuthorizationStrategy()
public final IClassResolver getClassResolver()
public abstract ClientInfo getClientInfo()
setClientInfo(ClientInfo)
)
client info object.
public final FeedbackMessages getFeedbackMessages()
public final java.lang.String getId()
null
if a concrete session is not yet created.
public java.util.Locale getLocale()
public final <M extends java.io.Serializable> M getMetaData(MetaDataKey<M> key)
M
- The type of the metadata.key
- The key for the data
MetaDataKey
protected boolean isCurrentRequestValid(RequestCycle lockedRequestCycle)
lockedRequestCycle
-
public IPageFactory getPageFactory()
public final long getSizeInBytes()
public final java.lang.String getStyle()
public final void info(java.io.Serializable message)
message
- The feedback messagepublic final void success(java.io.Serializable message)
message
- The feedback messagepublic void invalidate()
public void invalidateNow()
public void replaceSession()
ISessionStore.invalidate(Request)
and bind()
Call upon login to protect against session fixation.
public final boolean isSessionInvalidated()
invalidate()
,
invalidateNow()
public final boolean isTemporary()
public final void setClientInfo(ClientInfo clientInfo)
Sets the client info object for this session. This will only work when
getClientInfo()
is not overridden.
clientInfo
- the client info objectpublic void setLocale(java.util.Locale locale)
locale
- New localepublic final void setMetaData(MetaDataKey<?> key, java.io.Serializable object)
MetaDataKey
.
key
- The singleton key for the metadataobject
- The metadata object
java.lang.IllegalArgumentException
MetaDataKey
public final Session setStyle(java.lang.String style)
Session
).
style
- The style to set.
public final void warn(java.io.Serializable message)
message
- The feedback messagepublic void detach()
public void internalDetach()
Session
public final void dirty()
public final java.io.Serializable getAttribute(java.lang.String name)
name
- The name of the attribute to store
protected final java.util.List<java.lang.String> getAttributeNames()
protected ISessionStore getSessionStore()
protected final void removeAttribute(java.lang.String name)
name
- the name of the attribute to removepublic final void setAttribute(java.lang.String name, java.io.Serializable value)
name
- The name of the attributevalue
- The value of the attributepublic int nextSequenceValue()
public int nextPageId()
public final IPageManager getPageManager()
IPageManager
instance.
IPageManager
instance.#newPageManager()
public void onEvent(IEvent<?> event)
onEvent
in interface IEventSink
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |