use of org.apache.wicket.page.IManageablePage in project wicket by apache.
the class AsynchronousPageStoreTest method storeReturnsSameInstanceOnClosePageRequest.
/**
* Store returns the same page instance from queue when there is a close request for it back
* again.
*
* @throws InterruptedException
*/
@Test
public void storeReturnsSameInstanceOnClosePageRequest() throws InterruptedException {
ISerializer serializer = new DeflatedJavaSerializer("applicationKey");
// ISerializer serializer = new DummySerializer();
IDataStore dataStore = new DiskDataStore("applicationName", new File("./target"), Bytes.bytes(10000l));
// IPageStore pageStore = new DummyPageStore(new File("target/store"));
IPageStore pageStore = spy(new DefaultPageStore(serializer, dataStore, 0));
IPageStore asyncPageStore = new AsynchronousPageStore(pageStore, 100);
int pageId = 0;
String sessionId = "sessionId";
DummyPage page = new DummyPage(pageId, 1000, 1000, sessionId);
asyncPageStore.storePage(sessionId, page);
Thread.sleep(500);
IManageablePage pageBack = asyncPageStore.getPage(sessionId, pageId);
verify(pageStore, never()).getPage(sessionId, pageId);
assertEquals(page, pageBack);
}
use of org.apache.wicket.page.IManageablePage in project wicket by apache.
the class DefaultPageStore method prepareForSerialization.
@Override
public Serializable prepareForSerialization(final String sessionId, final Serializable page) {
if (dataStore.isReplicated()) {
return null;
}
SerializedPage result = null;
if (page instanceof IManageablePage) {
IManageablePage _page = (IManageablePage) page;
result = pagesCache.getPage(sessionId, _page.getPageId());
if (result == null) {
result = createSerializedPage(sessionId, _page);
if (result != null) {
pagesCache.storePage(sessionId, _page.getPageId(), result);
}
}
} else if (page instanceof SerializedPage) {
SerializedPage _page = (SerializedPage) page;
if (_page.getData() == null) {
result = restoreStrippedSerializedPage(_page);
} else {
result = _page;
}
}
if (result != null) {
return result;
}
return page;
}
use of org.apache.wicket.page.IManageablePage in project wicket by apache.
the class DefaultMapperContext method getPageInstance.
@Override
public IRequestablePage getPageInstance(final int pageId) {
IManageablePage manageablePage = Session.get().getPageManager().getPage(pageId);
IRequestablePage requestablePage = null;
if (manageablePage instanceof IRequestablePage) {
requestablePage = (IRequestablePage) manageablePage;
}
return requestablePage;
}
use of org.apache.wicket.page.IManageablePage in project wicket by apache.
the class TransparentWebMarkupContainerTest method ajaxUpdate.
/**
* Test case for <a href="https://issues.apache.org/jira/browse/WICKET-3719">WICKET-3719</a>
*/
@Test
public void ajaxUpdate() {
WicketTester wicketTester = new WicketTester() {
@Override
protected IPageManagerProvider newTestPageManagerProvider() {
return new IPageManagerProvider() {
@Override
public IPageManager apply(IPageManagerContext context) {
return new MockPageManager() {
@Override
public void touchPage(IManageablePage page) {
page = WicketObjects.cloneObject(page);
super.touchPage(page);
}
};
}
};
}
};
wicketTester.startPage(TransparentWithAjaxUpdatePage.class);
wicketTester.clickLink("link", true);
wicketTester.destroy();
}
use of org.apache.wicket.page.IManageablePage in project wicket by apache.
the class AsynchronousPageStore method getPage.
@Override
public IManageablePage getPage(String sessionId, int pageId) {
Entry entry = getEntry(sessionId, pageId);
if (entry != null) {
log.debug("Returning the page of a non-stored entry with session id '{}' and page id '{}'", sessionId, pageId);
return entry.page;
}
IManageablePage page = delegate.getPage(sessionId, pageId);
log.debug("Returning the page of a stored entry with session id '{}' and page id '{}'", sessionId, pageId);
return page;
}
Aggregations