Search in sources :

Example 1 with DeflatedJavaSerializer

use of org.apache.wicket.serialize.java.DeflatedJavaSerializer in project oc-explorer by devgateway.

the class FormsWebApplication method optimizeForWebPerformance.

/**
 * optimize wicket for a better web performance This will be invoked if the
 * application is started with -Dwicket.configuration=deployment
 */
private void optimizeForWebPerformance() {
    // add javascript files at the bottom of the page
    setHeaderResponseDecorator(new RenderJavaScriptToFooterHeaderResponseDecorator("scripts-bucket"));
    // The default is Development, so this code is not used
    if (usesDeploymentConfig()) {
        getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("-v-", new CachingResourceVersion(new Adler32ResourceVersion())));
        getResourceSettings().setJavaScriptCompressor(new GoogleClosureJavaScriptCompressor(CompilationLevel.SIMPLE_OPTIMIZATIONS));
        getResourceSettings().setCssCompressor(new YuiCssCompressor());
        getFrameworkSettings().setSerializer(new DeflatedJavaSerializer(getApplicationKey()));
        getMarkupSettings().setStripComments(true);
    } else {
        getResourceSettings().setCachingStrategy(new NoOpResourceCachingStrategy());
    }
    getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) RenderJavaScriptToFooterHeaderResponseDecorator(de.agilecoders.wicket.core.markup.html.RenderJavaScriptToFooterHeaderResponseDecorator) DeflatedJavaSerializer(org.apache.wicket.serialize.java.DeflatedJavaSerializer) NoOpResourceCachingStrategy(org.apache.wicket.request.resource.caching.NoOpResourceCachingStrategy) Adler32ResourceVersion(de.agilecoders.wicket.core.request.resource.caching.version.Adler32ResourceVersion) GoogleClosureJavaScriptCompressor(de.agilecoders.wicket.extensions.javascript.GoogleClosureJavaScriptCompressor) CachingResourceVersion(org.apache.wicket.request.resource.caching.version.CachingResourceVersion) YuiCssCompressor(de.agilecoders.wicket.extensions.javascript.YuiCssCompressor)

Example 2 with DeflatedJavaSerializer

use of org.apache.wicket.serialize.java.DeflatedJavaSerializer 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 3 with DeflatedJavaSerializer

use of org.apache.wicket.serialize.java.DeflatedJavaSerializer in project ocvn by devgateway.

the class FormsWebApplication method optimizeForWebPerformance.

/**
 * optimize wicket for a better web performance This will be invoked if the
 * application is started with -Dwicket.configuration=deployment
 */
private void optimizeForWebPerformance() {
    // add javascript files at the bottom of the page
    setHeaderResponseDecorator(new RenderJavaScriptToFooterHeaderResponseDecorator("scripts-bucket"));
    // The default is Development, so this code is not used
    if (usesDeploymentConfig()) {
        getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("-v-", new CachingResourceVersion(new Adler32ResourceVersion())));
        getResourceSettings().setJavaScriptCompressor(new GoogleClosureJavaScriptCompressor(CompilationLevel.SIMPLE_OPTIMIZATIONS));
        getResourceSettings().setCssCompressor(new YuiCssCompressor());
        getFrameworkSettings().setSerializer(new DeflatedJavaSerializer(getApplicationKey()));
        getMarkupSettings().setStripComments(true);
    } else {
        getResourceSettings().setCachingStrategy(new NoOpResourceCachingStrategy());
    }
    getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) RenderJavaScriptToFooterHeaderResponseDecorator(de.agilecoders.wicket.core.markup.html.RenderJavaScriptToFooterHeaderResponseDecorator) DeflatedJavaSerializer(org.apache.wicket.serialize.java.DeflatedJavaSerializer) NoOpResourceCachingStrategy(org.apache.wicket.request.resource.caching.NoOpResourceCachingStrategy) Adler32ResourceVersion(de.agilecoders.wicket.core.request.resource.caching.version.Adler32ResourceVersion) GoogleClosureJavaScriptCompressor(de.agilecoders.wicket.extensions.javascript.GoogleClosureJavaScriptCompressor) CachingResourceVersion(org.apache.wicket.request.resource.caching.version.CachingResourceVersion) YuiCssCompressor(de.agilecoders.wicket.extensions.javascript.YuiCssCompressor)

