|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 or youre 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.
| Nested Class Summary | |
|---|---|
static interface |
Session.IPageMapVisitor
Visitor interface for visiting page maps |
static class |
Session.PageMapAccessMetaData
meta data for recording map map access. |
| Field Summary | |
|---|---|
static IFeedbackMessageFilter |
MESSAGES_FOR_COMPONENTS
Filter that returns all component scoped messages ( FeedbackMessage.getReporter() !=
null). |
static MetaDataKey |
PAGEMAP_ACCESS_MDK
meta data key for missing body tags logging. |
static java.lang.String |
SESSION_ATTRIBUTE_NAME
Name of session attribute under which this session is stored |
| Constructor Summary | |
|---|---|
protected |
Session(Application application,
Request request)
Deprecated. Use #Session(Request) |
|
Session(Request request)
Constructor. |
| Method Summary | |
|---|---|
protected void |
attach()
Any attach logic for session subclasses. |
void |
bind()
Force binding this session to the application's session store if not already done so. |
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. |
IPageMap |
createAutoPageMap()
Automatically creates a page map, giving it a session unique name. |
java.lang.String |
createAutoPageMapName()
With this call you can create a pagemap name but not create the pagemap itself already. |
protected int |
currentCreateAutoPageMapCounter()
|
protected 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.lang.String message)
Registers an error feedback message for this session |
static boolean |
exists()
Checks if the Session threadlocal is set in this thread |
static Session |
findOrCreate()
Locate the session for the client of this request in the ISessionStore or create a new one and attach it when none could
be located and sets it as the current instance for this thread. |
static Session |
get()
Get the session for the calling thread. |
Application |
getApplication()
Get the application that is currently working with this session. |
protected java.lang.Object |
getAttribute(java.lang.String name)
Gets the attribute value with the given name |
protected java.util.List |
getAttributeNames()
|
IAuthorizationStrategy |
getAuthorizationStrategy()
|
protected java.lang.String |
getAutoPageMapNamePrefix()
|
protected java.lang.String |
getAutoPageMapNameSuffix()
|
IClassResolver |
getClassResolver()
|
ClientInfo |
getClientInfo()
Gets the client info object for this session. |
IPageMap |
getDefaultPageMap()
|
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. |
java.io.Serializable |
getMetaData(MetaDataKey key)
Gets metadata for this session using the given key. |
Page |
getPage(int pageId,
int versionNumber)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
Page |
getPage(java.lang.String pageMapName,
java.lang.String path,
int versionNumber)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
IPageFactory |
getPageFactory()
|
IPageFactory |
getPageFactory(Page page)
|
java.util.List |
getPageMaps()
|
protected ISessionStore |
getSessionStore()
Gets the session store. |
long |
getSizeInBytes()
|
java.lang.String |
getStyle()
Get the style (see Session). |
protected void |
incrementCreateAutoPageMapCounter()
|
void |
info(java.lang.String message)
Registers an informational feedback message for this 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. |
IPageMap |
newPageMap(java.lang.String name)
Creates a new page map with a given name |
protected int |
nextPageId()
|
IPageMap |
pageMapForName(java.lang.String pageMapName,
boolean autoCreate)
Gets a page map for the given name, automatically creating it if need be. |
protected void |
removeAttribute(java.lang.String name)
Removes the attribute with the given name. |
void |
removePageMap(IPageMap pageMap)
|
static void |
set(Session session)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
void |
setApplication(Application application)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
setAttribute(java.lang.String name,
java.lang.Object 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 |
touch(Page page)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
static void |
unset()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
update()
Deprecated. obsolete method (was meant for internal book keeping really). Clients should override detach() instead. |
void |
visitPageMaps(Session.IPageMapVisitor visitor)
|
void |
warn(java.lang.String 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 IFeedbackMessageFilter MESSAGES_FOR_COMPONENTS
FeedbackMessage.getReporter() !=
null).
public static final MetaDataKey PAGEMAP_ACCESS_MDK
public static final java.lang.String SESSION_ATTRIBUTE_NAME
| Constructor Detail |
|---|
public Session(Request request)
RequestCycle is not available until this
constructor returns.
request - The current requestprotected Session(Application application, Request request)
RequestCycle is not available until this
constructor returns.
application - The application that this is a session ofrequest - The current request| Method Detail |
|---|
public static boolean exists()
Session threadlocal is set in this thread
get() can return the instance of session,
false otherwisepublic static final Session findOrCreate()
ISessionStore or create a new one and attach it when none could
be located and sets it as the current instance for this thread.
Typically, clients never touch this method, but rather use
get(), which does the locating implicitly when not yet
set as a thread local.
public static Session get()
public static void set(Session session)
Sets session for calling thread. Also triggers attach() being
called.
session - The sessionpublic static void unset()
Clears the session for calling thread.
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 void cleanupFeedbackMessages()
public final void clear()
public final IPageMap createAutoPageMap()
protected int currentCreateAutoPageMapCounter()
protected void incrementCreateAutoPageMapCounter()
public final java.lang.String createAutoPageMapName()
protected java.lang.String getAutoPageMapNamePrefix()
protected java.lang.String getAutoPageMapNameSuffix()
public final void error(java.lang.String message)
message - The feedback messagepublic final Application getApplication()
public IAuthorizationStrategy getAuthorizationStrategy()
public final IClassResolver getClassResolver()
public ClientInfo getClientInfo()
setClientInfo(ClientInfo))
client info object or uses RequestCycle.newClientInfo() to get
the info object based on the current request when no client info object
was set yet, and then caches the returned object; we can expect the
client to stay the same for the whole session, and implementations of
RequestCycle.newClientInfo() might be relatively expensive.
public final IPageMap getDefaultPageMap()
public final FeedbackMessages getFeedbackMessages()
public final java.lang.String getId()
public java.util.Locale getLocale()
public final java.io.Serializable getMetaData(MetaDataKey key)
key - The key for the data
MetaDataKeyprotected boolean isCurrentRequestValid(RequestCycle lockedRequestCycle)
lockedRequestCycle -
public final Page getPage(int pageId, int versionNumber)
pageId - versionNumber -
public final Page getPage(java.lang.String pageMapName, java.lang.String path, int versionNumber)
pageMapName - The name of the page map where the page ispath - Component pathversionNumber - The version of the page required
public final IPageFactory getPageFactory()
public final IPageFactory getPageFactory(Page page)
page - The page, or null if no page context is available
public final java.util.List getPageMaps()
public final long getSizeInBytes()
public final java.lang.String getStyle()
public final void info(java.lang.String message)
message - The feedback messagepublic void invalidate()
public void invalidateNow()
public final boolean isSessionInvalidated()
invalidate(),
invalidateNow()public final boolean isTemporary()
public final IPageMap newPageMap(java.lang.String name)
name - The name for the new page map
public final IPageMap pageMapForName(java.lang.String pageMapName, boolean autoCreate)
pageMapName - Name of page map, or null for default page mapautoCreate - True if the page map should be automatically created if it
does not exist
public final void removePageMap(IPageMap pageMap)
pageMap - Page map to removepublic final void setApplication(Application application)
Sets the application that this session is associated with.
application - The applicationpublic final void setClientInfo(ClientInfo clientInfo)
Sets the client info object for this session. This will only work when
getClientInfo() is not overriden.
clientInfo - the client info objectpublic final 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.IllegalArgumentExceptionMetaDataKeypublic final Session setStyle(java.lang.String style)
Session).
style - The style to set.
public final void touch(Page page)
The page will be 'touched' in the session. If it wasn't added yet to the pagemap, it will be added to the page map else it will set this page to the front. If another page was removed because of this it will be cleaned up.
page - public final void visitPageMaps(Session.IPageMapVisitor visitor)
visitor - The visitor to call at each Page in this PageMap.public final void warn(java.lang.String message)
message - The feedback messageprotected void attach()
protected void detach()
public final void dirty()
protected final java.lang.Object getAttribute(java.lang.String name)
name - The name of the attribute to store
protected final java.util.List getAttributeNames()
protected ISessionStore getSessionStore()
protected final void removeAttribute(java.lang.String name)
name - the name of the attribute to remove
protected final void setAttribute(java.lang.String name,
java.lang.Object value)
name - The name of the attributevalue - The value of the attributeprotected final void update()
detach() instead.
protected int nextPageId()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||