Search in sources :

Example 1 with IManageablePage

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);
}
Also used : DeflatedJavaSerializer(org.apache.wicket.serialize.java.DeflatedJavaSerializer) File(org.apache.wicket.util.file.File) IManageablePage(org.apache.wicket.page.IManageablePage) ISerializer(org.apache.wicket.serialize.ISerializer) Test(org.junit.Test)

Example 2 with IManageablePage

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;
}
Also used : IManageablePage(org.apache.wicket.page.IManageablePage)

Example 3 with IManageablePage

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;
}
Also used : IRequestablePage(org.apache.wicket.request.component.IRequestablePage) IManageablePage(org.apache.wicket.page.IManageablePage)

Example 4 with IManageablePage

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();
}
Also used : MockPageManager(org.apache.wicket.mock.MockPageManager) WicketTester(org.apache.wicket.util.tester.WicketTester) IPageManagerProvider(org.apache.wicket.IPageManagerProvider) IManageablePage(org.apache.wicket.page.IManageablePage) IPageManagerContext(org.apache.wicket.page.IPageManagerContext) Test(org.junit.Test)

Example 5 with IManageablePage

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;
}
Also used : IManageablePage(org.apache.wicket.page.IManageablePage)

Aggregations

IManageablePage (org.apache.wicket.page.IManageablePage)9 Test (org.junit.Test)4 ISerializer (org.apache.wicket.serialize.ISerializer)3 DeflatedJavaSerializer (org.apache.wicket.serialize.java.DeflatedJavaSerializer)3 File (org.apache.wicket.util.file.File)3 IPageManagerProvider (org.apache.wicket.IPageManagerProvider)2 MockPageManager (org.apache.wicket.mock.MockPageManager)2 IPageManagerContext (org.apache.wicket.page.IPageManagerContext)2 WicketTester (org.apache.wicket.util.tester.WicketTester)2 Stopwatch (com.google.common.base.Stopwatch)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Component (org.apache.wicket.Component)1 IComponentInstantiationListener (org.apache.wicket.application.IComponentInstantiationListener)1 Behavior (org.apache.wicket.behavior.Behavior)1 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)1