Example usage for com.fasterxml.jackson.module.jaxb JaxbAnnotationModule setPriority

List of usage examples for com.fasterxml.jackson.module.jaxb JaxbAnnotationModule setPriority

Introduction

In this page you can find the example usage for com.fasterxml.jackson.module.jaxb JaxbAnnotationModule setPriority.

Prototype

public JaxbAnnotationModule setPriority(Priority p) 

Source Link

Usage

From source file:org.broadleafcommerce.core.web.api.jaxrs.JaxrsObjectMapperProvider.java

@Override
public void afterPropertiesSet() throws Exception {
    mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    // serializing to singleelement arrays is enabled by default but just in case they change this in the future...
    mapper.configure(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED, false);

    // Register the JAXB annotation module 
    JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule();
    // Make sure that JAXB is the primary serializer (technically the default behavior but let's be explicit)
    jaxbModule.setPriority(Priority.PRIMARY);
    mapper.registerModule(new JaxbAnnotationModule());

    mapper.setTypeFactory(TypeFactory.defaultInstance().withModifier(typeModifier));
}