Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2707

Add new MongoClient interface that doesn't include the legacy API

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • API
    • None

    Description

      The current MongoClient API for the synchronous driver is a class that resides in the com.mongodb package in the driver module. It includes entry points to both the standard CRUD API via the getDatabase method as well as the legacy CRUD API via the deprecated getDB method. This was a reasonable approach when the 3.0 driver was released because we imagined that applications would slowly shift from the legacy API to the standard API, DAO by DAO, and it made sense for all of them to share a single MongoClient instance in order to avoid the overhead of two connection pools, two SDAM monitors, etc.

      While this is still a valid use case, most new applications never touch the legacy API, and we don't even refer to it in the reference documentation. Furthermore, including both APIs in a single module means that we will be unable to create modular JAR files that work properly as Java 9 modules. That's because the Java 9 module system prohibits the same package from being included in multiple modules, and currently the Java driver has such a split of the com.mongodb package. The mongodb-driver-core JAR file contains foundational classes used within core, as well as the sync and async drivers, including

      • ReadPreference
      • ReadConcern
      • WriteConcern

      while the mongodb-driver JAR file contains core classes for the high-level synchronous driver API, including

      • MongoClient
      • DB
      • DBCollection
      • DBObject

      However, the standard CRUD API is defined in the com.mongodb.client package, and includes interfaces such as:

      • MongoDatabase
      • MongoCollection
      • FindIterable

      The only thing missing is an entry point. To that end, I propose adding a new MongoClient interface to the com.mongodb.client package as an additional entry point to the standard CRUD
      API, which specifically does not include the legacy API. Additionally, there will be a MongoClients factory class for MongoClient instances, modelled after the corresponding class in the mongodb-driver-async module.

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: