WICKET-6563 new IPageStore implementation

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c43d3a33
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c43d3a33
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c43d3a33

Branch: refs/heads/WICKET-6563
Commit: c43d3a338c591b86eedd294bb56ba122753385a6
Parents: 08f6a53
Author: Sven Meier <[email protected]>
Authored: Mon Jun 25 17:19:41 2018 +0200
Committer: Sven Meier <[email protected]>
Committed: Tue Oct 30 13:56:10 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/wicket/Application.java     |  33 +-
 .../wicket/DefaultPageManagerProvider.java      | 147 ++--
 .../org/apache/wicket/IPageManagerProvider.java |  10 +-
 .../src/main/java/org/apache/wicket/Page.java   |  10 +-
 .../main/java/org/apache/wicket/Session.java    |   7 +-
 .../core/request/handler/PageProvider.java      |   1 -
 .../handler/RenderPageRequestHandler.java       |   2 +-
 .../core/util/string/ComponentRenderer.java     |   2 +-
 .../org/apache/wicket/mock/MockApplication.java |   2 +-
 .../org/apache/wicket/mock/MockPageManager.java |  56 +-
 .../org/apache/wicket/mock/MockPageStore.java   |  75 ++
 .../apache/wicket/page/AbstractPageManager.java | 121 ----
 .../wicket/page/DefaultPageManagerContext.java  | 101 ---
 .../org/apache/wicket/page/IPageManager.java    |  80 +--
 .../apache/wicket/page/IPageManagerContext.java |  66 --
 .../wicket/page/PageAccessSynchronizer.java     |  42 +-
 .../org/apache/wicket/page/PageManager.java     |  90 +++
 .../wicket/page/PageManagerDecorator.java       | 100 ---
 .../apache/wicket/page/PageStoreManager.java    | 508 -------------
 .../org/apache/wicket/page/RequestAdapter.java  | 206 ------
 .../pageStore/AbstractCachingPageStore.java     | 105 ---
 .../wicket/pageStore/AbstractPageStore.java     | 154 ----
 .../wicket/pageStore/AsynchronousDataStore.java | 344 ---------
 .../wicket/pageStore/AsynchronousPageStore.java | 400 ++++++-----
 .../wicket/pageStore/DefaultPageContext.java    | 112 +++
 .../wicket/pageStore/DefaultPageStore.java      | 469 ------------
 .../wicket/pageStore/DelegatingPageStore.java   |  67 ++
 .../apache/wicket/pageStore/DiskDataStore.java  | 589 ---------------
 .../apache/wicket/pageStore/DiskPageStore.java  | 710 +++++++++++++++++++
 .../apache/wicket/pageStore/FilePageStore.java  | 562 +++++++++++++++
 .../wicket/pageStore/GroupingPageStore.java     | 288 ++++++++
 .../org/apache/wicket/pageStore/IDataStore.java |  83 ---
 .../apache/wicket/pageStore/IPageContext.java   | 114 +++
 .../org/apache/wicket/pageStore/IPageStore.java | 106 ++-
 .../apache/wicket/pageStore/IPersistedPage.java |  44 ++
 .../wicket/pageStore/IPersistentPageStore.java  |  51 ++
 .../wicket/pageStore/InMemoryPageStore.java     | 359 ++++++++++
 .../wicket/pageStore/InSessionPageStore.java    | 256 +++++++
 .../apache/wicket/pageStore/NoopPageStore.java  |  53 ++
 .../wicket/pageStore/PageWindowManager.java     | 506 -------------
 .../wicket/pageStore/PerSessionPageStore.java   | 332 ---------
 .../wicket/pageStore/RequestPageStore.java      | 157 ++++
 .../wicket/pageStore/SecondLevelPageCache.java  |  42 --
 .../apache/wicket/pageStore/SerializedPage.java |  88 +++
 .../wicket/pageStore/SerializingPageStore.java  |  72 ++
 .../wicket/pageStore/disk/NestedFolders.java    | 123 ++++
 .../pageStore/disk/PageWindowManager.java       | 493 +++++++++++++
 .../pageStore/memory/HttpSessionDataStore.java  | 186 -----
 .../memory/IDataStoreEvictionStrategy.java      |  35 -
 .../memory/MemorySizeEvictionStrategy.java      |  64 --
 .../memory/PageNumberEvictionStrategy.java      |  62 --
 .../wicket/pageStore/memory/PageTable.java      | 128 ----
 .../pageStore/memory/PageTableCleaner.java      |  46 --
 .../apache/wicket/settings/StoreSettings.java   |  69 +-
 .../wicket/util/tester/BaseWicketTester.java    | 447 ++++++------
 .../core/request/mapper/TestMapperContext.java  |  51 +-
 .../DontStoreNotRenderedPageTestCase.java       |  33 +-
 .../html/TransparentWebMarkupContainerTest.java |   8 +-
 .../wicket/page/PageAccessSynchronizerTest.java |   2 +-
 .../wicket/page/PersistentPageManagerTest.java  |  79 ++-
 .../persistent/disk/PageWindowManagerTest.java  | 305 --------
 .../AbstractConcurrentPageStoreTest.java        | 375 ++++++++++
 .../wicket/pageStore/AbstractPageStoreTest.java |  91 ++-
 .../pageStore/AsynchronousDataStoreTest.java    |  45 +-
 .../pageStore/AsynchronousPageStoreTest.java    | 255 +++++--
 .../wicket/pageStore/DefaultPageStoreTest.java  |  31 -
 .../wicket/pageStore/DiskDataStoreTest.java     | 413 -----------
 .../wicket/pageStore/DiskPageStoreTest.java     |  52 ++
 .../wicket/pageStore/DummyPageContext.java      | 110 +++
 .../wicket/pageStore/FilePageStoreTest.java     |  52 ++
 .../wicket/pageStore/GroupingPageStoreTest.java | 112 +++
 .../wicket/pageStore/InMemoryPageStoreTest.java |  31 +
 .../pageStore/InSessionPageStoreTest.java       |  32 +
 .../apache/wicket/pageStore/NoopDataStore.java  |  61 --
 .../pageStore/PerSessionPageStoreTest.java      |  55 --
 .../wicket/pageStore/RequestPageStoreTest.java  |  64 ++
 .../pageStore/SerializingPageStoreTest.java     |  52 ++
 .../pageStore/disk/NestedFoldersTest.java       |  96 +++
 .../pageStore/disk/PageWindowManagerTest.java   | 306 ++++++++
 .../memory/DummyPageManagerContext.java         |  66 --
 .../memory/HttpSessionDataStoreTest.java        | 114 ---
 .../memory/MemorySizeEvictionStrategyTest.java  |  64 --
 .../memory/PageNumberEvictionStrategyTest.java  |  66 --
 .../wicket/pageStore/memory/PageTableTest.java  |  58 --
 .../request/handler/PageIdPoliticTest.java      |  31 +-
 .../request/handler/PageProviderTest.java       |  20 +-
 .../wicket/versioning/InMemoryPageStore.java    | 126 ----
 .../wicket/versioning/PageVersioningTest.java   |  29 +-
 .../devutils/debugbar/DebugBarInitializer.java  |   2 +-
 .../devutils/debugbar/InspectorDebugPanel.java  |  20 +-
 .../devutils/debugbar/PageSizeDebugPanel.java   | 104 ---
 .../devutils/debugbar/PageStoreDebugPanel.java  |  84 +++
 .../devutils/debugbar/StandardDebugPanel.java   |   4 +-
 .../devutils/diskstore/DebugDiskDataStore.java  | 100 ---
 .../diskstore/DebugPageManagerProvider.java     |  63 --
 .../diskstore/DiskStoreBrowserPage.html         |  31 -
 .../diskstore/DiskStoreBrowserPage.java         |  51 --
 .../devutils/diskstore/PageStorePage.html       |  31 +
 .../devutils/diskstore/PageStorePage.java       |  68 ++
 .../diskstore/browser/BrowserPanel.html         |  28 -
 .../diskstore/browser/BrowserPanel.java         | 133 ----
 .../diskstore/browser/BrowserTable.java         |  47 --
 .../diskstore/browser/DataStoreHelper.java      |  43 --
 .../diskstore/browser/PageWindowColumn.java     |  80 ---
 .../browser/PageWindowDescription.java          |  57 --
 .../diskstore/browser/PageWindowProvider.java   | 108 ---
 .../browser/PersistedPagesProvider.java         | 133 ++++
 .../diskstore/browser/PersistedPanel.html       |  31 +
 .../diskstore/browser/PersistedPanel.java       | 201 ++++++
 .../browser/SessionIdentifiersModel.java        |  73 ++
 .../browser/SessionsProviderModel.java          |  57 --
 .../devutils/inspector/EnhancedPageView.java    |  37 +-
 .../devutils/inspector/InspectorPage.java       |  30 +-
 .../wicket/examples/frames/BodyFrame.java       |   6 +-
 .../apache/wicket/examples/StartExamples.java   |  13 +-
 .../ajax/markup/html/modal/ModalWindow.java     |   5 +-
 .../apache/wicket/jmx/StoreSettingsMBean.java   |  15 +-
 .../wicket/jmx/wrapper/StoreSettings.java       |   6 -
 .../ws/api/AbstractWebSocketProcessor.java      |   2 +-
 119 files changed, 6829 insertions(+), 7494 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/Application.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java 
