com.github.aidensuen.mongo.session.impl.DefaultMongoSessionFactory Maven / Gradle / Ivy
package com.github.aidensuen.mongo.session.impl;
import com.github.aidensuen.mongo.session.Configuration;
import com.github.aidensuen.mongo.session.ExecutorType;
import com.github.aidensuen.mongo.session.MongoSession;
import com.github.aidensuen.mongo.session.MongoSessionFactory;
import org.springframework.data.mongodb.core.MongoOperations;
public class DefaultMongoSessionFactory implements MongoSessionFactory {
private final Configuration configuration;
private final MongoOperations mongoOperations;
public DefaultMongoSessionFactory(Configuration configuration, MongoOperations mongoOperations) {
this.configuration = configuration;
this.mongoOperations = mongoOperations;
}
@Override
public MongoSession getMongoSession() {
return getMongoSession(this.configuration.getDefaultExecutorType());
}
@Override
public MongoSession getMongoSession(ExecutorType executorType) {
return new DefaultMongoSession(mongoOperations, configuration, this.configuration.newExecutor(mongoOperations, executorType));
}
@Override
public Configuration getConfiguration() {
return this.configuration;
}
}