org.apache.wicket.pageStore
Class DefaultPageStore

java.lang.Object
  extended by org.apache.wicket.pageStore.DefaultPageStore
All Implemented Interfaces:
IPageStore

public class DefaultPageStore
extends java.lang.Object
implements IPageStore

The IPageStore that converts IManageablePage instances to DefaultPageStore.SerializedPages before passing them to the IDataStore to store them and the same in the opposite direction when loading DefaultPageStore.SerializedPage from the data store.


Nested Class Summary
protected static class DefaultPageStore.SerializedPage
          A representation of IManageablePage that knows additionally the id of the http session in which this IManageablePage instance is used.
 
Constructor Summary
DefaultPageStore(ISerializer pageSerializer, IDataStore dataStore, int cacheSize)
          Construct.
 
Method Summary
 IManageablePage convertToPage(java.lang.Object object)
          Converts a page representation to an instance of IManageablePage
protected  IManageablePage deserializePage(byte[] data)
           
 void destroy()
          Destroy the store.
 IManageablePage getPage(java.lang.String sessionId, int id)
          Restores a page from the persistent layer.
protected  byte[] getPageData(java.lang.String sessionId, int pageId)
           
 java.io.Serializable prepareForSerialization(java.lang.String sessionId, java.lang.Object object)
          Process the page before the it gets serialized.
 void removePage(java.lang.String sessionId, int id)
          Removes a page from the persistent layer.
protected  void removePageData(java.lang.String sessionId)
           
protected  void removePageData(java.lang.String sessionId, int pageId)
           
 java.lang.Object restoreAfterSerialization(java.io.Serializable serializable)
          This method should restore the serialized page to intermediate object that can be converted to real page instance using IPageStore.convertToPage(Object).
protected  DefaultPageStore.SerializedPage serializePage(java.lang.String sessionId, IManageablePage page)
           
protected  boolean storeAfterSessionReplication()
           
 void storePage(java.lang.String sessionId, IManageablePage page)
          Stores the page to a persistent layer.
protected  void storePageData(java.lang.String sessionId, int pageId, byte[] data)
           
 void unbind(java.lang.String sessionId)
          The page store should cleanup all the pages for that sessionid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPageStore

public DefaultPageStore(ISerializer pageSerializer,
                        IDataStore dataStore,
                        int cacheSize)
Construct.

Parameters:
pageSerializer - the ISerializer that will be used to convert pages from/to byte arrays
dataStore - the IDataStore that actually stores the pages
cacheSize - the number of pages to cache in memory before passing them to IDataStore.storeData(String, int, byte[])
Method Detail

destroy

public void destroy()
Description copied from interface: IPageStore
Destroy the store.

Specified by:
destroy in interface IPageStore
See Also:
IPageStore.destroy()

getPageData

protected byte[] getPageData(java.lang.String sessionId,
                             int pageId)
Parameters:
sessionId -
pageId -
Returns:
page data
See Also:
IDataStore.getData(String, int)

removePageData

protected void removePageData(java.lang.String sessionId,
                              int pageId)
Parameters:
sessionId -
pageId -
See Also:
IDataStore.removeData(String, int)

removePageData

protected void removePageData(java.lang.String sessionId)
Parameters:
sessionId -
See Also:
IDataStore.removeData(String)

storePageData

protected void storePageData(java.lang.String sessionId,
                             int pageId,
                             byte[] data)
Parameters:
sessionId -
pageId -
data -
See Also:
IDataStore.storeData(String, int, byte[])

getPage

public IManageablePage getPage(java.lang.String sessionId,
                               int id)
Description copied from interface: IPageStore
Restores a page from the persistent layer.

Specified by:
getPage in interface IPageStore
Parameters:
sessionId - The session of the page that must be removed
id - The id of the page.
Returns:
The page

removePage

public void removePage(java.lang.String sessionId,
                       int id)
Description copied from interface: IPageStore
Removes a page from the persistent layer.

Specified by:
removePage in interface IPageStore
Parameters:
sessionId - The session of the page that must be removed
id - The id of the page.

storePage

public void storePage(java.lang.String sessionId,
                      IManageablePage page)
Description copied from interface: IPageStore
Stores the page to a persistent layer. The page should be stored under the id and the version number.

Specified by:
storePage in interface IPageStore
Parameters:
sessionId - The session of the page that must be removed
page - The page to store

unbind

public void unbind(java.lang.String sessionId)
Description copied from interface: IPageStore
The page store should cleanup all the pages for that sessionid.

Specified by:
unbind in interface IPageStore
Parameters:
sessionId - The session of the page that must be removed

convertToPage

public IManageablePage convertToPage(java.lang.Object object)
Description copied from interface: IPageStore
Converts a page representation to an instance of IManageablePage

Specified by:
convertToPage in interface IPageStore
Parameters:
object - some kind of page representation
Returns:
page

prepareForSerialization

public java.io.Serializable prepareForSerialization(java.lang.String sessionId,
                                                    java.lang.Object object)
Description copied from interface: IPageStore
Process the page before the it gets serialized. The page can be either real page instance or object returned by IPageStore.restoreAfterSerialization(Serializable).

Specified by:
prepareForSerialization in interface IPageStore
Parameters:
sessionId - The session of the page that must be removed
Returns:
The Page itself or a SerializedContainer for that page

storeAfterSessionReplication

protected boolean storeAfterSessionReplication()
Returns:
Always true for this implementation

restoreAfterSerialization

public java.lang.Object restoreAfterSerialization(java.io.Serializable serializable)
Description copied from interface: IPageStore
This method should restore the serialized page to intermediate object that can be converted to real page instance using IPageStore.convertToPage(Object).

Specified by:
restoreAfterSerialization in interface IPageStore
Returns:
Page

serializePage

protected DefaultPageStore.SerializedPage serializePage(java.lang.String sessionId,
                                                        IManageablePage page)
Parameters:
sessionId -
page -
Returns:
the serialized page information

deserializePage

protected IManageablePage deserializePage(byte[] data)
Parameters:
data -
Returns:
page data deserialized


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.