All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.zhengframework.mongodb.MongoClientProvider Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.github.zhengframework.mongodb;

import com.mongodb.ConnectionString;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;

@Singleton
public class MongoClientProvider implements Provider {

  private final MongodbConfig mongodbConfig;

  @Inject
  public MongoClientProvider(MongodbConfig mongodbConfig) {
    this.mongodbConfig = mongodbConfig;
  }

  @Override
  public MongoClient get() {
    ConnectionString connectionString = new ConnectionString(mongodbConfig.getUrl());
    return MongoClients.create(connectionString);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy