io.sirix.access.xml.XmlLocalDatabaseModule Maven / Gradle / Ivy
package io.sirix.access.xml;
import dagger.Module;
import dagger.Provides;
import io.sirix.access.*;
import io.sirix.api.Database;
import io.sirix.api.ResourceSession;
import io.sirix.api.TransactionManager;
import io.sirix.api.xml.XmlResourceSession;
import io.sirix.dagger.DatabaseScope;
import javax.inject.Provider;
/**
* The module for {@link XmlLocalDatabaseComponent}.
*
* @author Joao Sousa
*/
@Module(includes = LocalDatabaseModule.class)
public interface XmlLocalDatabaseModule {
@DatabaseScope
@Provides
static ResourceSessionFactory resourceManagerFactory(
final Provider subComponentBuilder) {
return new SubComponentResourceSessionFactory<>(subComponentBuilder);
}
@DatabaseScope
@Provides
static Database xmlDatabase(final TransactionManager transactionManager,
final DatabaseConfiguration dbConfig, final PathBasedPool> sessions,
final ResourceStore resourceStore, final WriteLocksRegistry writeLocks,
final PathBasedPool> resourceManagers) {
return new LocalDatabase<>(transactionManager, dbConfig, sessions, resourceStore, writeLocks, resourceManagers);
}
@DatabaseScope
@Provides
static ResourceStore xmlResourceManager(
final PathBasedPool> allResourceManagers,
final ResourceSessionFactory resourceSessionFactory) {
return new ResourceStoreImpl<>(allResourceManagers, resourceSessionFactory);
}
}