Example usage for com.fasterxml.jackson.module.jaxb JaxbAnnotationIntrospector JaxbAnnotationIntrospector

List of usage examples for com.fasterxml.jackson.module.jaxb JaxbAnnotationIntrospector JaxbAnnotationIntrospector

Introduction

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

Prototype

public JaxbAnnotationIntrospector(TypeFactory typeFactory) 

Source Link

Usage

From source file:software.coolstuff.springframework.owncloud.service.impl.local.OwncloudLocalUserDataServiceImpl.java

public OwncloudLocalUserDataServiceImpl(Jackson2ObjectMapperBuilder builder, ResourceLoader resourceLoader,
        OwncloudProperties properties) {
    Validate.notNull(builder);//from  ww  w .  j a v a 2  s  .  c om
    xmlMapper = builder.createXmlMapper(true).build();
    xmlMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(xmlMapper.getTypeFactory()));
    this.resourceLoader = resourceLoader;
    this.properties = properties;
}

From source file:com.dell.asm.asmcore.asmmanager.client.util.ServiceTemplateClientUtil.java

private static ObjectMapper buildObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    AnnotationIntrospector ai = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
    mapper.setAnnotationIntrospector(ai);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return mapper;
}

From source file:org.bremersee.common.jms.DefaultJmsConverter.java

/**
 * Default constructor./*from  www. java 2  s  . co m*/
 */
public DefaultJmsConverter() {
    objectMapper = new ObjectMapper();
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary);
    objectMapper.setAnnotationIntrospector(pair);
}

From source file:org.bremersee.common.web.client.ResponseErrorHandlerImpl.java

/**
 * Default constructor./*w  w  w  .j a  v a  2  s .c  om*/
 */
public ResponseErrorHandlerImpl() {
    Jaxb2Marshaller m = new Jaxb2Marshaller();
    m.setContextPath(ThrowableMessageDto.class.getPackage().getName());
    unmarshaller = m;
    objectMapper = new ObjectMapper();
    // see http://wiki.fasterxml.com/JacksonJAXBAnnotations
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary);
    objectMapper.setAnnotationIntrospector(pair);
}

From source file:org.bremersee.common.spring.autoconfigure.WebMvcExceptionResolver.java

public WebMvcExceptionResolver() {
    defaultExceptionMapper = new ThrowableToThrowableDtoMapper();
    Jaxb2Marshaller m = new Jaxb2Marshaller();
    m.setContextPath(ThrowableDto.class.getPackage().getName());
    marshaller = m;//from w w w .j  a v  a 2s . co m
    objectMapper = new ObjectMapper();
    // see http://wiki.fasterxml.com/JacksonJAXBAnnotations
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary);
    objectMapper.setAnnotationIntrospector(pair);
}

From source file:gt.dakaik.config.WebContext.java

public MappingJackson2HttpMessageConverter jacksonXmlMessageConverter() {
    MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();

    ObjectMapper mapper = new XmlMapper();

    //Registering Hibernate4Module to support lazy objects
    Hibernate4Module module = new Hibernate4Module();
    module.disable(Hibernate4Module.Feature.USE_TRANSIENT_ANNOTATION);
    mapper.registerModule(module);//from   w ww. j  a v  a  2s . c  om

    // Cambiar AnnotationIntrospector para usar anotaciones de JAXB
    AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
    mapper.setAnnotationIntrospector(introspector);

    List<MediaType> MediaTypes = new ArrayList<>();
    MediaTypes.add(MediaType.APPLICATION_XML);
    messageConverter.setSupportedMediaTypes(MediaTypes);

    messageConverter.setObjectMapper(mapper);
    //log.debug("Listado de MediaTypes: [{}]", messageConverter.getSupportedMediaTypes().toString());

    return messageConverter;

}

From source file:edu.psu.swe.scim.server.utility.AttributeUtil.java

