Class SimpleMongoClientDatabaseFactory

java.lang.Object
org.springframework.data.mongodb.core.MongoDatabaseFactorySupport<com.mongodb.client.MongoClient>
org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory
All Implemented Interfaces:
DisposableBean, CodecRegistryProvider, MongoDatabaseFactory, MongoSessionProvider

public class SimpleMongoClientDatabaseFactory extends MongoDatabaseFactorySupport<com.mongodb.client.MongoClient> implements DisposableBean
Factory to create MongoDatabase instances from a MongoClient instance.
Since:
3.0
Author:
Christoph Strobl
  • Constructor Details

    • SimpleMongoClientDatabaseFactory

      public SimpleMongoClientDatabaseFactory(String connectionString)
      Creates a new SimpleMongoClientDatabaseFactory instance for the given connectionString. Using this constructor will create a new MongoClient instance that will be closed when calling MongoDatabaseFactorySupport.destroy().
      Parameters:
      connectionString - connection coordinates for a database connection. Must contain a database name and must not be null or empty.
      See Also:
    • SimpleMongoClientDatabaseFactory

      public SimpleMongoClientDatabaseFactory(com.mongodb.ConnectionString connectionString)
      Creates a new SimpleMongoClientDatabaseFactory instance from the given MongoClient. Using this constructor will create a new MongoClient instance that will be closed when calling MongoDatabaseFactorySupport.destroy().
      Parameters:
      connectionString - connection coordinates for a database connection. Must contain also a database name and not be null.
    • SimpleMongoClientDatabaseFactory

      public SimpleMongoClientDatabaseFactory(com.mongodb.client.MongoClient mongoClient, String databaseName)
      Creates a new SimpleMongoClientDatabaseFactory instance from the given MongoClient. Note that the client will not be closed when calling MongoDatabaseFactorySupport.destroy() as we assume a managed client instance that we do not want to close on MongoDatabaseFactorySupport.destroy() meaning that you (or the application container) must dispose the client instance once it is no longer required for use.
      Parameters:
      mongoClient - must not be null.
      databaseName - must not be null or empty.
  • Method Details