Search in sources :

Example 1 with StoreSettings

use of org.apache.wicket.settings.StoreSettings in project wicket by apache.

the class DiskDataStoreTest method sessionFolderName.

/**
 * https://issues.apache.org/jira/browse/WICKET-4478
 *
 * Tests that the folder where a session data is put is partitioned, i.e.
 * it is put in folders which names are automatically calculated on the fly.
 */
@Test
public void sessionFolderName() {
    StoreSettings storeSettings = new StoreSettings(null);
    java.io.File fileStoreFolder = storeSettings.getFileStoreFolder();
    DiskDataStore store = new DiskDataStore("sessionFolderName", fileStoreFolder, MAX_SIZE_PER_SESSION);
    String sessionId = "abcdefg";
    java.io.File sessionFolder = store.getSessionFolder(sessionId, true);
    String absolutePath = sessionFolder.getAbsolutePath();
    assertTrue(absolutePath.contains("sessionFolderName-filestore"));
    assertTrue(absolutePath.contains("7141"));
    assertTrue(absolutePath.contains("1279"));
    assertTrue(absolutePath.contains("abcdefg"));
    DiskDataStore.SessionEntry sessionEntry = new DiskDataStore.SessionEntry(store, sessionId);
    sessionEntry.unbind();
    // assert that the 'sessionId' folder and the parents two levels up are removed
    assertFalse(sessionFolder.getParentFile().getParentFile().exists());
}
Also used : StoreSettings(org.apache.wicket.settings.StoreSettings) Test(org.junit.Test)

Example 2 with StoreSettings

use of org.apache.wicket.settings.StoreSettings in project wicket by apache.

the class DefaultPageManagerProvider method apply.

@Override
public IPageManager apply(IPageManagerContext pageManagerContext) {
    IDataStore dataStore = newDataStore();
    StoreSettings storeSettings = getStoreSettings();
    IPageStore pageStore;
    if (dataStore.canBeAsynchronous() && storeSettings.isAsynchronous()) {
        int capacity = storeSettings.getAsynchronousQueueCapacity();
        dataStore = new AsynchronousDataStore(dataStore, capacity);
        pageStore = newPageStore(dataStore);
        if (pageStore.canBeAsynchronous()) {
            pageStore = new AsynchronousPageStore(pageStore, capacity);
        }
    } else {
        pageStore = newPageStore(dataStore);
    }
    return new PageStoreManager(application.getName(), pageStore, pageManagerContext);
}
Also used : StoreSettings(org.apache.wicket.settings.StoreSettings) IPageStore(org.apache.wicket.pageStore.IPageStore) PageStoreManager(org.apache.wicket.page.PageStoreManager) AsynchronousDataStore(org.apache.wicket.pageStore.AsynchronousDataStore) AsynchronousPageStore(org.apache.wicket.pageStore.AsynchronousPageStore) IDataStore(org.apache.wicket.pageStore.IDataStore)

Example 3 with StoreSettings

use of org.apache.wicket.settings.StoreSettings in project wicket by apache.

the class DebugPageManagerProvider method newDataStore.

@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;
}
Also used : StoreSettings(org.apache.wicket.settings.StoreSettings) Bytes(org.apache.wicket.util.lang.Bytes) File(java.io.File)

Example 4 with StoreSettings

use of org.apache.wicket.settings.StoreSettings in project wicket by apache.

the class DiskDataStoreTest method store.

/**
 * store()
 */
@Test
public void store() {
    generateFiles();
    StoreSettings storeSettings = new StoreSettings(null);
    java.io.File fileStoreFolder = storeSettings.getFileStoreFolder();
    dataStore = new DiskDataStore("app1", fileStoreFolder, MAX_SIZE_PER_SESSION);
    int asynchronousQueueCapacity = storeSettings.getAsynchronousQueueCapacity();
    dataStore = new AsynchronousDataStore(dataStore, asynchronousQueueCapacity);
    doTestDataStore();
    dataStore.destroy();
}
Also used : StoreSettings(org.apache.wicket.settings.StoreSettings) Test(org.junit.Test)

Example 5 with StoreSettings

use of org.apache.wicket.settings.StoreSettings in project wicket by apache.

the class DefaultPageManagerProvider method newDataStore.

protected IDataStore newDataStore() {
    StoreSettings storeSettings = getStoreSettings();
    Bytes maxSizePerSession = storeSettings.getMaxSizePerSession();
    File fileStoreFolder = storeSettings.getFileStoreFolder();
    return new DiskDataStore(application.getName(), fileStoreFolder, maxSizePerSession);
}
Also used : StoreSettings(org.apache.wicket.settings.StoreSettings) Bytes(org.apache.wicket.util.lang.Bytes) DiskDataStore(org.apache.wicket.pageStore.DiskDataStore) File(java.io.File)

Aggregations

StoreSettings (org.apache.wicket.settings.StoreSettings)5 File (java.io.File)2 Bytes (org.apache.wicket.util.lang.Bytes)2 Test (org.junit.Test)2 PageStoreManager (org.apache.wicket.page.PageStoreManager)1 AsynchronousDataStore (org.apache.wicket.pageStore.AsynchronousDataStore)1 AsynchronousPageStore (org.apache.wicket.pageStore.AsynchronousPageStore)1 DiskDataStore (org.apache.wicket.pageStore.DiskDataStore)1 IDataStore (org.apache.wicket.pageStore.IDataStore)1 IPageStore (org.apache.wicket.pageStore.IPageStore)1