@PostConstruct
public void init() { // TODO move this to a CDI producer
    objectMapper = new ObjectMapper();

    JaxbAnnotationModule jaxbAnnotationModule = new JaxbAnnotationModule();
    objectMapper.registerModule(jaxbAnnotationModule);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(objectMapper.getTypeFactory());
    AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospectorPair(jacksonIntrospector, jaxbIntrospector);
    objectMapper.setAnnotationIntrospector(pair);

    objectMapper.setSerializationInclusion(Include.NON_NULL);

    SimpleModule module = new SimpleModule();
    module.addDeserializer(ScimResource.class, new ScimResourceDeserializer(this.registry, this.objectMapper));
    objectMapper.registerModule(module);
}

From source file:org.apache.nifi.cluster.coordination.http.replication.okhttp.OkHttpReplicationClient.java

public OkHttpReplicationClient(final NiFiProperties properties) {
    jsonCodec.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS));
    jsonCodec.setAnnotationIntrospector(new JaxbAnnotationIntrospector(jsonCodec.getTypeFactory()));

    jsonSerializer = new JsonEntitySerializer(jsonCodec);
    xmlSerializer = new XmlEntitySerializer();

    okHttpClient = createOkHttpClient(properties);
}

From source file:com.abiquo.apiclient.stream.StreamClient.java

private StreamClient(final String endpoint, final String username, final String password,
        final SSLConfiguration sslConfiguration) {
    this.endpoint = checkNotNull(endpoint, "endpoint cannot be null");
    checkNotNull(username, "username cannot be null");
    checkNotNull(password, "password cannot be null");

    AsyncHttpClientConfig.Builder config = new AsyncHttpClientConfig.Builder();
    config.setRequestTimeoutInMs(-1);//from ww  w . ja va2 s .co  m
    config.setIdleConnectionTimeoutInMs(-1);
    if (sslConfiguration != null) {
        config.setHostnameVerifier(sslConfiguration.hostnameVerifier());
        config.setSSLContext(sslConfiguration.sslContext());
    }
    config.setRealm(new Realm.RealmBuilder() //
            .setPrincipal(username) //
            .setPassword(password) //
            .setUsePreemptiveAuth(true) //
            .setScheme(Realm.AuthScheme.BASIC) //
            .build());

    clientConfig = config.build();

    json = new ObjectMapper().setAnnotationIntrospector( //
            new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(),
                    new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))) //
            .registerModule(new AbiquoModule());
}

From source file:com.linecorp.platform.channel.sample.ApiHttpClient.java

public ApiHttpClient(final String channelAccessToken) {

    RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeoutInMillis)
            .setConnectTimeout(timeoutInMillis).build();

    CloseableHttpAsyncClient asyncClient = HttpAsyncClientBuilder.create()
            .setDefaultRequestConfig(requestConfig)
            .addInterceptorLast((HttpRequest httpRequest, HttpContext httpContext) -> {
                httpRequest.addHeader("X-Line-ChannelToken", channelAccessToken);
                httpRequest.addHeader("Content-Type", "application/json; charser=UTF-8");
                httpRequest.removeHeaders("Accept");
                httpRequest.addHeader("Accept", "application/json; charset=UTF-8");
            }).setMaxConnTotal(maxConnections).setMaxConnPerRoute(maxConnections).disableCookieManagement()
            .build();/*from www  .j  a  v a2s .  c  o  m*/

    asyncRestTemplate = new AsyncRestTemplate(new HttpComponentsAsyncClientHttpRequestFactory(asyncClient));
    asyncRestTemplate.setErrorHandler(new ApiResponseErrorHandler());

    httpHeaders = new HttpHeaders();
    httpHeaders.set("X-Line-ChannelToken", channelAccessToken);
    httpHeaders.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
    List<MediaType> list = new ArrayList<>();
    list.add(new MediaType("application", "json", Charset.forName("UTF-8")));
    httpHeaders.setAccept(list);

    objectMapper = new ObjectMapper();
    objectMapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
    objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}