io.sirix.access.SubComponentResourceSessionFactory Maven / Gradle / Ivy
package io.sirix.access;
import io.sirix.cache.BufferManager;
import io.sirix.api.NodeReadOnlyTrx;
import io.sirix.api.NodeTrx;
import io.sirix.api.ResourceSession;
import javax.inject.Provider;
import java.nio.file.Path;
/**
* A parameterizable resource session factory that creates {@link ResourceSession} instances based on
* {@link GenericResourceSessionComponent a resource session subcomponent}.
*
* @author Joao Sousa
*/
public class SubComponentResourceSessionFactory, R extends ResourceSession extends NodeReadOnlyTrx, ? extends NodeTrx>>
implements ResourceSessionFactory {
private final Provider subComponentBuilder;
public SubComponentResourceSessionFactory(final Provider subComponentBuilder) {
this.subComponentBuilder = subComponentBuilder;
}
@Override
public R create(final ResourceConfiguration resourceConfig, final BufferManager bufferManager,
final Path resourceFile) {
return this.subComponentBuilder.get()
.resourceConfig(resourceConfig)
.bufferManager(bufferManager)
.resourceFile(resourceFile)
.build()
.resourceManager();
}
}