Warning |
---|
This page may be outdated! Please use the reference guide |
Wicket 1.5 - Page storage
Table of Contents | ||
---|---|---|
|
Introduction
This page describes the internals of Wicket page storages in version 1.5.
...
To setup another IPageManager implementation use org.apache.wicket.Application.setPageManagerProvider(IPageManagerProvider).
The custom IPageManager implementation may or may not use IPageStore/IDataStore.
IPageStore
org.apache.wicket.pageStore.IPageStore's role is to mediate the storing and loading of pages done by the underlying IDataStore.
Wiki Markup
The default implementation org.apache.wicket.pageStore.DefaultPageStore pre-processes the pages before passing them to IDataStore#storeData(String, int, byte\[\]) and to post-processes them after IDataStore#getData(String, int). The processing consists of transforming the page instance to org.apache.wicket.pageStore.DefaultPageStore.SerializedPage. This is a struct of:
\
{
sessionId: String,
pageId : int,
data : byte\[\]
\
}
i.e. this is the serialized page instance (data) plus additional information needed to be able to easily find it later (sessionId, pageId).
When a SerializedPage has to be stored DefaultPageStore stores it in a application scoped cache ({sessionId, pageId} -> SerializedPage) and additionally
gives it to the underlying IDataStore (#storeData(sessionId, pageId, data). The application scoped cache is used as second level cache. Getting a page from it is slower than the http session based cache in PageStoreManager because the page has to be deserialized, but is faster than the underlying IDataStore which stores the page bytes in some persistent store.
...
With Wicket 1.5-RC6 will be available an extension of DiskDataStore that can be used to browse the content of the 'data' files created by DiskDataStore.
This debug enabled DiskDataStore is automatically setup when wicket-devutils.jar is in the classpath.
The debug information can be seen at http://host:port/context/wicket/internal/debug/diskDataStore
HttpSessionDataStore
In some environments like Google AppEngine it is not allowed to write to the file system and thus DiskDataStore cannot be used. In this case org.apache.wicket.pageStore.memory.HttpSessionDataStore can be used as replacement. This implementation of IDataStore is not persistent and puts all the data in the http session.
Wicket comes with 2 default eviction strategies to keep the size of the http session reasonable:
- org.apache.wicket.pageStore.memory.PageNumberEvictionStrategy - specifies how many pages can be hold
- org.apache.wicket.pageStore.memory.MemorySizeEvictionStrategy - specifies the maximum amount of memory for pages per http session.
To configure it:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
MyApp#init()
{
super.init();
setPageManagerProvider(new DefaultPageManagerProvider()
{
protected IDataStore newDataStore()
{
return new HttpSessionDataStore(pageManagerContext, new PageNumberEvictionStrategy(20));
}
}
}
|
...
org.apache.wicket.protocol.http.PageExpiredException may be thrown by PageProvider when none of the underlying storages can find a page with specific id.
The reasons could be:
- the page have never been stored
- IStoreSettings.setMaxSizePerSession(Bytes) is not big enough and the page bytes were already overwritten
- the http session has expired and thus all the data about it (including stored pages) is erased from all stores