You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2018/12/06 20:31:28 UTC
[08/14] wicket git commit: WICKET-6563 new IPageStore implementation
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-core/src/test/java/org/apache/wicket/versioning/InMemoryPageStore.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/versioning/InMemoryPageStore.java b/wicket-core/src/test/java/org/apache/wicket/versioning/InMemoryPageStore.java
deleted file mode 100644
index f69a918..0000000
--- a/wicket-core/src/test/java/org/apache/wicket/versioning/InMemoryPageStore.java
+++ /dev/null
@@ -1,126 +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.versioning;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.wicket.pageStore.IDataStore;
-
-/**
- * An implementation of {@link IDataStore} that stores the data in memory. Used only for testing
- * purposes.
- *
- * @author martin-g
- */
-public class InMemoryPageStore implements IDataStore
-{
-
- /**
- * A map of : sessionId => pageId => pageAsBytes
- */
- private final ConcurrentHashMap<String, Map<Integer, byte[]>> store;
-
- /**
- * Construct.
- */
- public InMemoryPageStore()
- {
- store = new ConcurrentHashMap<> ();
- }
-
- @Override
- public void destroy()
- {
- store.clear();
- }
-
- /**
- * @see org.apache.wicket.pageStore.IDataStore#getData(java.lang.String, int)
- */
- @Override
- public byte[] getData(String sessionId, int pageId)
- {
- byte[] pageAsBytes = null;
-
- final Map<Integer, byte[]> sessionPages = store.get(sessionId);
- if (sessionPages != null)
- {
- pageAsBytes = sessionPages.get(pageId);
- }
-
- return pageAsBytes;
- }
-
- /**
- * @see org.apache.wicket.pageStore.IDataStore#removeData(java.lang.String, int)
- */
- @Override
- public void removeData(String sessionId, int pageId)
- {
- final Map<Integer, byte[]> sessionPages = store.get(sessionId);
- if (sessionPages != null)
- {
- sessionPages.remove(pageId);
- }
- }
-
- /**
- * @see org.apache.wicket.pageStore.IDataStore#removeData(java.lang.String)
- */
- @Override
- public void removeData(String sessionId)
- {
- store.remove(sessionId);
- }
-
- /**
- * @see org.apache.wicket.pageStore.IDataStore#storeData(java.lang.String, int, byte[])
- */
- @Override
- public void storeData(String sessionId, int pageId, byte[] pageAsBytes)
- {
- Map<Integer, byte[]> sessionPages = store.get(sessionId);
- if (sessionPages == null)
- {
- sessionPages = new ConcurrentHashMap<>();
- Map<Integer, byte[]> tmpSessionPages = store.putIfAbsent(sessionId, sessionPages);
- if (tmpSessionPages != null)
- {
- sessionPages = tmpSessionPages;
- }
- }
-
- sessionPages.put(pageId, pageAsBytes);
- }
-
- /**
- * @see org.apache.wicket.pageStore.IDataStore#isReplicated()
- */
- @Override
- public boolean isReplicated()
- {
- return false;
- }
-
- @Override
- public boolean canBeAsynchronous()
- {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-core/src/test/java/org/apache/wicket/versioning/PageVersioningTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/versioning/PageVersioningTest.java b/wicket-core/src/test/java/org/apache/wicket/versioning/PageVersioningTest.java
index 6f10ada..3842780 100644
--- a/wicket-core/src/test/java/org/apache/wicket/versioning/PageVersioningTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/versioning/PageVersioningTest.java
@@ -22,11 +22,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.wicket.IPageManagerProvider;
import org.apache.wicket.Page;
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.pageStore.DefaultPageStore;
-import org.apache.wicket.pageStore.IDataStore;
+import org.apache.wicket.page.PageManager;
+import org.apache.wicket.pageStore.IPageStore;
+import org.apache.wicket.pageStore.InMemoryPageStore;
+import org.apache.wicket.pageStore.InSessionPageStore;
+import org.apache.wicket.pageStore.SerializingPageStore;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.serialize.java.JavaSerializer;
import org.apache.wicket.util.tester.WicketTester;
@@ -58,21 +58,12 @@ class PageVersioningTest
@Override
protected IPageManagerProvider newTestPageManagerProvider()
{
- return new IPageManagerProvider()
+ return () ->
{
-
- @Override
- public IPageManager apply(IPageManagerContext pageManagerContext)
- {
-
- final IDataStore dataStore = new InMemoryPageStore();
- final AsynchronousDataStore asyncDS = new AsynchronousDataStore(dataStore,
- 100);
- final DefaultPageStore pageStore = new DefaultPageStore(new JavaSerializer(
- application.getApplicationKey()), asyncDS, 40);
- return new PageStoreManager(application.getName(), pageStore,
- pageManagerContext);
- }
+ InMemoryPageStore inMemory = new InMemoryPageStore("test", Integer.MAX_VALUE);
+ SerializingPageStore serializing = new SerializingPageStore(inMemory, new JavaSerializer("test"));
+ final IPageStore store = new InSessionPageStore(serializing, Integer.MAX_VALUE);
+ return new PageManager(store);
};
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java
index ae17d8e..2fcdca3 100644
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java
@@ -38,7 +38,7 @@ public class DebugBarInitializer implements IInitializer
DebugBar.registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, application);
DebugBar.registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, application);
DebugBar.registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
- DebugBar.registerContributor(PageSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
+ DebugBar.registerContributor(PageStoreDebugPanel.DEBUG_BAR_CONTRIB, application);
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/InspectorDebugPanel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/InspectorDebugPanel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/InspectorDebugPanel.java
index 33a0705..4de5cd4 100644
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/InspectorDebugPanel.java
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/InspectorDebugPanel.java
@@ -18,12 +18,13 @@ package org.apache.wicket.devutils.debugbar;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
+import org.apache.wicket.core.util.lang.WicketObjects;
import org.apache.wicket.devutils.inspector.InspectorPage;
import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;
import org.apache.wicket.request.resource.ResourceReference;
+import org.apache.wicket.util.lang.Bytes;
/**
* A panel that adds a link to the inspector to the debug bar.
@@ -73,7 +74,22 @@ public class InspectorDebugPanel extends StandardDebugPanel
@Override
protected IModel<String> getDataModel()
{
- return new Model<>("Inspector");
+ return new IModel<String>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject()
+ {
+ Page enclosingPage = getPage();
+ long pageSize = WicketObjects.sizeof(enclosingPage);
+ Bytes pageSizeInBytes = (pageSize > -1 ? Bytes.bytes(pageSize) : null);
+ String pageSizeAsString = pageSizeInBytes != null ? pageSizeInBytes.toString()
+ : "unknown";
+
+ return "Page: " + pageSizeAsString;
+ }
+ };
}
@Override
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageSizeDebugPanel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageSizeDebugPanel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageSizeDebugPanel.java
deleted file mode 100644
index f386783..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageSizeDebugPanel.java
+++ /dev/null
@@ -1,104 +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.devutils.debugbar;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.core.util.lang.WicketObjects;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-import org.apache.wicket.util.lang.Bytes;
-
-/**
- * A panel for the debug bar that shows the size of the currently shown page.
- * <p>
- * <strong>Note</strong>: this size includes the size of the debug bar itself too!
- */
-public class PageSizeDebugPanel extends StandardDebugPanel
-{
- private static final long serialVersionUID = 1L;
-
- /** */
- public static final IDebugBarContributor DEBUG_BAR_CONTRIB = new IDebugBarContributor()
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component createComponent(final String id, final DebugBar debugBar)
- {
- return new PageSizeDebugPanel(id);
- }
-
- };
-
- /**
- * Construct.
- *
- * @param id
- */
- public PageSizeDebugPanel(final String id)
- {
- super(id);
- }
-
- @Override
- protected Class<? extends Page> getLinkPageClass()
- {
- // not used
- return WebPage.class;
- }
-
- // Disable the link because there is no page with more detailed information
- @Override
- protected BookmarkablePageLink<Void> createLink(final String id)
- {
- BookmarkablePageLink<Void> bookmarkablePageLink = super.createLink(id);
- bookmarkablePageLink.setEnabled(false);
- return bookmarkablePageLink;
- }
-
- @Override
- protected ResourceReference getImageResourceReference()
- {
- // TODO: need better image for this:
- return new PackageResourceReference(SessionSizeDebugPanel.class, "harddrive.png");
- }
-
- @Override
- protected IModel<String> getDataModel()
- {
- return new IModel<String>()
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getObject()
- {
- Page enclosingPage = getPage();
- long pageSize = WicketObjects.sizeof(enclosingPage);
- Bytes pageSizeInBytes = (pageSize > -1 ? Bytes.bytes(pageSize) : null);
- String pageSizeAsString = pageSizeInBytes != null ? pageSizeInBytes.toString()
- : "unknown";
-
- return "Page: " + pageSizeAsString;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageStoreDebugPanel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageStoreDebugPanel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageStoreDebugPanel.java
new file mode 100644
index 0000000..9cc5a06
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/PageStoreDebugPanel.java
@@ -0,0 +1,84 @@
+/*
+ * 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.devutils.debugbar;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.devutils.diskstore.PageStorePage;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.pageStore.IPersistentPageStore;
+import org.apache.wicket.request.resource.PackageResourceReference;
+import org.apache.wicket.request.resource.ResourceReference;
+
+/**
+ * A panel that adds a link to persisted pages to the debug bar.
+ */
+public class PageStoreDebugPanel extends StandardDebugPanel
+{
+ private static final long serialVersionUID = 1L;
+
+ /** */
+ public static final IDebugBarContributor DEBUG_BAR_CONTRIB = new IDebugBarContributor()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component createComponent(final String id, final DebugBar debugBar)
+ {
+ return new PageStoreDebugPanel(id);
+ }
+ };
+
+ /**
+ * Construct.
+ *
+ * @param id
+ * The component id
+ */
+ public PageStoreDebugPanel(final String id)
+ {
+ super(id);
+ }
+
+ @Override
+ protected Class<? extends Page> getLinkPageClass()
+ {
+ return PageStorePage.class;
+ }
+
+ @Override
+ protected ResourceReference getImageResourceReference()
+ {
+ return new PackageResourceReference(PageStoreDebugPanel.class, "harddrive.png");
+ }
+
+ @Override
+ protected IModel<String> getDataModel()
+ {
+ return new IModel<String>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject()
+ {
+ IPersistentPageStore store = PageStorePage.getPersistentPageStore();
+ return String.format("Persisted pages: %s", store == null ? "N/A" : store.getTotalSize());
+ }
+ };
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/StandardDebugPanel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/StandardDebugPanel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/StandardDebugPanel.java
index c88499e..921b009 100644
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/StandardDebugPanel.java
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/StandardDebugPanel.java
@@ -50,7 +50,7 @@ public abstract class StandardDebugPanel extends DevUtilsPanel
protected void onInitialize()
{
super.onInitialize();
- BookmarkablePageLink<Void> link = createLink("link");
+ WebMarkupContainer link = createLink("link");
add(link);
ResourceReference img = getImageResourceReference();
if (img == null)
@@ -64,7 +64,7 @@ public abstract class StandardDebugPanel extends DevUtilsPanel
link.add(new Label("data", getDataModel()));
}
- protected BookmarkablePageLink<Void> createLink(final String id)
+ protected WebMarkupContainer createLink(final String id)
{
return new BookmarkablePageLink<>(id, getLinkPageClass(), getLinkPageParameters());
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugDiskDataStore.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugDiskDataStore.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugDiskDataStore.java
deleted file mode 100644
index 9c3d882..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugDiskDataStore.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.devutils.diskstore;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.pageStore.DiskDataStore;
-import org.apache.wicket.pageStore.PageWindowManager;
-import org.apache.wicket.pageStore.PageWindowManager.PageWindow;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.util.lang.Bytes;
-
-/**
- * An extension of {@link DiskDataStore} that is able to browse the content of the file storage.
- * <p>
- * To enable it add in YourApplication#init():
- *
- * <pre>
- * <code>
- * DebugDiskDataStore.register(this);
- * </code>
- * </pre>
- *
- * </p>
- * <p>
- * The data can be browsed at: <em>/wicket/internal/debug/diskDataStore</em>
- */
-public class DebugDiskDataStore extends DiskDataStore
-{
-
- /**
- * Construct.
- *
- * @param applicationName
- * @param fileStoreFolder
- * @param maxSizePerSession
- */
- public DebugDiskDataStore(String applicationName, File fileStoreFolder, Bytes maxSizePerSession)
- {
- super(applicationName, fileStoreFolder, maxSizePerSession);
-
- }
-
- /**
- *
- * @param sessionId
- * @param count
- * @return a list of the last N page windows
- */
- public List<PageWindow> getLastPageWindows(String sessionId, int count)
- {
- List<PageWindow> pageWindows = new ArrayList<>();
-
- SessionEntry sessionEntry = getSessionEntry(sessionId, false);
- if (sessionEntry != null)
- {
- PageWindowManager windowManager = sessionEntry.getManager();
- pageWindows.addAll(windowManager.getLastPageWindows(count));
- }
- return pageWindows;
- }
-
- @Override
- public File getStoreFolder()
- {
- return super.getStoreFolder();
- }
-
- /**
- * Configures the page manager provider and mounts the page at
- * <em>wicket/internal/debug/diskDataStore</em>
- *
- * @param application
- */
- public static void register(final Application application)
- {
- application.setPageManagerProvider(new DebugPageManagerProvider(application));
-
- ((WebApplication)application).mountPage("wicket/internal/debug/diskDataStore",
- DiskStoreBrowserPage.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugPageManagerProvider.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugPageManagerProvider.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugPageManagerProvider.java
deleted file mode 100644
index 7893638..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DebugPageManagerProvider.java
+++ /dev/null
@@ -1,63 +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.devutils.diskstore;
-
-import java.io.File;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.DefaultPageManagerProvider;
-import org.apache.wicket.pageStore.DiskDataStore;
-import org.apache.wicket.pageStore.IDataStore;
-import org.apache.wicket.settings.StoreSettings;
-import org.apache.wicket.util.lang.Bytes;
-
-/**
- */
-public class DebugPageManagerProvider extends DefaultPageManagerProvider
-{
-
- private DebugDiskDataStore dataStore;
-
- /**
- * Construct.
- *
- * @param application
- */
- public DebugPageManagerProvider(Application application)
- {
- super(application);
- }
-
- /**
- * @return the extended with debug information {@link DiskDataStore}
- */
- public DebugDiskDataStore getDataStore()
- {
- return dataStore;
- }
-
- @Override
- protected IDataStore newDataStore()
- {
- StoreSettings storeSettings = application.getStoreSettings();
- File fileStoreFolder = storeSettings.getFileStoreFolder();
- Bytes maxSizePerSession = storeSettings.getMaxSizePerSession();
- dataStore = new DebugDiskDataStore(application.getName(), fileStoreFolder,
- maxSizePerSession);
- return dataStore;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.html
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.html b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.html
deleted file mode 100644
index 307884c..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
-
- <head>
- <title>Debug DiskDataStore page</title>
- </head>
-
- <body>
-
- <div wicket:id="tree">default</div>
-
- </body>
-
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.java
deleted file mode 100644
index 066f9e6..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/DiskStoreBrowserPage.java
+++ /dev/null
@@ -1,51 +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.devutils.diskstore;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.devutils.diskstore.browser.BrowserPanel;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-/**
- * A page that shows the attributes (id, name, size) of the pages stored in the data stores.
- */
-public class DiskStoreBrowserPage extends WebPage
-{
-
- /**
- * Construct.
- *
- * @param parameters
- * the request parameters
- */
- public DiskStoreBrowserPage(final PageParameters parameters)
- {
- super(parameters);
-
- Component tree;
-// tree = new LabelTree("tree", new PageWindowModel(sessionId, dataStore));
- tree = new BrowserPanel("tree");
- add(tree);
- }
-
- @Override
- public boolean isVersioned()
- {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.html
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.html b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.html
new file mode 100644
index 0000000..bf62ef7
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.html
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+
+ <head>
+ <title>Debug DiskDataStore page</title>
+ </head>
+
+ <body>
+
+ <div wicket:id="persisted"></div>
+
+ </body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.java
new file mode 100644
index 0000000..6a0d6c7
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/PageStorePage.java
@@ -0,0 +1,68 @@
+/*
+ * 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.devutils.diskstore;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.devutils.diskstore.browser.PersistedPanel;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.pageStore.DelegatingPageStore;
+import org.apache.wicket.pageStore.IPageStore;
+import org.apache.wicket.pageStore.IPersistentPageStore;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+/**
+ * A page that shows the attributes (id, name, size) of the pages stored in the data stores.
+ */
+public class PageStorePage extends WebPage
+{
+
+ /**
+ * Construct.
+ *
+ * @param parameters
+ * the request parameters
+ */
+ public PageStorePage(final PageParameters parameters)
+ {
+ super(parameters);
+
+ add(new PersistedPanel("persisted", PageStorePage::getPersistentPageStore));
+ }
+
+ @Override
+ public boolean isVersioned()
+ {
+ return false;
+ }
+
+ public static IPersistentPageStore getPersistentPageStore() {
+ IPageStore store = Session.get().getPageManager().getPageStore();
+ while (true) {
+ if (store instanceof IPersistentPageStore) {
+ return (IPersistentPageStore)store;
+ }
+
+ if (store instanceof DelegatingPageStore) {
+ store = ((DelegatingPageStore)store).getDelegate();
+ } else {
+ break;
+ }
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.html
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.html b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.html
deleted file mode 100644
index aba3252..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
-<wicket:panel>
-
- <h3>Active sessions</h3>
- <select wicket:id="sessions"></select> <a wicket:id="currentSessionLink" title="Selects the current session">Current session</a>
-
- <h3>Stored pages</h3> <a wicket:id="refresh" title="Refreshes the content of the table below">refresh</a>
- <table wicket:id="table" border="1" cellpadding="3" cellspacing="1"></table>
-
-</wicket:panel>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.java
deleted file mode 100644
index 51cd5f7..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserPanel.java
+++ /dev/null
@@ -1,133 +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.devutils.diskstore.browser;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.markup.html.form.DropDownChoice;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.time.Duration;
-
-/**
- * A panel that shows the data about pages in the data store
- */
-public class BrowserPanel extends Panel
-{
-
- /**
- * Construct.
- *
- * @param id
- * the component id
- */
- public BrowserPanel(String id)
- {
- super(id);
-
- final DropDownChoice<String> sessionsSelector = createSessionsSelector("sessions");
- add(sessionsSelector);
-
- final BrowserTable table = createTable("table", sessionsSelector.getModel());
- add(table);
-
- AjaxFallbackLink<Void> refreshLink = new AjaxFallbackLink<Void>("refresh")
- {
- @Override
- public void onClick(Optional<AjaxRequestTarget> targetOptional)
- {
- targetOptional.ifPresent(target -> target.add(table));
- }
- };
- add(refreshLink);
-
- AjaxFallbackLink<Void> currentSessionLink = new AjaxFallbackLink<Void>("currentSessionLink")
- {
- @Override
- public void onClick(Optional<AjaxRequestTarget> targetOptional)
- {
- sessionsSelector.setModelObject(getCurrentSession().getObject());
- targetOptional.ifPresent(target -> target.add(sessionsSelector, table));
- }
-
- @Override
- public boolean isVisible()
- {
- return BrowserPanel.this.getSession().isTemporary() == false;
- }
- };
- currentSessionLink.setOutputMarkupPlaceholderTag(true);
- add(currentSessionLink);
-
- sessionsSelector.add(new AjaxFormComponentUpdatingBehavior("change")
- {
- @Override
- protected void onUpdate(AjaxRequestTarget target)
- {
- target.add(table);
- }
- });
- }
-
- private DropDownChoice<String> createSessionsSelector(String id)
- {
- IModel<String> defaultSession = getCurrentSession();
-
- DropDownChoice<String> sessionsSelector = new DropDownChoice<String>("sessions",
- defaultSession, new SessionsProviderModel());
-
-
- return sessionsSelector;
- }
-
- private IModel<String> getCurrentSession()
- {
- return Model.of(getSession().getId());
- }
-
- private BrowserTable createTable(String id, IModel<String> sessionId)
- {
- PageWindowProvider provider = new PageWindowProvider(sessionId);
-
- List<IColumn<PageWindowDescription, String>> columns = new ArrayList<>();
-
- PageWindowColumn pageIdColumn = new PageWindowColumn(Model.of("Id"), "id");
- columns.add(pageIdColumn);
-
- PageWindowColumn pageNameColumn = new PageWindowColumn(Model.of("Name"), "name");
- columns.add(pageNameColumn);
-
- PageWindowColumn pageSizeColumn = new PageWindowColumn(Model.of("Size"), "size");
- columns.add(pageSizeColumn);
-
- BrowserTable browserTable = new BrowserTable(id, columns, provider);
- browserTable.setOutputMarkupId(true);
-
- browserTable.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
-
- return browserTable;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserTable.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserTable.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserTable.java
deleted file mode 100644
index 264d88a..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/BrowserTable.java
+++ /dev/null
@@ -1,47 +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.devutils.diskstore.browser;
-
-import java.util.List;
-
-import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-
-/**
- * A data table that shows the attributes of the recently stored pages in the data store. The last
- * used pages are rendered first.
- */
-class BrowserTable extends DefaultDataTable<PageWindowDescription, String>
-{
-
- /**
- * Construct.
- *
- * @param id
- * the component id
- * @param columns
- * the columns that show the page attributes
- * @param provider
- * the provider of page descriptions
- */
- public BrowserTable(String id, List<IColumn<PageWindowDescription, String>> columns,
- PageWindowProvider provider)
- {
- super(id, columns, provider, 20);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/DataStoreHelper.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/DataStoreHelper.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/DataStoreHelper.java
deleted file mode 100644
index ff4bf67..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/DataStoreHelper.java
+++ /dev/null
@@ -1,43 +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.devutils.diskstore.browser;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.devutils.diskstore.DebugDiskDataStore;
-import org.apache.wicket.devutils.diskstore.DebugPageManagerProvider;
-
-/**
- * A helper to work with {@link DebugDiskDataStore}
- */
-public final class DataStoreHelper
-{
-
- private DataStoreHelper()
- {
- }
-
- /**
- * @return the configured {@link DebugDiskDataStore}
- */
- public static DebugDiskDataStore getDataStore()
- {
- DebugPageManagerProvider pageManagerProvider = (DebugPageManagerProvider)Application.get()
- .getPageManagerProvider();
- DebugDiskDataStore dataStore = pageManagerProvider.getDataStore();
- return dataStore;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowColumn.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowColumn.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowColumn.java
deleted file mode 100644
index ea21877..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowColumn.java
+++ /dev/null
@@ -1,80 +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.devutils.diskstore.browser;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.devutils.diskstore.DebugDiskDataStore;
-import org.apache.wicket.devutils.diskstore.DebugPageManagerProvider;
-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.repeater.Item;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.serialize.ISerializer;
-
-/**
- * A column that shows the page attributes (id, name, size)
- */
-class PageWindowColumn extends PropertyColumn<PageWindowDescription, String>
-{
- /**
- * Construct.
- *
- * @param displayModel
- * the header
- * @param propertyExpression
- * the page attribute
- */
- public PageWindowColumn(IModel<String> displayModel, String propertyExpression)
- {
- super(displayModel, propertyExpression);
- }
-
- @Override
- public void populateItem(Item<ICellPopulator<PageWindowDescription>> cellItem,
- String componentId, IModel<PageWindowDescription> rowModel)
- {
- String label;
- PageWindowDescription windowDescription = rowModel.getObject();
- if ("name".equals(getPropertyExpression()))
- {
- int pageId = windowDescription.getId();
- DebugPageManagerProvider pageManagerProvider = (DebugPageManagerProvider)Application.get()
- .getPageManagerProvider();
- DebugDiskDataStore dataStore = pageManagerProvider.getDataStore();
- String sessionId = windowDescription.getSessionId();
- byte[] data = dataStore.getData(sessionId, pageId);
- ISerializer serializer = Application.get().getFrameworkSettings().getSerializer();
- Object page = serializer.deserialize(data);
- label = page.getClass().getName();
- }
- else if ("id".equals(getPropertyExpression()))
- {
- label = Integer.toString(windowDescription.getId());
- }
- else if ("size".equals(getPropertyExpression()))
- {
- label = Integer.toString(windowDescription.getSize());
- }
- else
- {
- label = "unknown: " + getPropertyExpression();
- }
-
- cellItem.add(new Label(componentId, label));
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowDescription.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowDescription.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowDescription.java
deleted file mode 100644
index b07c005..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowDescription.java
+++ /dev/null
@@ -1,57 +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.devutils.diskstore.browser;
-
-import org.apache.wicket.pageStore.PageWindowManager.PageWindow;
-import org.apache.wicket.util.io.IClusterable;
-
-/**
- * A serializable representation of the page information
- */
-class PageWindowDescription implements IClusterable
-{
- /** the page id */
- private final int id;
-
- /** the page size */
- private final int size;
-
- /** the id of the session for which this page has been used */
- private final String sessionId;
-
- PageWindowDescription(PageWindow pageWindow, String sessionId)
- {
- id = pageWindow.getPageId();
- size = pageWindow.getFilePartSize();
- this.sessionId = sessionId;
- }
-
- public String getSessionId()
- {
- return sessionId;
- }
-
- public int getId()
- {
- return id;
- }
-
- public int getSize()
- {
- return size;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowProvider.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowProvider.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowProvider.java
deleted file mode 100644
index dd8397c..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PageWindowProvider.java
+++ /dev/null
@@ -1,108 +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.devutils.diskstore.browser;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.wicket.devutils.diskstore.DebugDiskDataStore;
-import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
-import org.apache.wicket.markup.repeater.data.IDataProvider;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.pageStore.PageWindowManager.PageWindow;
-
-/**
- * An {@link IDataProvider} that extracts the information about the stored pages
- */
-class PageWindowProvider implements ISortableDataProvider<PageWindowDescription, String>
-{
- private static final int MAX_PAGES_TO_READ = 1000;
-
- /**
- * The model that brings the currently selected session id
- */
- private final IModel<String> sessionId;
-
- PageWindowProvider(final IModel<String> sessionId)
- {
- this.sessionId = sessionId;
- }
-
- @Override
- public Iterator<? extends PageWindowDescription> iterator(long first, long count)
- {
- List<PageWindow> lastPageWindows = getPageWindows();
- List<PageWindow> subList = lastPageWindows.subList((int)first, (int)(first + count));
- List<PageWindowDescription> pageDescriptions = new ArrayList<>();
- for (PageWindow pw : subList)
- {
- pageDescriptions.add(new PageWindowDescription(pw, sessionId.getObject()));
- }
-
- return pageDescriptions.iterator();
- }
-
- private List<PageWindow> getPageWindows()
- {
- List<PageWindow> lastPageWindows = new ArrayList<>();
- if (sessionId != null && sessionId.getObject() != null)
- {
- String sessId = sessionId.getObject();
- DebugDiskDataStore dataStore = DataStoreHelper.getDataStore();
- List<PageWindow> pageWindows = dataStore.getLastPageWindows(sessId, MAX_PAGES_TO_READ);
- lastPageWindows.addAll(pageWindows);
- }
- return lastPageWindows;
- }
-
- @Override
- public long size()
- {
- return getPageWindows().size();
- }
-
- /**
- * @param description
- *
- * {@inheritDoc}
- */
- @Override
- public IModel<PageWindowDescription> model(PageWindowDescription description)
- {
- return new Model<>(description);
- }
-
- @Override
- public void detach()
- {
- sessionId.detach();
- }
-
- /*
- * No sort state for now. The provider is ISortableDataProvider just because we use
- * DefaultDataTable
- */
- @Override
- public ISortState<String> getSortState()
- {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPagesProvider.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPagesProvider.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPagesProvider.java
new file mode 100644
index 0000000..62abfaf
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPagesProvider.java
@@ -0,0 +1,133 @@
+/*
+ * 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.devutils.diskstore.browser;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.wicket.core.util.lang.PropertyResolver;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.pageStore.IPersistedPage;
+import org.apache.wicket.pageStore.IPersistentPageStore;
+import org.apache.wicket.util.lang.Objects;
+
+/**
+ * An {@link IDataProvider} that extracts the information about {@link IPersistedPage}s.
+ */
+class PersistedPagesProvider extends SortableDataProvider<IPersistedPage, String>
+{
+ /**
+ * The model that brings the currently selected session id
+ */
+ private final IModel<String> sessionId;
+
+ private final IModel<IPersistentPageStore> store;
+
+ private List<IPersistedPage> pages;
+
+ PersistedPagesProvider(final IModel<String> sessionId, IModel<IPersistentPageStore> store)
+ {
+ this.sessionId = sessionId;
+ this.store = store;
+ }
+
+ @Override
+ public Iterator<? extends IPersistedPage> iterator(long first, long count)
+ {
+ List<IPersistedPage> pages = getPages();
+
+ if (getSort() != null) {
+ Collections.sort(pages, new SortComparator());
+ }
+
+ return pages.iterator();
+ }
+
+ private List<IPersistedPage> getPages()
+ {
+ if (pages == null)
+ {
+ pages = new ArrayList<>();
+
+ if (sessionId.getObject() != null)
+ {
+ String sessId = sessionId.getObject();
+
+ IPersistentPageStore persistentPagesStore = store.getObject();
+
+ if (persistentPagesStore != null)
+ {
+ pages.addAll(persistentPagesStore.getPersistentPages(sessId));
+ }
+ }
+ }
+
+ return pages;
+ }
+
+ @Override
+ public long size()
+ {
+ return getPages().size();
+ }
+
+ /**
+ * @param description
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public IModel<IPersistedPage> model(IPersistedPage description)
+ {
+ return new Model<>(description);
+ }
+
+ @Override
+ public void detach()
+ {
+ sessionId.detach();
+ store.detach();
+
+ pages = null;
+ }
+
+ private class SortComparator implements Comparator<IPersistedPage>
+ {
+
+ @Override
+ public int compare(IPersistedPage page0, IPersistedPage page1)
+ {
+ Object value0 = PropertyResolver.getValue(getSort().getProperty(), page0);
+ Object value1 = PropertyResolver.getValue(getSort().getProperty(), page1);
+
+ int c = Objects.compareWithConversion(value0, value1);
+
+ if (getSort().isAscending() == false)
+ {
+ c = c * -1;
+ }
+
+ return c;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.html
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.html b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.html
new file mode 100644
index 0000000..c4ac731
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.html
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+<wicket:panel>
+
+ <h3>Persistent store</h3>
+ <span wicket:id="store"></span>
+
+ <h3>Persisted sessions</h3>
+ <select wicket:id="sessions"></select> <a wicket:id="currentSessionLink" title="Selects the current session">Current session</a>
+
+ <h3>Persisted pages</h3> <a wicket:id="refresh" title="Refreshes the content of the table below">refresh</a>
+ <table wicket:id="table"></table>
+
+</wicket:panel>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.java
new file mode 100644
index 0000000..4705f5d
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/PersistedPanel.java
@@ -0,0 +1,201 @@
+/*
+ * 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.devutils.diskstore.browser;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.wicket.PageReference;
+import org.apache.wicket.Session;
+import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
+import org.apache.wicket.devutils.inspector.InspectorPage;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.GenericPanel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.pageStore.DefaultPageContext;
+import org.apache.wicket.pageStore.IPageContext;
+import org.apache.wicket.pageStore.IPersistedPage;
+import org.apache.wicket.pageStore.IPersistentPageStore;
+import org.apache.wicket.util.time.Duration;
+
+/**
+ * A panel that shows data about {@link IPersistedPage}s in an {@link IPersistentPageStore}.
+ */
+public class PersistedPanel extends GenericPanel<IPersistentPageStore>
+{
+
+ /**
+ * Construct.
+ *
+ * @param id
+ * the component id
+ */
+ public PersistedPanel(String id, IModel<IPersistentPageStore> store)
+ {
+ super(id, store);
+
+ final Label storeLabel = new Label("store", () -> {
+ IPersistentPageStore s = getModelObject();
+
+ if (s == null) {
+ return "N/A";
+ }
+
+ return String.format("%s - %s", s.getClass().getName(), s.getTotalSize());
+ });
+ storeLabel.setOutputMarkupId(true);
+ add(storeLabel);
+
+ final DropDownChoice<String> sessionsSelector = createSessionsSelector("sessions");
+ sessionsSelector.setOutputMarkupId(true);
+ add(sessionsSelector);
+
+ final DataTable<IPersistedPage, String> table = createTable("table", sessionsSelector.getModel());
+ table.setOutputMarkupId(true);
+ add(table);
+
+ AjaxFallbackLink<Void> refreshLink = new AjaxFallbackLink<Void>("refresh")
+ {
+ @Override
+ public void onClick(Optional<AjaxRequestTarget> targetOptional)
+ {
+ targetOptional.ifPresent(target -> target.add(table));
+ }
+ };
+ add(refreshLink);
+
+ AjaxFallbackLink<Void> currentSessionLink = new AjaxFallbackLink<Void>("currentSessionLink")
+ {
+ @Override
+ public void onClick(Optional<AjaxRequestTarget> targetOptional)
+ {
+ sessionsSelector.setModelObject(getCurrentSessionIdentifier());
+ targetOptional.ifPresent(target -> target.add(sessionsSelector, table));
+ }
+
+ @Override
+ public boolean isVisible()
+ {
+ return PersistedPanel.this.getSession().isTemporary() == false;
+ }
+ };
+ currentSessionLink.setOutputMarkupPlaceholderTag(true);
+ add(currentSessionLink);
+
+ sessionsSelector.add(new AjaxFormComponentUpdatingBehavior("change")
+ {
+ @Override
+ protected void onUpdate(AjaxRequestTarget target)
+ {
+ target.add(storeLabel);
+ target.add(sessionsSelector);
+ target.add(table);
+ }
+ });
+
+ add(new AbstractAjaxTimerBehavior(Duration.seconds(5)) {
+
+ @Override
+ protected void onTimer(AjaxRequestTarget target)
+ {
+ target.add(storeLabel);
+ target.add(table);
+ }
+ });
+ }
+
+ private DropDownChoice<String> createSessionsSelector(String id)
+ {
+ DropDownChoice<String> sessionsSelector = new DropDownChoice<String>("sessions",
+ Model.of(getCurrentSessionIdentifier()), new SessionIdentifiersModel(getModel()));
+
+ return sessionsSelector;
+ }
+
+ private String getCurrentSessionIdentifier()
+ {
+ IPersistentPageStore store = getModelObject();
+ if (store == null) {
+ return null;
+ }
+
+ IPageContext context = new DefaultPageContext(Session.get());
+
+ return store.getContextIdentifier(context);
+ }
+
+ private DataTable<IPersistedPage, String> createTable(String id, IModel<String> sessionId)
+ {
+ PersistedPagesProvider provider = new PersistedPagesProvider(sessionId, getModel());
+
+ List<IColumn<IPersistedPage, String>> columns = new ArrayList<>();
+
+ columns.add(new AbstractColumn<IPersistedPage, String>(Model.of("Id"), "pageId")
+ {
+ @Override
+ public void populateItem(Item<ICellPopulator<IPersistedPage>> cellItem, String componentId, IModel<IPersistedPage> rowModel)
+ {
+ cellItem.add(new Link<IPersistedPage>(componentId, rowModel)
+ {
+ @Override
+ protected void onComponentTag(ComponentTag tag)
+ {
+ tag.setName("a");
+
+ super.onComponentTag(tag);
+ }
+
+ @Override
+ public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
+ {
+ replaceComponentTagBody(markupStream, openTag, "" + getModelObject().getPageId());
+ }
+
+ @Override
+ public void onClick()
+ {
+ setResponsePage(new InspectorPage(new PageReference(getModelObject().getPageId())));
+ }
+ });
+ }
+ });
+ columns.add(new PropertyColumn<>(Model.of("Type"), "pageType", "pageType"));
+ columns.add(new PropertyColumn<>(Model.of("Size"), "pageSize", "pageSize"));
+
+ DefaultDataTable<IPersistedPage, String> browserTable = new DefaultDataTable<>(id, columns, provider, 20);
+ browserTable.setOutputMarkupId(true);
+
+ return browserTable;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionIdentifiersModel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionIdentifiersModel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionIdentifiersModel.java
new file mode 100644
index 0000000..06592b9
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionIdentifiersModel.java
@@ -0,0 +1,73 @@
+/*
+ * 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.devutils.diskstore.browser;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.pageStore.DefaultPageContext;
+import org.apache.wicket.pageStore.DiskPageStore;
+import org.apache.wicket.pageStore.IPageContext;
+import org.apache.wicket.pageStore.IPersistentPageStore;
+
+/**
+ * A model that collects the keys from the {@link DiskPageStore} folder
+ */
+public class SessionIdentifiersModel extends LoadableDetachableModel<List<String>>
+{
+ private final IModel<IPersistentPageStore> store;
+
+ public SessionIdentifiersModel(IModel<IPersistentPageStore> store)
+ {
+ this.store = store;
+ }
+
+ @Override
+ protected List<String> load()
+ {
+ IPersistentPageStore store = this.store.getObject();
+ if (store == null)
+ {
+ return Collections.emptyList();
+ }
+
+ ArrayList<String> identifiers = new ArrayList<>(store.getContextIdentifiers());
+
+ IPageContext context = new DefaultPageContext(Session.get());
+ String current = store.getContextIdentifier(context);
+ if (identifiers.contains(current) == false)
+ {
+ // identifiers of the store seem no to match their sessions ids,
+ // thus add the default identifier so the select works properly
+ identifiers.add(current);
+ }
+
+ return identifiers;
+ }
+
+ @Override
+ public void detach()
+ {
+ super.detach();
+
+ store.detach();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionsProviderModel.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionsProviderModel.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionsProviderModel.java
deleted file mode 100644
index 6638303..0000000
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/diskstore/browser/SessionsProviderModel.java
+++ /dev/null
@@ -1,57 +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.devutils.diskstore.browser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.devutils.diskstore.DebugDiskDataStore;
-import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.pageStore.DiskDataStore;
-
-/**
- * A model that collects the session ids from the {@link DiskDataStore} folder
- */
-public class SessionsProviderModel extends LoadableDetachableModel<List<String>>
-{
-
- @Override
- protected List<String> load()
- {
- List<String> sessionIds = new ArrayList<>();
- if (Application.exists())
- {
- DebugDiskDataStore dataStore = DataStoreHelper.getDataStore();
- File appStoreFolder = dataStore.getStoreFolder();
- if (appStoreFolder.isDirectory())
- {
- String[] sessionIdFileNames = appStoreFolder.list();
- if (sessionIdFileNames != null)
- {
- for (String sessionId : sessionIdFileNames)
- {
- sessionIds.add(sessionId);
- }
- }
- }
- }
-
- return sessionIds;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/EnhancedPageView.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/EnhancedPageView.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/EnhancedPageView.java
index 2710327..61deca5 100644
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/EnhancedPageView.java
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/EnhancedPageView.java
@@ -86,42 +86,13 @@ public final class EnhancedPageView extends GenericPanel<Page>
*
* @param id
* See Component
- * @param page
+ * @param model
* The page to be analyzed
*/
- public EnhancedPageView(String id, Page page)
+ public EnhancedPageView(String id, IModel<Page> model)
{
- this(id, getModelFor(page == null ? null : page.getPageReference()));
- }
-
- private static IModel<Page> getModelFor(final PageReference pageRef)
- {
- return new LoadableDetachableModel<Page>()
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected Page load()
- {
- if (pageRef == null)
- return null;
- Page page = pageRef.getPage();
- return page;
- }
- };
- }
-
- /**
- * Constructor.
- *
- * @param id
- * See Component
- * @param pageModel
- * The page to be analyzed
- */
- public EnhancedPageView(String id, IModel<Page> pageModel)
- {
- super(id, pageModel);
+ super(id, model);
+
expandState = new ExpandState();
expandState.expandAll();
showStatefulAndParentsOnly = false;
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/InspectorPage.java
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/InspectorPage.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/InspectorPage.java
index 023583d..0ab7837 100644
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/InspectorPage.java
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/inspector/InspectorPage.java
@@ -18,15 +18,15 @@ package org.apache.wicket.devutils.inspector;
import org.apache.wicket.Application;
import org.apache.wicket.Page;
+import org.apache.wicket.PageReference;
import org.apache.wicket.Session;
import org.apache.wicket.devutils.DevUtilsPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.page.IManageablePage;
+import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;
-import org.apache.wicket.util.string.StringValueConversionException;
/**
@@ -47,23 +47,19 @@ public final class InspectorPage extends DevUtilsPage
*/
public InspectorPage(final PageParameters parameters)
{
+ this(new PageReference(parameters.get("pageId").toInt()));
+ }
+
+ public InspectorPage(PageReference reference)
+ {
add(new ApplicationView("application", Application.get()));
add(new SessionView("session", Session.get()));
- IManageablePage page = null;
- try
- {
- final int pageId = parameters.get("pageId").toInt();
- page = Session.get().getPageManager().getPage(pageId);
- }
- catch (StringValueConversionException e)
- {
- // Ignore
- }
- catch (NullPointerException e)
- {
- // Ignore
- }
- add(new EnhancedPageView("page", (Page)page));
+
+ IModel<Page> page = () -> {
+ return reference.getPage();
+ };
+
+ add(new EnhancedPageView("page", page));
add(new Image("bug", new PackageResourceReference(InspectorPage.class, "bug.png")));
add(new BookmarkablePageLink<>("allsessions", LiveSessionsPage.class));
add(new Label("wicketVersion", getApplication().getFrameworkSettings().getVersion()));
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-examples/src/main/java/org/apache/wicket/examples/frames/BodyFrame.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/frames/BodyFrame.java b/wicket-examples/src/main/java/org/apache/wicket/examples/frames/BodyFrame.java
index 3896404..f557a59 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/frames/BodyFrame.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/frames/BodyFrame.java
@@ -16,10 +16,10 @@
*/
package org.apache.wicket.examples.frames;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.core.request.handler.PageProvider;
import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.IRequestHandler;
/**
@@ -41,7 +41,7 @@ public class BodyFrame extends WebPage
{
// create a new page instance, passing this 'master page' as an argument
LeftFrame leftFrame = new LeftFrame(this);
- getSession().getPageManager().touchPage(leftFrame);
+ getSession().getPageManager().addPage(leftFrame);
// get the url to that page
IRequestHandler leftFrameHandler = new RenderPageRequestHandler(new PageProvider(leftFrame));
// and create a simple component that modifies it's src attribute to
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java b/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
index 18e6c26..9f08961 100644
--- a/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
+++ b/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.examples;
+import java.io.File;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
@@ -28,6 +29,8 @@ import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
+import org.eclipse.jetty.server.session.DefaultSessionCache;
+import org.eclipse.jetty.server.session.FileSessionDataStore;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
@@ -97,12 +100,18 @@ public class StartExamples
bb.setContextPath("/");
bb.setWar("src/main/webapp");
+ // uncomment next lines if you want to test with session persistence
+// DefaultSessionCache sessionCache = new DefaultSessionCache(bb.getSessionHandler());
+// FileSessionDataStore sessionStore = new FileSessionDataStore();
+// sessionStore.setStoreDir(new File("./jetty-session-data"));
+// sessionCache.setSessionDataStore(sessionStore);
+// bb.getSessionHandler().setSessionCache(sessionCache);
+
ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb);
serverContainer.addEndpoint(new WicketServerEndpointConfig());
// uncomment next line if you want to test with JSESSIONID encoded in the urls
- // ((AbstractSessionManager)
- // bb.getSessionHandler().getSessionManager()).setUsingCookies(false);
+// ((AbstractSessionManager) bb.getSessionHandler().getSessionManager()).setUsingCookies(false);
server.setHandler(bb);
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
index a8a70ef..8302650 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
@@ -16,7 +16,6 @@
*/
package org.apache.wicket.extensions.ajax.markup.html.modal;
-import com.github.openjson.JSONObject;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.WicketRuntimeException;
@@ -45,6 +44,8 @@ import org.apache.wicket.util.io.IClusterable;
import org.apache.wicket.util.lang.EnumeratedType;
import org.apache.wicket.util.string.AppendingStringBuffer;
+import com.github.openjson.JSONObject;
+
/**
* Modal window component.
* <p>
@@ -1043,7 +1044,7 @@ public class ModalWindow extends Panel
CharSequence pageUrl;
RequestCycle requestCycle = RequestCycle.get();
- page.getSession().getPageManager().touchPage(page);
+ page.getSession().getPageManager().addPage(page);
if (page.isPageStateless())
{
pageUrl = requestCycle.urlFor(page.getClass(), page.getPageParameters());
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
----------------------------------------------------------------------
diff --git a/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java b/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
index 7f40a26..079019e 100644
--- a/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
+++ b/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
@@ -16,8 +16,7 @@
*/
package org.apache.wicket.jmx;
-import org.apache.wicket.pageStore.DiskDataStore;
-import org.apache.wicket.pageStore.IDataStore;
+import org.apache.wicket.pageStore.DiskPageStore;
/**
* JMX MBean for Application's StoreSettings
@@ -26,19 +25,13 @@ public interface StoreSettingsMBean
{
/**
- * @return the number of page instances which will be stored in the http session for faster
- * retrieval
- */
- int getInmemoryCacheSize();
-
- /**
- * @return maximum page size. After this size is exceeded, the {@link DiskDataStore} will start
+ * @return maximum page size. After this size is exceeded, the {@link DiskPageStore} will start
* saving the pages at the beginning of file.
*/
long getMaxSizePerSession();
/**
- * @return the location of the folder where {@link DiskDataStore} will store the files with page
+ * @return the location of the folder where {@link DiskPageStore} will store the files with page
* instances per session
*/
String getFileStoreFolder();
@@ -50,7 +43,7 @@ public interface StoreSettingsMBean
/**
* @return {@code true} when the HTTP worker thread doesn't wait for the storing of the page's
- * bytes in {@link IDataStore}
+ * bytes in {@link IPageStore}
*/
boolean isAsynchronous();
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/StoreSettings.java
----------------------------------------------------------------------
diff --git a/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/StoreSettings.java b/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/StoreSettings.java
index 9a658fd..b40793e 100644
--- a/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/StoreSettings.java
+++ b/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/StoreSettings.java
@@ -37,12 +37,6 @@ public class StoreSettings implements StoreSettingsMBean
}
@Override
- public int getInmemoryCacheSize()
- {
- return application.getStoreSettings().getInmemoryCacheSize();
- }
-
- @Override
public long getMaxSizePerSession()
{
return application.getStoreSettings().getMaxSizePerSession().bytes();
http://git-wip-us.apache.org/repos/asf/wicket/blob/3f364e71/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java
index ca3569d..d3c9d4f 100644
--- a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java
+++ b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java
@@ -300,7 +300,7 @@ public abstract class AbstractWebSocketProcessor implements IWebSocketProcessor
{
if (Session.exists())
{
- Session.get().getPageManager().commitRequest();
+ Session.get().getPageManager().detach();
}
}
});