imported MongoOptionsFactory from cnr-mongo-mdstore

This commit is contained in:
Claudio Atzori 2019-07-24 11:08:00 +02:00
parent 14a4a544e7
commit 213d3b3012
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package eu.dnetlib.mongodb;
import com.mongodb.MongoClientOptions;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
public class MongoOptionsFactory implements FactoryBean<MongoClientOptions> {
private int connectionsPerHost;
@Override
public MongoClientOptions getObject() throws BeansException {
return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
}
@Override
public Class<MongoClientOptions> getObjectType() {
return MongoClientOptions.class;
}
@Override
public boolean isSingleton() {
return false;
}
public int getConnectionsPerHost() {
return connectionsPerHost;
}
public void setConnectionsPerHost(int connectionsPerHost) {
this.connectionsPerHost = connectionsPerHost;
}
}