-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels