Class FilePageStore
- java.lang.Object
-
- org.apache.wicket.pageStore.AbstractPersistentPageStore
-
- org.apache.wicket.pageStore.FilePageStore
-
- All Implemented Interfaces:
IPageStore
,IPersistentPageStore
public class FilePageStore extends AbstractPersistentPageStore implements IPersistentPageStore
A storage of pages in files.All pages passed into this store are restricted to be
SerializedPage
s.While
DiskPageStore
uses a single file per session, this implementation stores each page in its own file. This improves on adisadvantage of DiskPageStore
surfacing with alternating Ajax requests from different browser tabs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FilePageStore.LastModifiedComparator
-
Nested classes/interfaces inherited from class org.apache.wicket.pageStore.AbstractPersistentPageStore
AbstractPersistentPageStore.PersistedPage
-
-
Constructor Summary
Constructors Constructor Description FilePageStore(String applicationName, File fileStoreFolder, Bytes maxSizePerSession)
Create a store that supportsSerializedPage
s only.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addPersistedPage(String sessionIdentifier, IManageablePage page)
Add a page.protected String
getPageType(File file)
Get the type of page from the given file.protected IManageablePage
getPersistedPage(String sessionIdentifier, int id)
List<IPersistedPage>
getPersistedPages(String sessionIdentifier)
Get information about all persisted pages with the given session identifier.Set<String>
getSessionIdentifiers()
Get the identifiers for all stored sessions.Bytes
getTotalSize()
Get total size of all pages stored in all contexts.protected byte[]
readFile(File file)
Read a file.protected void
removeAllPersistedPages(String sessionIdentifier)
protected void
removePersistedPage(String sessionIdentifier, IManageablePage page)
protected void
setPageType(File file, String pageType)
Set the type of page on the given file.boolean
supportsVersioning()
Pages are always serialized, so versioning is supported.protected void
writeFile(File file, byte[] data)
Write a file with given data.-
Methods inherited from class org.apache.wicket.pageStore.AbstractPersistentPageStore
addPage, canBeAsynchronous, createSessionIdentifier, destroy, getPage, getSessionIdentifier, removeAllPages, removePage
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.pageStore.IPageStore
addPage, canBeAsynchronous, destroy, detach, end, getPage, removeAllPages, removePage, revertPage
-
Methods inherited from interface org.apache.wicket.pageStore.IPersistentPageStore
getSessionIdentifier
-
-
-
-
Constructor Detail
-
FilePageStore
public FilePageStore(String applicationName, File fileStoreFolder, Bytes maxSizePerSession)
Create a store that supportsSerializedPage
s only.- Parameters:
applicationName
- name of applicationfileStoreFolder
- folder to store tomaxSizePerSession
- maximum size per session- See Also:
SerializingPageStore
-
-
Method Detail
-
supportsVersioning
public boolean supportsVersioning()
Pages are always serialized, so versioning is supported.- Specified by:
supportsVersioning
in interfaceIPageStore
-
getPersistedPage
protected IManageablePage getPersistedPage(String sessionIdentifier, int id)
- Specified by:
getPersistedPage
in classAbstractPersistentPageStore
-
readFile
protected byte[] readFile(File file) throws IOException
Read a file.Note: This implementation uses a
FileChannel
.- Parameters:
file
- file to read- Throws:
IOException
-
removePersistedPage
protected void removePersistedPage(String sessionIdentifier, IManageablePage page)
- Specified by:
removePersistedPage
in classAbstractPersistentPageStore
-
removeAllPersistedPages
protected void removeAllPersistedPages(String sessionIdentifier)
- Specified by:
removeAllPersistedPages
in classAbstractPersistentPageStore
-
addPersistedPage
protected void addPersistedPage(String sessionIdentifier, IManageablePage page)
Description copied from class:AbstractPersistentPageStore
Add a page.- Specified by:
addPersistedPage
in classAbstractPersistentPageStore
- Parameters:
sessionIdentifier
- identifier of sessionpage
- page to add
-
writeFile
protected void writeFile(File file, byte[] data) throws IOException
Write a file with given data.Note: This implementation uses a
FileChannel
withStandardOpenOption.TRUNCATE_EXISTING
. This might fail on Windows systems with "The requested operation cannot be performed on a file with a user-mapped section open", so subclasses can omit this option to circumvent this error, although this prevents files from shrinking when pages become smaller. Alternatively a completely different implementation can be chosen.- Parameters:
file
- file to writedata
- data to write- Throws:
IOException
-
getSessionIdentifiers
public Set<String> getSessionIdentifiers()
Description copied from interface:IPersistentPageStore
Get the identifiers for all stored sessions.- Specified by:
getSessionIdentifiers
in interfaceIPersistentPageStore
- Returns:
- the identifiers of all session.
-
getPersistedPages
public List<IPersistedPage> getPersistedPages(String sessionIdentifier)
Description copied from interface:IPersistentPageStore
Get information about all persisted pages with the given session identifier.- Specified by:
getPersistedPages
in interfaceIPersistentPageStore
- Parameters:
sessionIdentifier
- identifier of the session.- Returns:
- all persisted pages
-
getPageType
protected String getPageType(File file)
Get the type of page from the given file.This is an optional operation that returns
null
in case of any error.- Parameters:
file
-- Returns:
- pageType
-
setPageType
protected void setPageType(File file, String pageType)
Set the type of page on the given file.This is an optional operation that silently fails in case of an error.
- Parameters:
file
-pageType
-
-
getTotalSize
public Bytes getTotalSize()
Description copied from interface:IPersistentPageStore
Get total size of all pages stored in all contexts.Optional operation, may return
null
.- Specified by:
getTotalSize
in interfaceIPersistentPageStore
- Returns:
- total size or
null
-
-