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

Introduce closed type system for BSON documents

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.0.0
    • None
    • API, BSON
    • None
    • Major Change

    Description

      Introduce a closed type system for BSON documents and use it pervasively in the core of the driver, in preference to the open-typed Document class that is used now.

      Introduce a BsonDocumentReader implementation of BsonReader and a BsonDocument implementation of BsonWriter. This allows for easy conversion from any type with a Codec to and from a BsonDocument.

      This also means that clients of the core driver don't have to pass a separate encoder/decoder to operations that take or receive BsonDocument instances, as operations can just use the built-in BsonDocument Codec (which does not need to be extensible since the type system is closed)

      To handle the case where a client wants to pass an object to an operation without paying the cost of converting to BsonDocument, provide a BsonDocumentWrapper sub-class of BsonDocument that is constructed with an instance of T and an Encoder<T>. When the operation serializes it to the wire, it will just use that Encoder to do it.

      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: