Examples of JaxbAnnotationIntrospector


Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    }

    private ObjectMapper getObjectMapper() throws IOException {
        if (this.objectMapper == null) {
            ObjectMapper objectMapper = new ObjectMapper();
            AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
            SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
            serializationConfig = serializationConfig.without(SerializationConfig.Feature.WRAP_ROOT_VALUE)
                                                     .withAnnotationIntrospector(introspector);
            objectMapper.setSerializationConfig(serializationConfig);
            this.objectMapper = objectMapper;
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    }

    private ObjectMapper getObjectMapper() throws IOException {
        if (this.objectMapper == null) {
            ObjectMapper objectMapper = new ObjectMapper();
            AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
            SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
            serializationConfig = serializationConfig.without(SerializationConfig.Feature.WRAP_ROOT_VALUE)
                                                     .with(SerializationConfig.Feature.INDENT_OUTPUT)
                                                     .withAnnotationIntrospector(introspector);
            objectMapper.setSerializationConfig(serializationConfig);
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    private static ObjectMapper createObjectMapper() {
        ObjectMapper mapper = new ObjectMapper();

        AnnotationIntrospector pair =
            new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
                                            new JacksonAnnotationIntrospector());

        SerializationConfig serializationConfig =
            mapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL).withAnnotationIntrospector(pair);
           //.withDateFormat(StdDateFormat.getBlueprintISO8601Format());
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    }

    @Override
    protected Object[] getSingletons() {
        ObjectMapper mapper = new ObjectMapper();
        JaxbAnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector();
        mapper.getSerializationConfig().setAnnotationIntrospector(jaxbIntrospector);
        mapper.getDeserializationConfig().setAnnotationIntrospector(jaxbIntrospector);
        jacksonProvider = new JacksonJsonProvider();
        jacksonProvider.setMapper(mapper);
        return new Object[]{jacksonProvider};
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    }

    public void testXcVersions()
    {
        if (runsFromAnt()) {
            assertVersion(new JaxbAnnotationIntrospector().version(), MAJOR_VERSION, MINOR_VERSION);
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    obj.setMyMap(new HashMap<String, String>());
    obj.getMyMap().put("this", "that");
    obj.getMyMap().put("how", "here");

    ObjectMapper mapper = new ObjectMapper();
    mapper.getDeserializationConfig().withAnnotationIntrospector(new JaxbAnnotationIntrospector());
    mapper.getSerializationConfig().withAnnotationIntrospector(new JaxbAnnotationIntrospector());
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    mapper.writeValue(bytesOut, obj);
    obj = mapper.readValue(new ByteArrayInputStream(bytesOut.toByteArray()), ObjectContainingAMap.class);
    assertNotNull(obj.getMyMap());
  }
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

     */

    public void testAutoDetectDisable() throws IOException
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        Jackson183Bean bean = new Jackson183Bean();
        Map<String,Object> result;

        // Ok: by default, should see 2 fields:
        result = writeAndMap(mapper, bean);
        assertEquals(2, result.size());
        assertEquals("a", result.get("a"));
        assertEquals("b", result.get("b"));

        // But when disabling auto-detection, just one
        mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        mapper.configure(SerializationConfig.Feature.AUTO_DETECT_GETTERS, false);
        result = writeAndMap(mapper, bean);
        assertEquals(1, result.size());
        assertNull(result.get("a"));
        assertEquals("b", result.get("b"));
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    // @since 1.5
    public void testIssue246() throws IOException
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        Identified id = new Identified();
        id.id = "123";
        assertEquals("{\"id\":\"123\"}", mapper.writeValueAsString(id));
    }
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    // Added to check for [JACKSON-171]
    public void testWithJAXB() throws Exception
    {
        String jsonData = "{\"id\":1}";
        ObjectMapper mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        mapper.readValue(jsonData, JaxbBean.class);
    }
View Full Code Here

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

    public static class DualAnnotationObjectMapper extends ObjectMapper {

        public DualAnnotationObjectMapper() {
            super();
            AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
            AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();

            // make de/serializer use JAXB annotations first, then jackson ones
            AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
            setAnnotationIntrospector(pair);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.