org.springframework.hateoas.hal.Jackson2HalModule Java Examples
The following examples show how to use
org.springframework.hateoas.hal.Jackson2HalModule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimulatedDeviceFactory.java From hawkbit-examples with Eclipse Public License 1.0 | 6 votes |
private AbstractSimulatedDevice createDdiDevice(final String id, final String tenant, final int pollDelaySec, final URL baseEndpoint, final String gatewayToken) { final ObjectMapper mapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .registerModule(new Jackson2HalModule()); final RootControllerResourceClient controllerResource = Feign.builder() .requestInterceptor(new GatewayTokenInterceptor(gatewayToken)) .contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).logLevel(Level.HEADERS) .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper))).encoder(new JacksonEncoder()) .logger(new Slf4jLogger()).decode404() .target(RootControllerResourceClient.class, baseEndpoint.toString()); return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater, gatewayToken); }
Example #2
Source File: MyfeedAutoConfig.java From myfeed with Apache License 2.0 | 6 votes |
private List<HttpMessageConverter<?>> getHttpMessageConverters() { List<HttpMessageConverter<?>> converters = new ArrayList<>(); converters.add(new StringHttpMessageConverter(Charset.forName("UTF-8"))); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jackson2HalModule()); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setObjectMapper(mapper); converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); converters.add(converter); return converters; }
Example #3
Source File: ObjectMapperCustomizer.java From moserp with Apache License 2.0 | 6 votes |
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (!(bean instanceof ObjectMapper)) { return bean; } ObjectMapper mapper = (ObjectMapper) bean; mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); registerQuantitySerializer(mapper); mapper.registerModules(new MoneyModule(), new JavaTimeModule(), new Jackson2HalModule()); return mapper; }
Example #4
Source File: CatalogClient.java From microservice-consul with Apache License 2.0 | 5 votes |
protected RestTemplate getRestTemplate() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); converter.setObjectMapper(mapper); return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); }
Example #5
Source File: CatalogClient.java From microservice-consul with Apache License 2.0 | 5 votes |
protected RestTemplate getRestTemplate() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); converter.setObjectMapper(mapper); return new RestTemplate( Collections.<HttpMessageConverter<?>> singletonList(converter)); }
Example #6
Source File: CustomerClient.java From microservice-consul with Apache License 2.0 | 5 votes |
protected RestTemplate getRestTemplate() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); converter.setObjectMapper(mapper); return new RestTemplate( Collections.<HttpMessageConverter<?>> singletonList(converter)); }
Example #7
Source File: ReservationService.java From spring-cloud-in-action with MIT License | 5 votes |
@Bean public Decoder feignDecoder() { ObjectMapper objectMapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true) .registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(); jacksonConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); jacksonConverter.setObjectMapper(objectMapper); ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter); return new ResponseEntityDecoder(new SpringDecoder(objectFactory)); }
Example #8
Source File: RestTmplApplicationTests.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 5 votes |
private MappingJackson2HttpMessageConverter getHalMessageConverter() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter halConverter = new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class); halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); halConverter.setObjectMapper(objectMapper); return halConverter; }
Example #9
Source File: Application.java From hawkbit-examples with Eclipse Public License 1.0 | 5 votes |
private static MgmtSoftwareModuleClientResource uploadSoftwareModule( final ClientConfigurationProperties configuration) { final ObjectMapper mapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .registerModule(new Jackson2HalModule()); return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).decode404() .requestInterceptor( new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword())) .logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder()) .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper))) .target(MgmtSoftwareModuleClientResource.class, configuration.getUrl()); }
Example #10
Source File: AsyncGetService.java From orders with Apache License 2.0 | 5 votes |
@Autowired public AsyncGetService(RestProxyTemplate restProxyTemplate) { this.restProxyTemplate = restProxyTemplate; this.halTemplate = new RestTemplate(restProxyTemplate.getRestTemplate().getRequestFactory()); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter halConverter = new MappingJackson2HttpMessageConverter(); halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); halConverter.setObjectMapper(objectMapper); halTemplate.setMessageConverters(Collections.singletonList(halConverter)); }
Example #11
Source File: Application.java From spring-cloud-microservice-example with GNU General Public License v3.0 | 5 votes |
@Bean public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); jsonConverter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); objectMapper.registerModule(new Jackson2HalModule()); jsonConverter.setObjectMapper(objectMapper); return jsonConverter; }
Example #12
Source File: HalRestTemplate.java From moserp with Apache License 2.0 | 5 votes |
public HalRestTemplate() { ObjectMapper halObjectMapper = new ObjectMapper(); halObjectMapper.registerModule(new Jackson2HalModule()); halObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MappingJackson2HttpMessageConverter halConverter = new MappingJackson2HttpMessageConverter(); halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); halConverter.setObjectMapper(halObjectMapper); getMessageConverters().add(halConverter); }
Example #13
Source File: ObjectMapperBuilder.java From moserp with Apache License 2.0 | 5 votes |
public ObjectMapper build() { ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); registerQuantitySerializer(mapper); mapper.registerModules(new MoneyModule(), new JavaTimeModule(), new Jackson2HalModule()); return mapper; }
Example #14
Source File: ObjectMapperBuilder.java From moserp with Apache License 2.0 | 5 votes |
public ObjectMapper build() { ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); registerQuantitySerializer(mapper); mapper.registerModules(new MoneyModule(), new JavaTimeModule(), new Jackson2HalModule()); return mapper; }
Example #15
Source File: CustomerClient.java From microservice-consul with Apache License 2.0 | 5 votes |
protected RestTemplate getRestTemplate() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); converter.setObjectMapper(mapper); return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); }
Example #16
Source File: RestTmplApplicationTests.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 5 votes |
private MappingJackson2HttpMessageConverter getHalMessageConverter() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter halConverter = new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class); halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON)); halConverter.setObjectMapper(objectMapper); return halConverter; }
Example #17
Source File: JSONConfiguration.java From spring-boot-jpa-data-rest-soft-delete with MIT License | 4 votes |
@Bean public Module Jackson2HalModule() { return new Jackson2HalModule(); }