Thanks Tim!!
I found very useful the code in this post:
http://restlet-discuss.1400322.n2.nabble.com/Jackson-Mix-in-Annotations-td6211060.html#a6231831

I implemented my JacksonCustomConverter, that override the two methods
create and set the mapper with mapper.enableDefaultTyping().
I post the code:

public class JacksonCustomConverter extends JacksonConverter {
    @Override
    protected  JacksonRepresentation create(MediaType mediaType, T source) {
        ObjectMapper mapper = createMapper();
        JacksonRepresentation jr = new JacksonRepresentation(mediaType,
source);
        jr.setObjectMapper(mapper);
        return jr;
    }

    @Override
    protected  JacksonRepresentation create(Representation source, Class
objectClass) {
        ObjectMapper mapper = createMapper();
        JacksonRepresentation jr = new JacksonRepresentation(source,
objectClass);
        jr.setObjectMapper(mapper);
        return jr;
    }


    private ObjectMapper createMapper() {
        JsonFactory jsonFactory = new JsonFactory();
        jsonFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET,
false);
        ObjectMapper mapper = new ObjectMapper(jsonFactory);
        mapper.enableDefaultTyping();
        return mapper;
    }

}

Regards


--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Set-custom-objectMapper-to-Jackson-Extension-tp6287812p6288090.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2721483

Reply via email to