Class MongoClients


  • @Deprecated
    public final class MongoClients
    extends Object
    Deprecated.
    Prefer the Reactive Streams-based asynchronous driver (mongodb-driver-reactivestreams artifactId)
    A factory for MongoClient instances.
    Since:
    3.0
    • Method Detail

      • create

        public static MongoClient create()
        Deprecated.
        Creates a new client with the default connection string "mongodb://localhost".
        Returns:
        the client
      • create

        public static MongoClient create​(com.mongodb.ConnectionString connectionString)
        Deprecated.
        Create a new client with the given connection string.

        For each of the settings classed configurable via MongoClientSettings, the connection string is applied by calling the applyConnectionString method on an instance of setting's builder class, building the setting, and adding it to an instance of MongoClientSettings.Builder.

        The connection string's stream type is then applied by setting the StreamFactory to an instance of NettyStreamFactory,

        Parameters:
        connectionString - the settings
        Returns:
        the client
        Throws:
        IllegalArgumentException - if the connection string's stream type is not one of "netty" or "nio2"
        See Also:
        ConnectionString.getStreamType(), MongoClientSettings.Builder, ClusterSettings.Builder.applyConnectionString(ConnectionString), ConnectionPoolSettings.Builder.applyConnectionString(ConnectionString), ServerSettings.Builder.applyConnectionString(ConnectionString), SslSettings.Builder.applyConnectionString(ConnectionString), SocketSettings.Builder.applyConnectionString(ConnectionString)
      • create

        @Deprecated
        public static MongoClient create​(MongoClientSettings settings,
                                         @Nullable
                                         com.mongodb.MongoDriverInformation mongoDriverInformation)
        Creates a new client with the given client settings.

        Note: Intended for driver and library authors to associate extra driver metadata with the connections.

        Parameters:
        settings - the settings
        mongoDriverInformation - any driver information to associate with the MongoClient
        Returns:
        the client
        Since:
        3.4
      • create

        public static MongoClient create​(com.mongodb.ConnectionString connectionString,
                                         @Nullable
                                         com.mongodb.MongoDriverInformation mongoDriverInformation)
        Deprecated.
        Create a new client with the given connection string.

        Note: Intended for driver and library authors to associate extra driver metadata with the connections.

        Parameters:
        connectionString - the settings
        mongoDriverInformation - any driver information to associate with the MongoClient
        Returns:
        the client
        Throws:
        IllegalArgumentException - if the connection string's stream type is not one of "netty" or "nio2"
        See Also:
        create(ConnectionString)
      • create

        public static MongoClient create​(com.mongodb.MongoClientSettings settings)
        Deprecated.
        Create a new client with the given client settings.
        Parameters:
        settings - the settings
        Returns:
        the client
        Since:
        3.7
      • create

        public static MongoClient create​(com.mongodb.MongoClientSettings settings,
                                         @Nullable
                                         com.mongodb.MongoDriverInformation mongoDriverInformation)
        Deprecated.
        Creates a new client with the given client settings.

        Note: Intended for driver and library authors to associate extra driver metadata with the connections.

        Parameters:
        settings - the settings
        mongoDriverInformation - any driver information to associate with the MongoClient
        Returns:
        the client
        Since:
        3.7
      • getDefaultCodecRegistry

        public static org.bson.codecs.configuration.CodecRegistry getDefaultCodecRegistry()
        Deprecated.
        Gets the default codec registry. It includes the following providers:
        • ValueCodecProvider
        • BsonValueCodecProvider
        • DBRefCodecProvider
        • DBObjectCodecProvider
        • DocumentCodecProvider
        • IterableCodecProvider
        • MapCodecProvider
        • GeoJsonCodecProvider
        • GridFSFileCodecProvider
        • Jsr310CodecProvider
        • BsonCodecProvider
        Returns:
        the default codec registry
        Since:
        3.1
        See Also:
        MongoClientSettings.getCodecRegistry()