Search in sources :

Example 1 with ProviderConfig

use of com.enonic.xp.blob.ProviderConfig in project xp by enonic.

the class BlobStoreFactory method execute.

BlobStore execute() {
    final BlobStore providerStore = provider.get();
    final ProviderConfig config = provider.config();
    final BlobStore builtStore = populateWithReadThroughIfApplicable(config, providerStore);
    if (!this.config.cache()) {
        return builtStore;
    }
    return CachedBlobStore.create().memoryCapacity(this.config.memoryCapacity()).sizeTreshold(this.config.cacheSizeThreshold()).blobStore(builtStore).build();
}
Also used : ProviderConfig(com.enonic.xp.blob.ProviderConfig) CachedBlobStore(com.enonic.xp.internal.blobstore.cache.CachedBlobStore) ReadThroughBlobStore(com.enonic.xp.internal.blobstore.readthrough.ReadThroughBlobStore) BlobStore(com.enonic.xp.blob.BlobStore)

Example 2 with ProviderConfig

use of com.enonic.xp.blob.ProviderConfig in project xp by enonic.

the class BlobStoreActivatorTest method activate.

@Test
public void activate() throws Exception {
    final BlobStoreConfig blobStoreConfig = Mockito.mock(BlobStoreConfig.class);
    Mockito.when(blobStoreConfig.providerName()).thenReturn("file");
    final MemoryBlobStore blobStore = new MemoryBlobStore();
    final MemoryBlobStoreProvider provider = new MemoryBlobStoreProvider("memoey", blobStore, new ProviderConfig() {

        @Override
        public String readThroughProvider() {
            return null;
        }

        @Override
        public boolean readThroughEnabled() {
            return false;
        }

        @Override
        public long readThroughSizeThreshold() {
            return 0;
        }

        @Override
        public boolean isValid() {
            return true;
        }
    });
    final BundleContext bundleContext = Mockito.mock(BundleContext.class);
    final BlobStoreActivator blobStoreActivator = new BlobStoreActivator();
    blobStoreActivator.addProvider(provider);
    blobStoreActivator.setConfig(blobStoreConfig);
    blobStoreActivator.activate(bundleContext);
    final BundleContext context = Mockito.mock(BundleContext.class);
    blobStoreActivator.activate(context);
}
Also used : ProviderConfig(com.enonic.xp.blob.ProviderConfig) BlobStoreConfig(com.enonic.xp.internal.blobstore.config.BlobStoreConfig) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.jupiter.api.Test)

Aggregations

ProviderConfig (com.enonic.xp.blob.ProviderConfig)2 BlobStore (com.enonic.xp.blob.BlobStore)1 CachedBlobStore (com.enonic.xp.internal.blobstore.cache.CachedBlobStore)1 BlobStoreConfig (com.enonic.xp.internal.blobstore.config.BlobStoreConfig)1 ReadThroughBlobStore (com.enonic.xp.internal.blobstore.readthrough.ReadThroughBlobStore)1 Test (org.junit.jupiter.api.Test)1 BundleContext (org.osgi.framework.BundleContext)1