Description
It should be possible to configure default values for JsonbConfig
instances using MP/Jakarta config.
For example, if an application initialized a default JSON-B configuration like this:
new JsonbConfig()
With the properties:
jsonb.formatting=true
jsonb.encoding=UTF-16
It would be equivalent to specifying the following:
new JsonbConfig()
.withFormatting(true)
.withEncoding("UTF-16");
If a JsonbConfig explicitly defines a configuration value, it takes precedence over any MP/JEE Config values. For example, using the same properties file above, and the following code:
new JsonbConfig()
.withEncoding("UTF-32");
The resulting properties would be encoding=UTF-32
(explicitly defined) and formatting=true
(from MP/JEE Config)
Configuration that requires instances of classes could also be supported, for example:
jsonb.adapters=com.example.MyAdapter,com.example.FooAdapter
jsonb.propertyVisibilityStrategy=com.example.MyVisibilityStrategy
For these cases, it would be required that the referenced classes have default constructors in order to be globally configured via MP/JEE Config. If they do not have default public constructors, an error would be thrown.
NOTE: Jakarta Config is not an official spec yet, but it is being proposed for Jakarta EE 9