b/wicket-core/src/main/java/org/apache/wicket/Application.java
index 4ba6e05..530ee4c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -55,10 +55,7 @@ import 
org.apache.wicket.markup.parser.filter.WicketMessageTagHandler;
 import org.apache.wicket.markup.resolver.HtmlHeaderResolver;
 import org.apache.wicket.markup.resolver.WicketContainerResolver;
 import org.apache.wicket.markup.resolver.WicketMessageResolver;
-import org.apache.wicket.page.DefaultPageManagerContext;
 import org.apache.wicket.page.IPageManager;
-import org.apache.wicket.page.IPageManagerContext;
-import org.apache.wicket.pageStore.IDataStore;
 import org.apache.wicket.pageStore.IPageStore;
 import org.apache.wicket.protocol.http.IRequestLogger;
 import org.apache.wicket.protocol.http.RequestLogger;
@@ -1029,7 +1026,7 @@ public abstract class Application implements 
UnboundListener, IEventSink, IMetad
        /** The Security Settings */
        private SecuritySettings securitySettings;
 
-       /** The settings for {@link IPageStore}, {@link IDataStore} and {@link 
IPageManager} */
+       /** The settings for {@link IPageStore} and {@link IPageManager} */
        private StoreSettings storeSettings;
 
        /** can the settings object be set/used. */
@@ -1347,8 +1344,11 @@ public abstract class Application implements 
UnboundListener, IEventSink, IMetad
        }
 
        /**
+        * Set the provider of an {@link IPageManager}.
         * 
         * @param provider
+        * 
+        * @see DefaultPageManagerProvider
         */
        public final Application setPageManagerProvider(final 
IPageManagerProvider provider)
        {
@@ -1357,11 +1357,6 @@ public abstract class Application implements 
UnboundListener, IEventSink, IMetad
        }
 
        /**
-        * Context for PageManager to interact with rest of Wicket
-        */
-       private final IPageManagerContext pageManagerContext = new 
DefaultPageManagerContext();
-
-       /**
         * Returns an unsynchronized version of page manager
         * 
         * @return the page manager
@@ -1374,22 +1369,13 @@ public abstract class Application implements 
UnboundListener, IEventSink, IMetad
                        {
                                if (pageManager == null)
                                {
-                                       pageManager = 
pageManagerProvider.apply(getPageManagerContext());
+                                       pageManager = pageManagerProvider.get();
                                }
                        }
                }
                return pageManager;
        }
 
-       /**
-        * 
-        * @return the page manager context
-        */
-       protected IPageManagerContext getPageManagerContext()
-       {
-               return pageManagerContext;
-       }
-
        // 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
@@ -1547,7 +1533,7 @@ public abstract class Application implements 
UnboundListener, IEventSink, IMetad
                {
                        session = newSession(requestCycle.getRequest(), 
requestCycle.getResponse());
                        ThreadContext.setSession(session);
-                       internalGetPageManager().newSessionCreated();
+                       internalGetPageManager().removeAllPages();
                        sessionListeners.onCreated(session);
                }
                else
