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

Provide a more extensible DecoderContext and EncoderContext

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.4.2
    • Component/s: Codecs
    • Labels:
      None

      It would be nice to have a decoder and encoder context, that can be used externally, to pass options to the decoder and encoder.

      Right now I see no possibility to modify the existing context, overwrite it with some custom attributes, or even a possibility to hand over a own context implementation.

      The suggestion would be to ether make both contexts and there builders public and extensible or to provide a options map, that can be used and set for each child context.

      Either way would require some handover at the collection class as well, like find(<the findparameters>, DecoderContext) or find(<the findparameters>, Map<Object, Object>)

      "What is the usecase?"

      We have generic Decoder and Encoder, that works with an EMF model as a schema, with can take a couple of options, like a flag to serialize default values or not. Right now we have to instantiate a CodecProvider for every find we make in order to hand some options to the codec we want to use.

      Furthermore we call the codec registry and decode for every containment reference. We know the type for every containment reference and what type to expect, this we need to hand to our child decoder that is generic as well. Right now our Codec is not stateless and we have a instance for every find operation, which is kind of bad. With the above mentioned mechanism we could get rid of it.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            ungeildodger Jürgen Albert
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: