Interface DocumentContextTracker


@Internal public interface DocumentContextTracker
Tracks whether a serde created with the context of a document keeps that context, so that it must not serve other documents. A mapper caches the specific serde of a type only when creating it did not bind it to the document.

A serde is bound to the document when the graph of serdes created with the context holds a user serde that takes the context as a constructor argument, or a serde that resolves other serdes later with the context. A serde that keeps the serdes it created between documents, such as the runtime bean serdes, which keep the bean of each type, marks every later document it serves as bound when creating those serdes bound the first one, since the later documents do not look them up again.

This only keeps a mapper from caching such serdes. The property serdes a runtime bean keeps are still the ones created with the context of the first document; specializing them for each document is a separate change.

Since:
3.3
  • Method Details

    • markDocumentBound

      void markDocumentBound()
      Marks the serdes created with this context as bound to the document.
    • documentBindings

      int documentBindings()
      Returns:
      How many times the serdes created with this context were bound to the document, so that a serde can tell whether creating another serde bound it
    • markDocumentBound

      static void markDocumentBound(Object context)
      Marks the serdes created with the given context as bound to the document.
      Parameters:
      context - The encoder or decoder context
    • isDocumentBound

      static boolean isDocumentBound(Object context)
      Parameters:
      context - The encoder or decoder context
      Returns:
      Whether the serdes created with the context are bound to the document, true when the context does not track it
    • documentBindings

      static int documentBindings(Object context)
      Parameters:
      context - The encoder or decoder context
      Returns:
      How many times the serdes created with the context were bound to the document, -1 when the context does not track it