fmarchioni / mastertheboss

Source code for mastertheboss.com
MIT License
197 stars 581 forks source link

Example for SeBootstrap.Configuration setting the ObjectMapper #61

Closed koppor closed 1 year ago

koppor commented 1 year ago

(I come from http://www.mastertheboss.com/jboss-frameworks/resteasy/getting-started-with-jakarta-restful-services/, thank you for the great article!)

Typically, one injects the ObjectMapper using following class:

public class ObjectMapperContextResolver implements ContextResolver<ObjectMapper> {

Now that ContextResolver will be deprecated, how to add an ObjectMapper?

fmarchioni commented 1 year ago

Sorry for the very late reply. I've checked the CDI 4.0 specification https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#se_bootstrap and it looks like you should now use different APIs to access CDI in J2SE:

SeContainerInitializer containerInit = SeContainerInitializer.newInstance();
SeContainer container = containerInit.initialize();
// retrieve a bean and do work with it
MyBean myBean = container.select(MyBean.class).get();
myBean.doWork();
// when done
container.close();

I'll note that and will update the article in the future. On the other hand, maybe a faster response can be obtained from https://github.com/jakartaee/cdi/issues

fmarchioni commented 1 year ago

Closing as TBD: update CDI with J2SE articles