Example 4 with DeflatedJavaSerializer

use of org.apache.wicket.serialize.java.DeflatedJavaSerializer in project wicket by apache.

the class AsynchronousPageStoreTest method runTest.

private List<Metrics> runTest(int sessions, int pages, long writeMillis, long readMillis, int asyncPageStoreCapacity) throws InterruptedException {
    List<Metrics> results = new ArrayList<>();
    final CountDownLatch lock = new CountDownLatch(pages * sessions);
    // ISerializer serializer = new DummySerializer();
    ISerializer serializer = new DeflatedJavaSerializer("applicationKey");
    IDataStore dataStore = new DiskDataStore("applicationName", new File("./target"), Bytes.bytes(10000l));
    // IPageStore pageStore = new DummyPageStore(new File("target/store")) {
    IPageStore pageStore = new DefaultPageStore(serializer, dataStore, 0) {

        @Override
        public void storePage(String sessionId, IManageablePage page) {
            super.storePage(sessionId, page);
            lock.countDown();
        }
    };
    IPageStore asyncPageStore = new AsynchronousPageStore(pageStore, asyncPageStoreCapacity);
    Stopwatch stopwatch = Stopwatch.createUnstarted();
    for (int pageId = 1; pageId <= pages; pageId++) {
        for (int i = 1; i <= sessions; i++) {
            String sessionId = String.valueOf(i);
            Metrics metrics = new Metrics();
            stopwatch.reset();
            DummyPage page = new DummyPage(pageId, around(writeMillis), around(readMillis), sessionId);
            stopwatch.start();
            asyncPageStore.storePage(sessionId, page);
            metrics.storedPage = page;
            metrics.storingMillis = stopwatch.elapsed(TimeUnit.MILLISECONDS);
            stopwatch.reset();
            stopwatch.start();
            metrics.restoredPage = DummyPage.class.cast(asyncPageStore.getPage(sessionId, pageId));
            metrics.restoringMillis = stopwatch.elapsed(TimeUnit.MILLISECONDS);
            results.add(metrics);
        }
    }
    lock.await(pages * sessions * (writeMillis + readMillis), TimeUnit.MILLISECONDS);
    return results;
}
Also used : ArrayList(java.util.ArrayList) Stopwatch(com.google.common.base.Stopwatch) CountDownLatch(java.util.concurrent.CountDownLatch) 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)

Example 5 with DeflatedJavaSerializer

use of org.apache.wicket.serialize.java.DeflatedJavaSerializer in project wicket by apache.

the class AsynchronousPageStoreTest method storeReturnsRestoredInstanceOnDistantPageRequest.

/**
 * Store returns the restored page instance from wrapped store when there is a distant request
 * for it back again.
 *
 * @throws InterruptedException
 */
@Test
public void storeReturnsRestoredInstanceOnDistantPageRequest() 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(1500);
    IManageablePage pageBack = asyncPageStore.getPage(sessionId, pageId);
    verify(pageStore, times(1)).getPage(sessionId, pageId);
    assertNotEquals(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)

Aggregations

DeflatedJavaSerializer (org.apache.wicket.serialize.java.DeflatedJavaSerializer)5 IManageablePage (org.apache.wicket.page.IManageablePage)3 ISerializer (org.apache.wicket.serialize.ISerializer)3 File (org.apache.wicket.util.file.File)3 RenderJavaScriptToFooterHeaderResponseDecorator (de.agilecoders.wicket.core.markup.html.RenderJavaScriptToFooterHeaderResponseDecorator)2 Adler32ResourceVersion (de.agilecoders.wicket.core.request.resource.caching.version.Adler32ResourceVersion)2 GoogleClosureJavaScriptCompressor (de.agilecoders.wicket.extensions.javascript.GoogleClosureJavaScriptCompressor)2 YuiCssCompressor (de.agilecoders.wicket.extensions.javascript.YuiCssCompressor)2 FilenameWithVersionResourceCachingStrategy (org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy)2 NoOpResourceCachingStrategy (org.apache.wicket.request.resource.caching.NoOpResourceCachingStrategy)2 CachingResourceVersion (org.apache.wicket.request.resource.caching.version.CachingResourceVersion)2 Test (org.junit.Test)2 Stopwatch (com.google.common.base.Stopwatch)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1