@@ -1594,10 +1580,15 @@ public abstract class Application implements 
UnboundListener, IEventSink, IMetad
                        @Override
                        public void onDetach(final RequestCycle requestCycle)
                        {
+                               IPageManager pageManager;
+                               
                                if (Session.exists())
                                {
-                                       
Session.get().getPageManager().commitRequest();
+                                       pageManager = 
Session.get().getPageManager();
+                               } else {
+                                       pageManager = internalGetPageManager();
                                }
+                               pageManager.detach();
 
                                if (Application.exists())
                                {

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java 
b/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java
index f109472..cf4f84a 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java
@@ -19,22 +19,57 @@ package org.apache.wicket;
 import java.io.File;
 
 import org.apache.wicket.page.IPageManager;
-import org.apache.wicket.page.IPageManagerContext;
-import org.apache.wicket.page.PageStoreManager;
-import org.apache.wicket.pageStore.AsynchronousDataStore;
+import org.apache.wicket.page.PageManager;
 import org.apache.wicket.pageStore.AsynchronousPageStore;
-import org.apache.wicket.pageStore.DefaultPageStore;
-import org.apache.wicket.pageStore.DiskDataStore;
-import org.apache.wicket.pageStore.IDataStore;
+import org.apache.wicket.pageStore.DiskPageStore;
+import org.apache.wicket.pageStore.FilePageStore;
+import org.apache.wicket.pageStore.GroupingPageStore;
 import org.apache.wicket.pageStore.IPageStore;
+import org.apache.wicket.pageStore.InMemoryPageStore;
+import org.apache.wicket.pageStore.InSessionPageStore;
+import org.apache.wicket.pageStore.NoopPageStore;
+import org.apache.wicket.pageStore.RequestPageStore;
+import org.apache.wicket.pageStore.SerializingPageStore;
 import org.apache.wicket.serialize.ISerializer;
+import org.apache.wicket.settings.FrameworkSettings;
 import org.apache.wicket.settings.StoreSettings;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.lang.Bytes;
 
 /**
- * {@link IPageManagerProvider} implementation that creates new instance of 
{@link IPageManager}
- * that persists the pages in {@link DiskDataStore}
+ * A provider of a {@link PageManager} with a default chain of page {@link 
IPageStore}s:
+ * <ol>
+ * <li>{@link RequestPageStore} caching pages until end of the request</li>
+ * <li>{@link InSessionPageStore} keeping the last accessed page in the 
session</li>
+ * <li>{@link AsynchronousPageStore} moving storage of pages to a worker 
thread (if enabled in
+ * {@link StoreSettings#isAsynchronous()})</li>
+ * <li>{@link DiskPageStore} keeping all pages, configured according to {@link 
StoreSettings}</li>
+ * </ol>
+ * An alternative chain with all pages held in-memory could be:
+ * <ol>
+ * <li>{@link RequestPageStore} caching pages until end of the request</li>
+ * <li>{@link InSessionPageStore} keeping the last accessed page in the 
session</li>
+ * <li>{@link AsynchronousPageStore} moving storage of pages to a worker 
thread</li>
+ * <li>{@link SerializingPageStore} serializing all pages (so they are 
available for
+ * back-button)</li>
+ * <li>{@link InMemoryPageStore} keeping all pages in memory</li>
+ * </ol>
+ * ... or if all pages should be kept in the session only, without any 
serialization (no back-button
+ * support though):
+ * <ul>
+ * <li>{@link RequestPageStore} caching pages until end of the request</li>
+ * <li>{@link InSessionPageStore} keeping a limited count of pages in the 
session, e.g. 10</li>
+ * <li>{@link NoopPageStore} discarding all exceeding pages</li>
+ * </ul>
+ * For back-button support <em>at least one</em> store in the chain must 
create copies of stored
+ * pages (usually through serialization), otherwise any following request will 
work on an identical
+ * page instance and the previous state of page is no longer accessible.
+ * <p>
+ * Other stores be may inserted ad libitum, e.g.
+ * <ul>
+ * <li>{@link GroupingPageStore} groups pages with their own maximum page 
limit</li>
+ * <li>{@link FilePageStore} as alternative to the trusted {@link 
DiskPageStore}</li>
+ * </ul>
  */
 public class DefaultPageManagerProvider implements IPageManagerProvider
 {
@@ -44,7 +79,7 @@ public class DefaultPageManagerProvider implements 
IPageManagerProvider
         * Constructor.
         *
         * @param application
-        *          The application instance
+        *            The application instance
         */
        public DefaultPageManagerProvider(Application application)
        {
@@ -52,53 +87,85 @@ public class DefaultPageManagerProvider implements 
IPageManagerProvider
        }
 
        @Override
-       public IPageManager apply(IPageManagerContext pageManagerContext)
+       public IPageManager get()
        {
-               IDataStore dataStore = newDataStore();
+               IPageStore store = newPersistentStore();
 
-               StoreSettings storeSettings = getStoreSettings();
+               store = newAsynchronousStore(store);
 
-               IPageStore pageStore;
+               store = newSessionStore(store);
 
-               if (dataStore.canBeAsynchronous() && 
storeSettings.isAsynchronous())
-               {
-                       int capacity = 
storeSettings.getAsynchronousQueueCapacity();
-                       dataStore = new AsynchronousDataStore(dataStore, 
capacity);
+               store = newRequestStore(store);
 
-                       pageStore = newPageStore(dataStore);
-
-                       if (pageStore.canBeAsynchronous())
-                       {
-                               pageStore = new 
AsynchronousPageStore(pageStore, capacity);
-                       }
-               }
-               else
-               {
-                       pageStore = newPageStore(dataStore);
-               }
+               return new PageManager(store);
+       }
 
-               return new PageStoreManager(application.getName(), pageStore, 
pageManagerContext);
+       /**
+        * Get the {@link ISerializer} to use for serializing of pages.
+        * <p>
+        * By default the serializer of the applications {@link 
FrameworkSettings}.
+        * 
+        * @return how to serialize pages if needed for any {@link IPageStore}
+        * 
+        * @see FrameworkSettings#getSerializer()
+        */
+       protected ISerializer getSerializer()
+       {
+               return application.getFrameworkSettings().getSerializer();
+       }
 
+       /**
+        * Cache pages in the request until it is finished.
+        * 
+        * @see RequestPageStore
+        */
+       protected IPageStore newRequestStore(IPageStore pageStore)
+       {
+               return new RequestPageStore(pageStore);
        }
 
-       protected IPageStore newPageStore(IDataStore dataStore)
+       /**
+        * Cache last page in the session for fast access.
+        * 
+        * @see InSessionPageStore
+        */
+       protected IPageStore newSessionStore(IPageStore pageStore)
        {
-               int inmemoryCacheSize = 
getStoreSettings().getInmemoryCacheSize();
-               ISerializer pageSerializer = 
application.getFrameworkSettings().getSerializer();
-               return new DefaultPageStore(pageSerializer, dataStore, 
inmemoryCacheSize);
+               return new InSessionPageStore(pageStore, 1, getSerializer());
        }
 
-       protected IDataStore newDataStore()
+       /**
+        * Store pages asynchronously into the persistent store.
+        * 
+        * @see AsynchronousPageStore
+        * @see StoreSettings#isAsynchronous()
+        */
+       protected IPageStore newAsynchronousStore(IPageStore pageStore)
        {
-               StoreSettings storeSettings = getStoreSettings();
-               Bytes maxSizePerSession = storeSettings.getMaxSizePerSession();
-               File fileStoreFolder = storeSettings.getFileStoreFolder();
+               StoreSettings storeSettings = application.getStoreSettings();
+
+               if (storeSettings.isAsynchronous())
+               {
+                       int capacity = 
storeSettings.getAsynchronousQueueCapacity();
+                       pageStore = new AsynchronousPageStore(pageStore, 
capacity);
+               }
 
-               return new DiskDataStore(application.getName(), 
fileStoreFolder, maxSizePerSession);
+               return pageStore;
        }
 
-       StoreSettings getStoreSettings()
+       /**
+        * Keep persistent copies of all pages, by default on disk.
+        * 
+        * @see DiskPageStore
+        * @see StoreSettings#getMaxSizePerSession()
+        * @see StoreSettings#getFileStoreFolder()
+        */
+       protected IPageStore newPersistentStore()
        {
-               return application.getStoreSettings();
+               StoreSettings storeSettings = application.getStoreSettings();
+               Bytes maxSizePerSession = storeSettings.getMaxSizePerSession();
+               File fileStoreFolder = storeSettings.getFileStoreFolder();
+
+               return new DiskPageStore(application.getName(), 
fileStoreFolder, maxSizePerSession, getSerializer());
        }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/IPageManagerProvider.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/IPageManagerProvider.java 
b/wicket-core/src/main/java/org/apache/wicket/IPageManagerProvider.java
index 557a7aa..d887af3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/IPageManagerProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/IPageManagerProvider.java
@@ -16,11 +16,15 @@
  */
 package org.apache.wicket;
 
-import java.util.function.Function;
+import java.util.function.Supplier;
 
 import org.apache.wicket.page.IPageManager;
-import org.apache.wicket.page.IPageManagerContext;
 
-public interface IPageManagerProvider extends Function<IPageManagerContext, 
IPageManager>
+/**
+ * Provider of an {@link IPageManager}.
+ * 
+ * @author svenmeier
+ */
+public interface IPageManagerProvider extends Supplier<IPageManager>
 {
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/Page.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Page.java 
b/wicket-core/src/main/java/org/apache/wicket/Page.java
index a1f3b29..935e1f9 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Page.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Page.java
@@ -275,7 +275,7 @@ public abstract class Page extends MarkupContainer
                }
 
                final IPageManager pageManager = getSession().getPageManager();
-               if (!getFlag(FLAG_IS_DIRTY) && (isVersioned() && 
pageManager.supportsVersioning() ||
+               if (!getFlag(FLAG_IS_DIRTY) && (isVersioned() ||
 
                // we need to get pageId for new page instances even when the 
page doesn't need
                // versioning, otherwise pages override each other in the page 
store and back button
@@ -287,7 +287,7 @@ public abstract class Page extends MarkupContainer
 
                        if (isInitialization == false)
                        {
-                               pageManager.touchPage(this);
+                               pageManager.addPage(this);
                        }
                }
        }
@@ -298,7 +298,7 @@ public abstract class Page extends MarkupContainer
                super.onInitialize();
 
                final IPageManager pageManager = getSession().getPageManager();
-               pageManager.touchPage(this);
+               pageManager.addPage(this);
        }
 
        /**
@@ -825,7 +825,7 @@ public abstract class Page extends MarkupContainer
                        
getSession().getSessionStore().getSessionId(RequestCycle.get().getRequest(), 
true);
 
                        // Add/touch the response page in the session.
-                       getSession().getPageManager().touchPage(this);
+                       getSession().getPageManager().addPage(this);
                }
 
                if 
(getApplication().getDebugSettings().isOutputMarkupContainerClassName())
@@ -936,7 +936,7 @@ public abstract class Page extends MarkupContainer
                setStatelessHint(false);
 
                // make sure the page will be available on following request
-               getSession().getPageManager().touchPage(this);
+               getSession().getPageManager().addPage(this);
 
                return new PageReference(numericId);
        }

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/Session.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Session.java 
b/wicket-core/src/main/java/org/apache/wicket/Session.java
index a7aee21..3caaa0f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Session.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Session.java
@@ -37,6 +37,7 @@ import org.apache.wicket.feedback.FeedbackMessage;
 import org.apache.wicket.feedback.FeedbackMessages;
 import org.apache.wicket.page.IPageManager;
 import org.apache.wicket.page.PageAccessSynchronizer;
+import org.apache.wicket.pageStore.IPageStore;
 import org.apache.wicket.request.Request;
 import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.session.ISessionStore;
@@ -290,7 +291,7 @@ public abstract class Session implements IClusterable, 
IEventSink, IMetadataCont
        {
                if (isTemporary() == false)
                {
-                       getPageManager().clear();
+                       getPageManager().removeAllPages();
                }
        }
 
@@ -909,8 +910,8 @@ public abstract class Session implements IClusterable, 
IEventSink, IMetadataCont
         */
        public final IPageManager getPageManager()
        {
-               IPageManager pageManager = 
Application.get().internalGetPageManager();
-               return pageAccessSynchronizer.get().adapt(pageManager);
+               IPageManager manager = 
Application.get().internalGetPageManager();
+               return pageAccessSynchronizer.get().adapt(manager);
        }
 
        /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
 
b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
index bb94682..6dcfdc3 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
@@ -19,7 +19,6 @@ package org.apache.wicket.core.request.handler;
 import org.apache.wicket.Application;
 import org.apache.wicket.core.request.mapper.IPageSource;
 import org.apache.wicket.core.request.mapper.StalePageException;
-import org.apache.wicket.page.IPageManager;
 import org.apache.wicket.protocol.http.PageExpiredException;
 import org.apache.wicket.request.IRequestHandler;
 import org.apache.wicket.request.IRequestMapper;

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/core/request/handler/RenderPageRequestHandler.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/RenderPageRequestHandler.java
 
b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/RenderPageRequestHandler.java
index 156d420..642d40f 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/RenderPageRequestHandler.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/RenderPageRequestHandler.java
@@ -136,7 +136,7 @@ public class RenderPageRequestHandler
                        if (Session.exists())
                        {
                                // WICKET-5499
-                               
Session.get().getPageManager().touchPage(pageProvider.getPageInstance());
+                               
Session.get().getPageManager().addPage(pageProvider.getPageInstance());
                        }
                }
        }

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
 
b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
index 9104eb9..2b3d303 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java
@@ -452,7 +452,7 @@ public class ComponentRenderer
 
                private RenderPage(Component component)
                {
-                       // do not store the page in IPageStore/IDataStore. 
WICKET-5422
+                       // WICKET-5422 do not store the page in IPageStore 
                        setStatelessHint(true);
 
                        String componentMarkup;

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/mock/MockApplication.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/mock/MockApplication.java 
b/wicket-core/src/main/java/org/apache/wicket/mock/MockApplication.java
index 1c0a99d..4ae6f41 100644
--- a/wicket-core/src/main/java/org/apache/wicket/mock/MockApplication.java
+++ b/wicket-core/src/main/java/org/apache/wicket/mock/MockApplication.java
@@ -67,7 +67,7 @@ public class MockApplication extends WebApplication
 
                // set page and session store providers
                setSessionStoreProvider(MockSessionStore::new);
-               setPageManagerProvider((pageManagerContext) -> new 
MockPageManager());
+               setPageManagerProvider(() -> new MockPageManager());
 
                // for test cases we usually want stable resource names
                
getResourceSettings().setCachingStrategy(NoOpResourceCachingStrategy.INSTANCE);

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java 
b/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
index b27dc7e..05bb520 100644
--- a/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
+++ b/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 import org.apache.wicket.page.IManageablePage;
 import org.apache.wicket.page.IPageManager;
-import org.apache.wicket.page.IPageManagerContext;
+import org.apache.wicket.pageStore.IPageStore;
 
 /**
  * Simple {@link IPageManager} used for testing.
@@ -32,19 +32,6 @@ public class MockPageManager implements IPageManager
 {
        private final Map<Integer, IManageablePage> pages = new HashMap<>();
 
-       /**
-        * Construct.
-        * 
-        */
-       public MockPageManager()
-       {
-       }
-
-       @Override
-       public void commitRequest()
-       {
-       }
-
        @Override
        public void destroy()
        {
@@ -59,54 +46,29 @@ public class MockPageManager implements IPageManager
 
        @Override
        public void removePage(final IManageablePage page) {
-               if (page != null) {
-                       pages.remove(page.getPageId());
-               }
+               pages.remove(page.getPageId());
        }
 
        @Override
-       public void newSessionCreated()
+       public void addPage(IManageablePage page)
        {
-               pages.clear();
+               pages.put(page.getPageId(), page);
        }
 
        @Override
-       public void clear()
+       public void removeAllPages()
        {
                pages.clear();
        }
 
-       /**
-        * @param context
-        */
-       public void setContext(IPageManagerContext context)
-       {
-       }
-
-       @Override
-       public boolean supportsVersioning()
-       {
-               return true;
-       }
-
        @Override
-       public void touchPage(IManageablePage page)
+       public void detach()
        {
-               if (true || page.isPageStateless() == false)
-               {
-                       pages.put(page.getPageId(), page);
-               }
-       }
-
-       @Override
-       public void untouchPage(IManageablePage page)
-       {
-               pages.remove(page.getPageId());
        }
 
        @Override
-       public IPageManagerContext getContext()
+       public IPageStore getPageStore()
        {
-               return null;
+               throw new UnsupportedOperationException();
        }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/mock/MockPageStore.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/mock/MockPageStore.java 
b/wicket-core/src/main/java/org/apache/wicket/mock/MockPageStore.java
new file mode 100644
index 0000000..eb1dd58
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/mock/MockPageStore.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.mock;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.wicket.page.IManageablePage;
+import org.apache.wicket.pageStore.IPageContext;
+import org.apache.wicket.pageStore.IPageStore;
+
+public class MockPageStore implements IPageStore
+{
+       private final LinkedList<IManageablePage> pages = new LinkedList<>();
+
+       @Override
+       public void destroy()
+       {
+               pages.clear();
+       }
+
+       public List<IManageablePage> getPages()
+       {
+               return pages;
+       }
+
+       @Override
+       public IManageablePage getPage(IPageContext context, int id)
+       {
+               for (IManageablePage page : pages) {
+                       if (page .getPageId() == id) {
+                               return page;
+                       }
+               }
+               return null;
+       }
+
+       @Override
+       public void removePage(IPageContext context, final IManageablePage page)
+       {
+               pages.remove(page);
+       }
+
+       @Override
+       public void removeAllPages(IPageContext context)
+       {
+               pages.clear();
+       }
+
+       @Override
+       public boolean canBeAsynchronous(IPageContext context)
+       {
+               return true;
+       }
+
+       @Override
+       public void addPage(IPageContext context, IManageablePage page)
+       {
+               pages.addLast(page);
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/AbstractPageManager.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/AbstractPageManager.java 
b/wicket-core/src/main/java/org/apache/wicket/page/AbstractPageManager.java
deleted file mode 100644
index 03b26aa..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/page/AbstractPageManager.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.page;
-
-import org.apache.wicket.util.lang.Args;
-
-/**
- * Convenience class for {@link IPageManager} implementations. Subclass should 
extend
- * {@link RequestAdapter} and override {@link 
#newRequestAdapter(IPageManagerContext)} method to return it's
- * {@link RequestAdapter} implementation.
- * 
- * @author Matej Knopp
- */
-public abstract class AbstractPageManager implements IPageManager
-{
-       private final IPageManagerContext context;
-
-       /**
-        * Construct.
-        * 
-        * @param context
-        */
-       public AbstractPageManager(IPageManagerContext context)
-       {
-               this.context = Args.notNull(context, "context");
-       }
-
-       /**
-        * 
-        * @param context
-        * @return a new request adapter
-        */
-       protected abstract RequestAdapter newRequestAdapter(IPageManagerContext 
context);
-
-       /**
-        * @return The page manager context
-        */
-       @Override
-       public IPageManagerContext getContext()
-       {
-               return context;
-       }
-
-       /**
-        * @see #newRequestAdapter(IPageManagerContext)
-        * @return the request adapter
-        */
-       protected RequestAdapter getRequestAdapter()
-       {
-               RequestAdapter adapter = 
(RequestAdapter)getContext().getRequestData();
-               if (adapter == null)
-               {
-                       adapter = newRequestAdapter(getContext());
-                       getContext().setRequestData(adapter);
-               }
-               return adapter;
-       }
-
-       @Override
-       public void commitRequest()
-       {
-               getRequestAdapter().commitRequest();
-       }
-
-       @Override
-       public IManageablePage getPage(int id)
-       {
-               IManageablePage page = getRequestAdapter().getPage(id);
-               if (page != null)
-               {
-                       touchPage(page);
-               }
-               return page;
-       }
-
-       @Override
-       public void removePage(final IManageablePage page) {
-               if (page != null)
-               {
-                       getRequestAdapter().removePage(page);
-               }
-       }
-
-       @Override
-       public void newSessionCreated()
-       {
-               getRequestAdapter().newSessionCreated();
-       }
-
-       @Override
-       public void touchPage(IManageablePage page)
-       {
-               if (page != null)
-               {
-                       getRequestAdapter().touch(page);
-               }
-       }
-
-       @Override
-       public void untouchPage(IManageablePage page)
-       {
-               if (page != null)
-               {
-                       getRequestAdapter().untouch(page);
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/DefaultPageManagerContext.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/DefaultPageManagerContext.java
 
b/wicket-core/src/main/java/org/apache/wicket/page/DefaultPageManagerContext.java
deleted file mode 100644
index 78f4b49..0000000
--- 
a/wicket-core/src/main/java/org/apache/wicket/page/DefaultPageManagerContext.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.page;
-
-import java.io.Serializable;
-
-import org.apache.wicket.MetaDataKey;
-import org.apache.wicket.Session;
-import org.apache.wicket.request.cycle.RequestCycle;
-
-/**
- * Wicket's default page manager context
- * 
- * @author Juergen Donnerstag
- */
-public class DefaultPageManagerContext implements IPageManagerContext
-{
-       private static final MetaDataKey<Object> requestCycleMetaDataKey = new 
MetaDataKey<Object>()
-       {
-               private static final long serialVersionUID = 1L;
-       };
-
-       /**
-        * @see org.apache.wicket.page.IPageManagerContext#bind()
-        */
-       @Override
-       public void bind()
-       {
-               Session.get().bind();
-       }
-
-       /**
-        * @see org.apache.wicket.page.IPageManagerContext#getRequestData()
-        */
-       @Override
-       public Object getRequestData()
-       {
-               RequestCycle requestCycle = RequestCycle.get();
-               if (requestCycle == null)
-               {
-                       throw new IllegalStateException("Not a request 
thread.");
-               }
-               return requestCycle.getMetaData(requestCycleMetaDataKey);
-       }
-
-       /**
-        * @see 
org.apache.wicket.page.IPageManagerContext#getSessionAttribute(java.lang.String)
-        */
-       @Override
-       public Serializable getSessionAttribute(final String key)
-       {
-               return Session.get().getAttribute(key);
-       }
-
-       /**
-        * @see org.apache.wicket.page.IPageManagerContext#getSessionId()
-        */
-       @Override
-       public String getSessionId()
-       {
-               return Session.get().getId();
-       }
-
-       /**
-        * @see 
org.apache.wicket.page.IPageManagerContext#setRequestData(Object)
-        */
-       @Override
-       public void setRequestData(final Object data)
-       {
-               RequestCycle requestCycle = RequestCycle.get();
-               if (requestCycle == null)
-               {
-                       throw new IllegalStateException("Not a request 
thread.");
-               }
-               requestCycle.setMetaData(requestCycleMetaDataKey, data);
-       }
-
-       /**
-        * @see 
org.apache.wicket.page.IPageManagerContext#setSessionAttribute(java.lang.String,
-        *      java.io.Serializable)
-        */
-       @Override
-       public void setSessionAttribute(String key, Serializable value)
-       {
-               Session.get().setAttribute(key, value);
-       }
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/IPageManager.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/page/IPageManager.java 
b/wicket-core/src/main/java/org/apache/wicket/page/IPageManager.java
index a19a0e3..d600eee 100644
--- a/wicket-core/src/main/java/org/apache/wicket/page/IPageManager.java
+++ b/wicket-core/src/main/java/org/apache/wicket/page/IPageManager.java
@@ -16,89 +16,61 @@
  */
 package org.apache.wicket.page;
 
+import org.apache.wicket.Page;
+import org.apache.wicket.pageStore.IPageStore;
 
 /**
- * Page manager.
+ * A manager of pages - facade between {@link Page}s and {@link IPageStore}s 
they are stored in.
  * 
- * @author Matej Knopp
+ * @see PageManager
  */
 public interface IPageManager
 {
-       /**
-        * 
-        * @return the page manager context
-        */
-       IPageManagerContext getContext();
 
        /**
-        * Retrieve page instance with given id.
+        * Get a page
         * 
-        * @param id
-        *      the id of the page to load
-        * @return page instance or <code>null</code>
-        * @throws CouldNotLockPageException if the page is already locked by 
another thread
-        * and the lock cannot be acquired for some timeout
-        */
-       IManageablePage getPage(int id) throws CouldNotLockPageException;
-
-       /**
-        * Removes a page from the {@link 
org.apache.wicket.pageStore.IPageStore} and
-        * {@link org.apache.wicket.pageStore.IDataStore}. Any attempt to 
access it later
-        * will lead to {@link 
org.apache.wicket.protocol.http.PageExpiredException}
-        *
-        * @param page The page instance to remove from the stores
+        * @param pageId
+        *            id of page
+        * @return page, may be <code>null</code>
         */
-       void removePage(IManageablePage page);
+       IManageablePage getPage(int pageId);
 
        /**
-        * Marks page as changed.
-        * <p><strong>Note:</strong>Only stateful pages are stored.</p>
+        * Remove a page
         * 
         * @param page
-        *      the page that should be stored in the page stores at the end of 
the request.
-        * @throws CouldNotLockPageException if the page is already locked by 
another thread
-        * and the lock cannot be acquired for some timeout
-        */
-       void touchPage(IManageablePage page);
-
-       /**
-        * Marks page as non-changed.
-        * Could be used in Ajax requests to avoid storing the page if no 
changes have happened.
-        *
-        * @param page
-        *      the page that should <strong>not</strong> be stored in the page 
stores at the end of the request.
-        * @throws CouldNotLockPageException if the page is already locked by 
another thread
-        * and the lock cannot be acquired for some timeout
+        *            page to remove
         */
-       void untouchPage(IManageablePage page);
+       void removePage(IManageablePage page);
 
        /**
-        * Returns whether this manager supports versioning. Managers that 
support versioning must store
-        * page snapshots.
+        * Add a page.
         * 
-        * @return whether this page manager supports versioning
+        * @param page
+        *            page to add
         */
-       boolean supportsVersioning();
+       void addPage(IManageablePage page);
 
        /**
-        * Commits the changes to external storage if the manager uses it.
-        * 
-        * Should also detach all pages that were touched during this request.
+        * Remove all pages.
         */
-       void commitRequest();
+       void removeAllPages();
 
        /**
-        * Invoked when new session has been created.
+        * Detach at end of request.
         */
-       void newSessionCreated();
+       void detach();
 
        /**
-        * Clears all data for the current session.
+        * Destroy when application is destroyed.
         */
-       void clear();
+       void destroy();
 
        /**
-        * Destroy the page manager.
+        * Get the storage of pages, optional.
+        *  
+        * @return store or <code>null</code>
         */
-       void destroy();
+       IPageStore getPageStore();
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/IPageManagerContext.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/IPageManagerContext.java 
b/wicket-core/src/main/java/org/apache/wicket/page/IPageManagerContext.java
deleted file mode 100644
index d928606..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/page/IPageManagerContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.page;
-
-import java.io.Serializable;
-
-/**
- * Context object for {@link IPageManager}. This decouples the {@link 
IPageManager} from request
- * cycle and session.
- * 
- * @author Matej Knopp
- */
-public interface IPageManagerContext
-{
-       /**
-        * 
-        * @param data
-        */
-       void setRequestData(Object data);
-
-       /**
-        * 
-        * @return request data
-        */
-       Object getRequestData();
-
-       /**
-        * 
-        * @param key
-        * @param value
-        */
-       void setSessionAttribute(String key, Serializable value);
-
-       /**
-        * 
-        * @param key
-        * @return The session attribute associate with the key
-        */
-       Serializable getSessionAttribute(String key);
-
-       /**
-        * Tells Wicket to bind the current session. This make a temporary 
session become persistent
-        * across requests.
-        */
-       void bind();
-
-       /**
-        * 
-        * @return session id
-        */
-       String getSessionId();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/PageAccessSynchronizer.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/PageAccessSynchronizer.java 
b/wicket-core/src/main/java/org/apache/wicket/page/PageAccessSynchronizer.java
index d44b86a..c50fb20 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/page/PageAccessSynchronizer.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/page/PageAccessSynchronizer.java
@@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.function.Supplier;
 
 import org.apache.wicket.Application;
+import org.apache.wicket.pageStore.IPageStore;
 import org.apache.wicket.settings.ExceptionSettings.ThreadDumpStrategy;
 import org.apache.wicket.util.LazyInitializer;
 import org.apache.wicket.util.lang.Threads;
@@ -230,12 +231,12 @@ public class PageAccessSynchronizer implements 
Serializable
        /**
         * Wraps a page manager with this synchronizer
         * 
-        * @param pagemanager
+        * @param manager
         * @return wrapped page manager
         */
-       public IPageManager adapt(IPageManager pagemanager)
+       public IPageManager adapt(final IPageManager manager)
        {
-               return new PageManagerDecorator(pagemanager)
+               return new IPageManager()
                {
                        @Override
                        public IManageablePage getPage(int pageId)
@@ -244,7 +245,7 @@ public class PageAccessSynchronizer implements Serializable
                                try
                                {
                                        lockPage(pageId);
-                                       page = super.getPage(pageId);
+                                       page = manager.getPage(pageId);
                                }
                                finally
                                {
@@ -257,13 +258,13 @@ public class PageAccessSynchronizer implements 
Serializable
                        }
 
                        @Override
-                       public void removePage(final IManageablePage page) {
+                       public void removePage(IManageablePage page)
+                       {
                                if (page != null)
                                {
                                        try
                                        {
-                                               super.removePage(page);
-                                               untouchPage(page);
+                                               manager.removePage(page);
                                        }
                                        finally
                                        {
@@ -273,24 +274,43 @@ public class PageAccessSynchronizer implements 
Serializable
                        }
 
                        @Override
-                       public void touchPage(IManageablePage page)
+                       public void addPage(IManageablePage page)
                        {
                                lockPage(page.getPageId());
-                               super.touchPage(page);
+                               
+                               manager.addPage(page);
                        }
 
                        @Override
-                       public void commitRequest()
+                       public void removeAllPages()
+                       {
+                               manager.removeAllPages();
+                       }
+                       
+                       @Override
+                       public void detach()
                        {
                                try
                                {
-                                       super.commitRequest();
+                                       manager.detach();
                                }
                                finally
                                {
                                        unlockAllPages();
                                }
                        }
+                       
+                       @Override
+                       public IPageStore getPageStore()
+                       {
+                               return manager.getPageStore();
+                       }
+                       
+                       @Override
+                       public void destroy()
+                       {
+                               manager.destroy();
+                       }
                };
        }
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/PageManager.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/page/PageManager.java 
b/wicket-core/src/main/java/org/apache/wicket/page/PageManager.java
new file mode 100644
index 0000000..a516e1f
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/page/PageManager.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.page;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.pageStore.DefaultPageContext;
+import org.apache.wicket.pageStore.IPageContext;
+import org.apache.wicket.pageStore.IPageStore;
+import org.apache.wicket.util.lang.Args;
+
+/**
+ * Default implementation of a page mmanager.
+ * 
+ * @see IPageStore
+ * @see IPageContext
+ */
+public class PageManager implements IPageManager
+{
+       private final IPageStore store;
+       
+       public PageManager(IPageStore store) {
+               this.store = Args.notNull(store, "store");
+       }
+
+       @Override
+       public IManageablePage getPage(int pageId)
+       {
+               return store.getPage(createPageContext(), pageId);
+       }
+
+       @Override
+       public void removePage(IManageablePage page)
+       {
+               store.removePage(createPageContext(), page);
+       }
+
+       @Override
+       public void addPage(IManageablePage page)
+       {
+               store.addPage(createPageContext(), page);
+       }
+
+       @Override
+       public void removeAllPages()
+       {
+               store.removeAllPages(createPageContext());
+       }
+
+       @Override
+       public void detach()
+       {
+               store.detach(createPageContext());
+       }
+
+       /**
+        * Factory method for an {@link IPageContext}, returns a {@link 
DefaultPageContext} by default.
+        * 
+        * @return context of a stored page
+        */
+       protected IPageContext createPageContext()
+       {
+               return new DefaultPageContext(Session.get());
+       }
+
+       @Override
+       public void destroy()
+       {
+               store.destroy();
+       }
+       
+       @Override
+       public IPageStore getPageStore()
+       {
+               return store;
+       }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/PageManagerDecorator.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/PageManagerDecorator.java 
b/wicket-core/src/main/java/org/apache/wicket/page/PageManagerDecorator.java
deleted file mode 100644
index 8f719f8..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/page/PageManagerDecorator.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.page;
-
-import org.apache.wicket.util.lang.Args;
-
-/**
- * Decorator for {@link IPageManager}
- * 
- * @author igor
- */
-public class PageManagerDecorator implements IPageManager
-{
-       private final IPageManager delegate;
-
-       /**
-        * Constructor
-        * 
-        * @param delegate
-        */
-       public PageManagerDecorator(IPageManager delegate)
-       {
-               Args.notNull(delegate, "delegate");
-               this.delegate = delegate;
-       }
-
-       @Override
-       public IPageManagerContext getContext()
-       {
-               return delegate.getContext();
-       }
-
-       @Override
-       public IManageablePage getPage(int id)
-       {
-               return delegate.getPage(id);
-       }
-
-       @Override
-       public void removePage(final IManageablePage page) {
-               delegate.removePage(page);
-       }
-
-       @Override
-       public void touchPage(IManageablePage page)
-       {
-               delegate.touchPage(page);
-       }
-
-       @Override
-       public void untouchPage(IManageablePage page)
-       {
-               delegate.untouchPage(page);
-       }
-
-       @Override
-       public boolean supportsVersioning()
-       {
-               return delegate.supportsVersioning();
-       }
-
-       @Override
-       public void commitRequest()
-       {
-               delegate.commitRequest();
-       }
-
-       @Override
-       public void newSessionCreated()
-       {
-               delegate.newSessionCreated();
-       }
-
-       @Override
-       public void clear()
-       {
-               delegate.clear();
-       }
-
-       @Override
-       public void destroy()
-       {
-               delegate.destroy();
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java 
b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
deleted file mode 100644
index e1b543a..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.page;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.servlet.http.HttpSessionBindingEvent;
-import javax.servlet.http.HttpSessionBindingListener;
-
-import org.apache.wicket.pageStore.IPageStore;
-
-/**
- * 
- */
-public class PageStoreManager extends AbstractPageManager
-{
-       /**
-        * A cache that holds all registered page managers. <br/>
-        * applicationName -> page manager
-        */
-       private static final ConcurrentMap<String, PageStoreManager> MANAGERS = 
new ConcurrentHashMap<>();
-
-       private static final String ATTRIBUTE_NAME = 
"wicket:persistentPageManagerData";
-
-       /**
-        * A flag indicating whether this session entry is being re-set in the 
Session.
-        * <p>
-        * Web containers intercept
-        * {@link javax.servlet.http.HttpSession#setAttribute(String, Object)} 
to detect changes and
-        * replicate the session. If the attribute has been already bound in 
the session then
-        * {@link #valueUnbound(HttpSessionBindingEvent)} might get called - 
this flag
-        * helps us to ignore the invocation in that case.
-        * 
-        * @see #valueUnbound(HttpSessionBindingEvent)
-        */
-       private static final ThreadLocal<Boolean> STORING_TOUCHED_PAGES = new 
ThreadLocal<Boolean>()
-       {
-               @Override
-               protected Boolean initialValue()
-               {
-                       return Boolean.FALSE;
-               };
-       };
-
-       private final IPageStore pageStore;
-       
-       private final String applicationName;
-       
-       /**
-        * Construct.
-        * 
-        * @param applicationName
-        * @param pageStore
-        * @param context
-        */
-       public PageStoreManager(final String applicationName, final IPageStore 
pageStore,
-               final IPageManagerContext context)
-       {
-               super(context);
-
-               this.applicationName = applicationName;
-               this.pageStore = pageStore;
-
-               if (MANAGERS.containsKey(applicationName))
-               {
-                       throw new IllegalStateException(
-                               "Manager for application with key '" + 
applicationName + "' already exists.");
-               }
-               MANAGERS.put(applicationName, this);
-       }
-
-       /**
-        * Represents entry for single session. This is stored as session 
attribute and caches pages
-        * between requests.
-        * 
-        * @author Matej Knopp
-        */
-       private static class SessionEntry implements Serializable, 
HttpSessionBindingListener
-       {
-               private static final long serialVersionUID = 1L;
-
-               private final String applicationName;
-
-               /**
-                * The id handed to the {@link IPageStore} to identify the 
session.
-                * <p>
-                * Note: If the container changes a session's id, this field 
remains unchanged on its
-                * initial value.
-                */
-               private final String sessionId;
-
-               private transient List<IManageablePage> sessionCache;
-               private transient List<Object> afterReadObject;
-
-
-               /**
-                * Construct.
-                * 
-                * @param applicationName
-                * @param sessionId
-                */
-               public SessionEntry(String applicationName, String sessionId)
-               {
-                       this.applicationName = applicationName;
-                       this.sessionId = sessionId;
-               }
-
-               /**
-                * 
-                * @return page store
-                */
-               private IPageStore getPageStore()
-               {
-                       PageStoreManager manager = 
MANAGERS.get(applicationName);
-
-                       if (manager == null)
-                       {
-                               return null;
-                       }
-
-                       return manager.pageStore;
-               }
-
-               /**
-                * 
-                * @param id
-                * @return null, if not found
-                */
-               private IManageablePage findPage(int id)
-               {
-                       for (IManageablePage p : sessionCache)
-                       {
-                               if (p.getPageId() == id)
-                               {
-                                       return p;
-                               }
-                       }
-                       return null;
-               }
-
-               /**
-                * Add the page to cached pages if page with same id is not 
already there
-                * 
-                * @param page
-                */
-               private void addPage(IManageablePage page)
-               {
-                       if (page != null)
-                       {
-                               if (findPage(page.getPageId()) != null)
-                               {
-                                       return;
-                               }
-
-                               sessionCache.add(page);
-                       }
-               }
-
-               private synchronized void removePage(IManageablePage page)
-               {
-                       if (page != null)
-                       {
-                               sessionCache.remove(page);
-                               final IPageStore pageStore = getPageStore();
-                               if (pageStore != null)
-                               {
-                                       pageStore.removePage(sessionId, 
page.getPageId());
-                               }
-                       }
-               }
-
-               /**
-                * If the pages are stored in temporary state (after 
deserialization) this method convert
-                * them to list of "real" pages
-                */
-               private void convertAfterReadObjects()
-               {
-                       if (sessionCache == null)
-                       {
-                               sessionCache = new ArrayList<>();
-                       }
-
-                       final IPageStore pageStore = getPageStore();
-                       if (pageStore != null)
-                       {
-                               for (Object o : afterReadObject)
-                               {
-                                       IManageablePage page = 
pageStore.convertToPage(o);
-                                       addPage(page);
-                               }
-                       }
-
-                       afterReadObject = null;
-               }
-
-               /**
-                * 
-                * @param id
-                * @return manageable page
-                */
-               public synchronized IManageablePage getPage(int id)
-               {
-                       // check if pages are in deserialized state
-                       if (afterReadObject != null && 
afterReadObject.isEmpty() == false)
-                       {
-                               convertAfterReadObjects();
-                       }
-
-                       IManageablePage page = null;
-                       // try to find page with same id
-                       if (sessionCache != null)
-                       {
-                               page = findPage(id);
-                               if (page != null)
-                               {
-                                       return page;
-                               }
-                       }
-
-                       // not found, ask pagestore for the page
-                       final IPageStore pageStore = getPageStore();
-                       if (pageStore != null)
-                       {
-                               page = pageStore.getPage(sessionId, id);
-                       }
-                       return page;
-               }
-
-               /**
-                * set the list of pages to remember after the request
-                * 
-                * @param pages
-                */
-               public synchronized void setSessionCache(final 
List<IManageablePage> pages)
-               {
-                       sessionCache = new ArrayList<>(pages);
-                       afterReadObject = null;
-               }
-
-               /**
-                * Serializes all pages in this {@link SessionEntry}. If this 
is http worker thread then
-                * there is available {@link IPageStore} which will be asked to 
prepare the page for
-                * serialization (see DefaultPageStore$SerializePage). If there 
is no {@link IPageStore}
-                * available (session loading/persisting in application 
initialization/destruction thread)
-                * then the pages are serialized without any pre-processing
-                * 
-                * @param s
-                * @throws IOException
-                */
-               private void writeObject(final ObjectOutputStream s) throws 
IOException
-               {
-                       s.defaultWriteObject();
-
-                       // prepare for serialization and store the pages
-                       List<Serializable> serializedPages = new 
ArrayList<Serializable>();
-                       if (sessionCache != null)
-                       {
-                               IPageStore pageStore = getPageStore();
-                               for (IManageablePage p : sessionCache)
-                               {
-                                       Serializable preparedPage;
-                                       if (pageStore != null)
-                                       {
-                                               preparedPage = 
pageStore.prepareForSerialization(sessionId, p);
-                                       }
-                                       else
-                                       {
-                                               preparedPage = p;
-                                       }
-
-                                       if (preparedPage != null)
-                                       {
-                                               
serializedPages.add(preparedPage);
-                                       }
-                               }
-                       }
-                       s.writeObject(serializedPages);
-               }
-
-               /**
-                * Deserializes the pages in this {@link SessionEntry}. If this 
is http worker thread then
-                * there is available {@link IPageStore} which will be asked to 
restore the page from its
-                * optimized state (see DefaultPageStore$SerializePage). If 
there is no {@link IPageStore}
-                * available (session loading/persisting in application 
initialization/destruction thread)
-                * then the pages are deserialized without any post-processing
-                * 
-                * @param s
-                * @throws IOException
-                * @throws ClassNotFoundException
-                */
-               @SuppressWarnings("unchecked")
-               private void readObject(final ObjectInputStream s)
-                       throws IOException, ClassNotFoundException
-               {
-                       s.defaultReadObject();
-
-                       afterReadObject = new ArrayList<>();
-
-                       List<Serializable> l = 
(List<Serializable>)s.readObject();
-
-                       // convert to temporary state after deserialization 
(will need to be processed
-                       // by convertAfterReadObject before the pages can be 
accessed)
-                       IPageStore pageStore = getPageStore();
-                       for (Serializable ser : l)
-                       {
-                               Object page;
-                               if (pageStore != null)
-                               {
-                                       page = 
pageStore.restoreAfterSerialization(ser);
-                               }
-                               else
-                               {
-                                       page = ser;
-                               }
-                               afterReadObject.add(page);
-                       }
-               }
-
-               @Override
-               public void valueBound(HttpSessionBindingEvent event)
-               {
-               }
-
-               @Override
-               public void valueUnbound(HttpSessionBindingEvent event)
-               {
-                       if (STORING_TOUCHED_PAGES.get())
-                       {
-                               // triggered by #storeTouchedPages(), so do not 
remove the data
-                               return;
-                       }
-
-                       // WICKET-5164 use the original sessionId
-                       IPageStore store = getPageStore();
-                       // store might be null if destroyed already
-                       if (store != null)
-                       {
-                               store.unbind(sessionId);
-                       }
-               }
-
-               @Override
-               public boolean equals(Object o)
-               {
-                       // see https://issues.apache.org/jira/browse/WICKET-5390
-                       return false;
-               }
-       }
-
-       private String getAttributeName()
-       {
-               return ATTRIBUTE_NAME + " - " + applicationName;
-       }
-
-       /**
-        * {@link RequestAdapter} for {@link PageStoreManager}
-        * 
-        * @author Matej Knopp
-        */
-       protected class PersistentRequestAdapter extends RequestAdapter
-       {
-               /**
-                * Construct.
-                * 
-                * @param context
-                */
-               public PersistentRequestAdapter(IPageManagerContext context)
-               {
-                       super(context);
-               }
-
-               @Override
-               protected IManageablePage getPage(int id)
-               {
-                       IManageablePage touchedPage = findPage(id);
-                       if (touchedPage != null)
-                       {
-                               return touchedPage;
-                       }
-
-                       // try to get session entry for this session
-                       SessionEntry entry = getSessionEntry(false);
-
-                       if (entry != null)
-                       {
-                               return entry.getPage(id);
-                       }
-                       else
-                       {
-                               return null;
-                       }
-               }
-
-               @Override
-               protected void removePage(final IManageablePage page)
-               {
-                       final SessionEntry sessionEntry = 
getSessionEntry(false);
-                       if (sessionEntry != null)
-                       {
-                               sessionEntry.removePage(page);
-                       }
-               }
-
-               /**
-                * 
-                * @param create
-                * @return Session Entry
-                */
-               private SessionEntry getSessionEntry(boolean create)
-               {
-                       SessionEntry entry = 
(SessionEntry)getSessionAttribute(getAttributeName());
-                       if (entry == null && create)
-                       {
-                               bind();
-                               entry = new SessionEntry(applicationName, 
getSessionId());
-                       }
-                       return entry;
-               }
-
-               @Override
-               protected void newSessionCreated()
-               {
-                       // if the session is not temporary bind a session entry 
to it
-                       if (getSessionId() != null)
-                       {
-                               getSessionEntry(true);
-                       }
-               }
-
-               @Override
-               protected void storeTouchedPages(final List<IManageablePage> 
touchedPages)
-               {
-                       if (!touchedPages.isEmpty())
-                       {
-                               SessionEntry entry = getSessionEntry(true);
-                               entry.setSessionCache(touchedPages);
-                               for (IManageablePage page : touchedPages)
-                               {
-                                       // WICKET-5103 use the same sessionId 
as used in
-                                       // SessionEntry#getPage()
-                                       pageStore.storePage(entry.sessionId, 
page);
-                               }
-
-                               STORING_TOUCHED_PAGES.set(true);
-                               try
-                               {
-                                       setSessionAttribute(getAttributeName(), 
entry);
-                               }
-                               finally
-                               {
-                                       STORING_TOUCHED_PAGES.remove();
-                               }
-                       }
-               }
-       }
-
-       @Override
-       protected RequestAdapter newRequestAdapter(IPageManagerContext context)
-       {
-               return new PersistentRequestAdapter(context);
-       }
-
-       @Override
-       public boolean supportsVersioning()
-       {
-               return true;
-       }
-
-       @Override
-       public void clear()
-       {
-               RequestAdapter requestAdapter = getRequestAdapter();
-               String sessionEntryAttributeName = getAttributeName();
-               Serializable sessionEntry = 
requestAdapter.getSessionAttribute(sessionEntryAttributeName);
-               if (sessionEntry instanceof SessionEntry)
-               {
-                       ((SessionEntry)sessionEntry).valueUnbound(null);
-               }
-       }
-
-       @Override
-       public void destroy()
-       {
-               MANAGERS.remove(applicationName);
-               pageStore.destroy();
-       }
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/RequestAdapter.java 
b/wicket-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
deleted file mode 100644
index 7b8b7b9..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.page;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Request scoped helper class for {@link IPageManager}.
- * 
- * @author Matej Knopp
- */
-public abstract class RequestAdapter
-{
-       private static final Logger log = 
LoggerFactory.getLogger(RequestAdapter.class);
-
-       private final IPageManagerContext context;
-
-       private final List<IManageablePage> touchedPages = new 
ArrayList<IManageablePage>();
-
-       /**
-        * Construct.
-        * 
-        * @param context
-        *            The page manager context
-        */
-       public RequestAdapter(final IPageManagerContext context)
-       {
-               this.context = context;
-       }
-
-       /**
-        * Returns the page with specified id. The page is then cached by 
{@link RequestAdapter} during
-        * the rest of request processing.
-        * 
-        * @param id
-        * @return page instance or <code>null</code> if the page does not 
exist.
-        */
-       protected abstract IManageablePage getPage(int id);
-
-       /**
-        * Removes a page from the cache and the stores ({@link 
org.apache.wicket.pageStore.IPageStore} and
-        * {@link org.apache.wicket.pageStore.IDataStore}). Any attempt to 
access it later
-        * will lead to {@link 
org.apache.wicket.protocol.http.PageExpiredException}
-        *
-        * @param page The page instance to remove
-        */
-       protected abstract void removePage(final IManageablePage page);
-
-       /**
-        * Store the list of stateful pages.
-        * 
-        * @param touchedPages
-        */
-       protected abstract void storeTouchedPages(List<IManageablePage> 
touchedPages);
-
-       /**
-        * Notification on new session being created.
-        */
-       protected abstract void newSessionCreated();
-
-       /**
-        * Bind the session
-        * 
-        * @see IPageManagerContext#bind()
-        */
-       protected void bind()
-       {
-               context.bind();
-       }
-
-       /**
-        * @see IPageManagerContext#setSessionAttribute(String, Serializable)
-        * 
-        * @param key
-        * @param value
-        */
-       public void setSessionAttribute(String key, Serializable value)
-       {
-               context.setSessionAttribute(key, value);
-       }
-
-       /**
-        * @see IPageManagerContext#getSessionAttribute(String)
-        * 
-        * @param key
-        * @return the session attribute
-        */
-       public Serializable getSessionAttribute(final String key)
-       {
-               return context.getSessionAttribute(key);
-       }
-
-       /**
-        * @see IPageManagerContext#getSessionId()
-        * 
-        * @return session id
-        */
-       public String getSessionId()
-       {
-               return context.getSessionId();
-       }
-
-       /**
-        * 
-        * @param id
-        * @return null, if not found
-        */
-       protected IManageablePage findPage(final int id)
-       {
-               for (IManageablePage page : touchedPages)
-               {
-                       if (page.getPageId() == id)
-                       {
-                               return page;
-                       }
-               }
-               return null;
-       }
-
-       /**
-        * Touches a page, so it will be stored in the page stores
-        * at the end of the request cycle
-        *
-        * @param page The page to mark as dirty
-        */
-       protected void touch(final IManageablePage page)
-       {
-               if (findPage(page.getPageId()) == null)
-               {
-                       touchedPages.add(page);
-               }
-       }
-
-       /**
-        * @param page The page to unmark as dirty, so it won't be stored
-        *                at the end of the request cycle
-        */
-       protected void untouch(final IManageablePage page)
-       {
-               Iterator<IManageablePage> iterator = touchedPages.iterator();
-               while (iterator.hasNext())
-               {
-                       IManageablePage touchedPage = iterator.next();
-                       if (touchedPage.getPageId() == page.getPageId())
-                       {
-                               iterator.remove();
-                               break;
-                       }
-               }
-       }
-
-       /**
-        * 
-        */
-       protected void commitRequest()
-       {
-               // store pages that are not stateless
-               if (touchedPages.isEmpty() == false)
-               {
-                       List<IManageablePage> statefulPages = new 
ArrayList<IManageablePage>(
-                               touchedPages.size());
-                       for (IManageablePage page : touchedPages)
-                       {
-                               boolean isPageStateless;
-                               try
-                               {
-                                       isPageStateless = 
page.isPageStateless();
-                               }
-                               catch (Exception x)
-                               {
-                                       log.warn("An error occurred while 
checking whether a page is stateless. Assuming it is stateful.", x);
-                                       isPageStateless = false;
-                               }
-                               if (isPageStateless == false)
-                               {
-                                       statefulPages.add(page);
-                               }
-                       }
-
-                       if (statefulPages.isEmpty() == false)
-                       {
-                               storeTouchedPages(statefulPages);
-                       }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractCachingPageStore.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractCachingPageStore.java
 
b/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractCachingPageStore.java
deleted file mode 100644
index 86b8d82..0000000
--- 
a/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractCachingPageStore.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.pageStore;
-
-import org.apache.wicket.page.IManageablePage;
-import org.apache.wicket.serialize.ISerializer;
-import org.apache.wicket.util.lang.Args;
-
-/**
- * An abstract {@link org.apache.wicket.pageStore.IPageStore} that uses
- * {@link org.apache.wicket.pageStore.SecondLevelPageCache} to cache the 
stored pages in memory
- *
- * @param <P>
- *          The type of the page to be stored
- */
-public abstract class AbstractCachingPageStore<P> extends AbstractPageStore
-{
-       /**
-        * The cache implementation
-        */
-       protected final SecondLevelPageCache<String, Integer, P> pagesCache;
-
-       /**
-        * Constructor.
-        *
-        * @param pageSerializer
-        *          The serializer that will convert pages to/from byte[]
-        * @param dataStore
-        *          The third level page cache
-        * @param pagesCache
-        *          The cache to use as a second level store
-        */
-       protected AbstractCachingPageStore(ISerializer pageSerializer, 
IDataStore dataStore,
-                                          SecondLevelPageCache<String, 
Integer, P> pagesCache)
-       {
-               super(pageSerializer, dataStore);
-
-               this.pagesCache = Args.notNull(pagesCache, "pagesCache");
-       }
-
-       @Override
-       public IManageablePage getPage(final String sessionId, final int pageId)
-       {
-               P fromCache = pagesCache.getPage(sessionId, pageId);
-               if (fromCache != null)
-               {
-                       return convertToPage(fromCache);
-               }
-
-               byte[] data = getPageData(sessionId, pageId);
-               if (data != null)
-               {
-                       return deserializePage(data);
-               }
-               return null;
-       }
-
-       @Override
-       public void removePage(final String sessionId, final int pageId)
-       {
-               pagesCache.removePage(sessionId, pageId);
-               removePageData(sessionId, pageId);
-       }
-
-       @SuppressWarnings("unchecked")
-       @Override
-       public void storePage(final String sessionId, final IManageablePage 
page)
-       {
-               byte[] data = serializePage(page);
-               if (data != null)
-               {
-                       int pageId = page.getPageId();
-                       pagesCache.storePage(sessionId, pageId,  (P) page);
-                       storePageData(sessionId, pageId, data);
-               }
-       }
-
-       @Override
-       public void unbind(final String sessionId)
-       {
-               removePageData(sessionId);
-               pagesCache.removePages(sessionId);
-       }
-
-       @Override
-       public void destroy()
-       {
-               super.destroy();
-               pagesCache.destroy();
-       }
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c43d3a33/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractPageStore.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractPageStore.java 
b/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractPageStore.java
deleted file mode 100644
index 07f97d5..0000000
--- 
a/wicket-core/src/main/java/org/apache/wicket/pageStore/AbstractPageStore.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.pageStore;
-
-import java.io.Serializable;
-
-import org.apache.wicket.page.IManageablePage;
-import org.apache.wicket.serialize.ISerializer;
-import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public abstract class AbstractPageStore implements IPageStore
-{
-       private static final Logger LOG = 
LoggerFactory.getLogger(AbstractPageStore.class);
-
-       protected final IDataStore dataStore;
-
-       /**
-        * The {@link org.apache.wicket.serialize.ISerializer} that will be 
used to convert pages from/to byte arrays
-        */
-       protected final ISerializer pageSerializer;
-
-       protected AbstractPageStore(final ISerializer pageSerializer, final 
IDataStore dataStore)
-       {
-               Args.notNull(pageSerializer, "pageSerializer");
-               Args.notNull(dataStore, "dataStore");
-
-               this.pageSerializer = pageSerializer;
-               this.dataStore = dataStore;
-       }
-
-       @Override
-       public void destroy()
-       {
-               dataStore.destroy();
-       }
-
-       @Override
-       public Serializable prepareForSerialization(final String sessionId, 
final Serializable page)
-       {
-               if (dataStore.isReplicated())
-               {
-                       return null;
-               }
-
-               return page;
-       }
-
-       @Override
-       public Object restoreAfterSerialization(final Serializable serializable)
-       {
-               return serializable;
-       }
-
-       /**
-        * @param sessionId
-        *          The id of the http session
-        * @param pageId
-        *          The id of page which serialized data should be got
-        * @return page data
-        * @see org.apache.wicket.pageStore.IDataStore#getData(String, int)
-        */
-       protected byte[] getPageData(final String sessionId, final int pageId)
-       {
-               return dataStore.getData(sessionId, pageId);
-       }
-
-       /**
-        * @param sessionId
-        *          The id of the http session
-        * @param pageId
-        *          The id of page which serialized data should be removed
-        * @see org.apache.wicket.pageStore.IDataStore#removeData(String, int)
-        */
-       protected void removePageData(final String sessionId, final int pageId)
-       {
-               dataStore.removeData(sessionId, pageId);
-       }
-
-       /**
-        * @param sessionId
-        *          The id of the http session for which all data should be 
removed
-        * @see org.apache.wicket.pageStore.IDataStore#removeData(String)
-        */
-       protected void removePageData(final String sessionId)
-       {
-               dataStore.removeData(sessionId);
-       }
-
-       /**
-        * @param sessionId
-        *          The id of the http session
-        * @param pageId
-        *          The id of the page to store
-        * @param data
-        *          The serialized view of the page
-        * @see org.apache.wicket.pageStore.IDataStore#storeData(String, int, 
byte[])
-        */
-       protected void storePageData(final String sessionId, final int pageId, 
final byte[] data)
-       {
-               dataStore.storeData(sessionId, pageId, data);
-       }
-
-       /**
-        * Serializes the passed page to byte[]
-        *
-        * @param page
-        *          The page to serialize
-        * @return the serialized view of the passed page
-        */
-       protected byte[] serializePage(final IManageablePage page)
-       {
-               Args.notNull(page, "page");
-
-               byte[] data = pageSerializer.serialize(page);
-
-               if (data == null && LOG.isWarnEnabled())
-               {
-                       LOG.warn("Page {} cannot be serialized. See previous 
logs for possible reasons.", page);
-               }
-               return data;
-       }
-
-       /**
-        *
-        * @param data
-        *          The serialized view of the page
-        * @return page data deserialized
-        */
-       protected IManageablePage deserializePage(final byte[] data)
-       {
-               Args.notNull(data, "data");
-
-               return (IManageablePage) pageSerializer.deserialize(data);
-       }
-}

Reply via email to