Skip to content

Change the way Modules configure, interact with ObjectMapper #1955

@cowtowncoder

Description

@cowtowncoder

(from FasterXML/jackson3-dev#4)

Related to #1954, one significant change is the way in which Modules register their functionality with ObjectMapper. Changes are needed due to immutability of mappers; however, since Module.SetupContext is an existing abstraction, much or most changes can be insulated.

One necessary change is that owner, accessible via getOwner() of Module.SetupContext, can not be ObjectMapper being built -- it may or may not exist, but more importantly, it is immutable.
The most logical thing to do is to expose actual Builder, but need to use that entity should be minimized (which was already true for owner -- it is is and was a fallback).

Some additional changes that are needed:

  • Mapper, its builder, and saved state (for rebuilding, JDK serialization) will have to keep track of Modules to register, so there is a new dependency.
    • as a result Modules now SHOULD be java.io.Serializable; otherwise registering one will prevent ObjectMapper instance from being serializable
  • Modules are encouraged to try to do as much as possible dynamically in setupModule() method instead of pre-constructing things, and to minimize serializable state they keep

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xIssues to be only tackled for Jackson 3.x, not 2.x

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions