Example usage for org.springframework.http.converter.json MappingJackson2HttpMessageConverter getObjectMapper

List of usage examples for org.springframework.http.converter.json MappingJackson2HttpMessageConverter getObjectMapper

Introduction

In this page you can find the example usage for org.springframework.http.converter.json MappingJackson2HttpMessageConverter getObjectMapper.

Prototype

public ObjectMapper getObjectMapper() 

Source Link

Document

Return the underlying ObjectMapper for this view.

Usage

From source file:de.thm.arsnova.service.UserServiceImpl.java

public UserServiceImpl(UserRepository repository, JavaMailSender mailSender,
        @Qualifier("defaultJsonMessageConverter") MappingJackson2HttpMessageConverter jackson2HttpMessageConverter) {
    super(UserProfile.class, repository, jackson2HttpMessageConverter.getObjectMapper());
    this.userRepository = repository;
    this.mailSender = mailSender;
}

From source file:com.orange.ngsi2.client.Ngsi2Client.java

/**
 * Inject an ObjectMapper supporting Java8 and JavaTime module by default
 *///  w  ww .j av a 2 s .c  om
protected void injectJava8ObjectMapper() {
    MappingJackson2HttpMessageConverter converter = getMappingJackson2HttpMessageConverter();
    if (converter != null) {
        converter.getObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule())
                .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    }
}

From source file:io.pivotal.accounts.config.WebConfig.java

/**
 * configure the message converters with the date formatter.
 *///from   ww  w . j  ava2s  . co m
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    // Configure JSON support
    MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
    mappingJacksonHttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON));
    //mappingJacksonHttpMessageConverter.getObjectMapper().configure(
    //      Feature.WRITE_DATES_AS_TIMESTAMPS, true);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
    // There is no need to set the timezone as Jackson uses GMT and not the
    // local time zone (which is exactly what you want)
    // Note: While SimpleDateFormat is not threadsafe, Jackson Marshaller's
    // StdSerializerProvider clones the configured formatter for each thread
    mappingJacksonHttpMessageConverter.getObjectMapper().setDateFormat(format);
    //mappingJacksonHttpMessageConverter.getObjectMapper().configure(
    //      Feature.INDENT_OUTPUT, true);
    // mappingJacksonHttpMessageConverter.getObjectMapper().getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
    converters.add(mappingJacksonHttpMessageConverter);
}

From source file:com.orange.ngsi2.client.Ngsi2Client.java

/**
 * Inject the Ngsi2ResponseErrorHandler/*from w w w .j ava 2 s.  co  m*/
 */
protected void injectNgsi2ErrorHandler() {
    MappingJackson2HttpMessageConverter converter = getMappingJackson2HttpMessageConverter();
    if (converter != null) {
        this.asyncRestTemplate.setErrorHandler(new Ngsi2ResponseErrorHandler(converter.getObjectMapper()));
    }
}