Class MongoClientWrapper

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    @Beta
    @Deprecated(forRemoval=true,
                since="1.2.1")
    @KiwiDeprecated(since="1.2.1",
                    removeAt="2.0.0",
                    reference="https://github.com/kiwiproject/kiwi/issues/658")
    public class MongoClientWrapper
    extends Object
    implements Closeable
    Deprecated, for removal: This API element is subject to removal in a future version.
    with no replacement since we no longer support the older Mongo 3.x driver versions and our code must therefore use only the new Mongo APIs (i.e. com.mongodb.DB doesn't exist in the Mongo 4.x drivers).
    A wrapper around a MongoClient that also provides MongoDatabase and DB instances for a specific database, which is specified in the constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      MongoClientWrapper​(String mongoUri, String databaseName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new instance with the given Mongo connection URI.
    • Constructor Detail

      • MongoClientWrapper

        public MongoClientWrapper​(String mongoUri,
                                  String databaseName)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Create a new instance with the given Mongo connection URI. Uses databaseName to get both MongoDatabase and DB instances, which are available from this instance via their getter methods.
        Parameters:
        mongoUri - the Mongo connection URI
        databaseName - the database associated with this instance
    • Method Detail

      • getDB

        public com.mongodb.DB getDB()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Return the (deprecated) DB instance for clients that have not yet migrated to MongoDatabase.
        Returns:
        the DB instance associated with this instance (as specified in the constructor)
      • close

        public void close()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Closes the wrapper MongoClient.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable