You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to understand the Whiteboard Specification for Jakarta™ RESTful Web Services and write a blog post about it. I cam across the following snippet and wanted to try it out.
@JakartarsExtension
@JakartarsName("configProvider")
@Component
public class ConfigProvider implements ContextResolver {
private ObjectMapper mapper = new ObjectMapper();
public <T> getContext(Class<T> clazz) {
if(ObjectMapper.class.equals(clazz)) {
return mapper;
}
return null;
}
}
The snippet seems to be incorrect. If I copy it into an IDE it shows compile errors. And from looking at the ContextResolver interface, it also seems to be intended to look differently. IMHO it should look similar to the following class:
@JakartarsExtension
@JakartarsName("configProvider")
@Provider
public class ConfigProvider implements ContextResolver<ObjectMapper> {
private ObjectMapper mapper;
public CustomObjectMapperProvider() {
this.mapper = new ObjectMapper();
this.mapper.enable(SerializationFeature.INDENT_OUTPUT);
}
public ObjectMapper getContext(Class<?> clazz) {
return mapper;
}
}
Of course I am not sure if the snippet in the spec is based on some older JAX-RS specification. But with the current reference implementation, it does not work.
The text was updated successfully, but these errors were encountered:
I am trying to understand the Whiteboard Specification for Jakarta™ RESTful Web Services and write a blog post about it. I cam across the following snippet and wanted to try it out.
The snippet seems to be incorrect. If I copy it into an IDE it shows compile errors. And from looking at the
ContextResolver
interface, it also seems to be intended to look differently. IMHO it should look similar to the following class:Of course I am not sure if the snippet in the spec is based on some older JAX-RS specification. But with the current reference implementation, it does not work.
The text was updated successfully, but these errors were encountered: