当前位置: 首页>>代码示例>>Java>>正文


Java Jackson2HalModule类代码示例

本文整理汇总了Java中org.springframework.hateoas.hal.Jackson2HalModule的典型用法代码示例。如果您正苦于以下问题:Java Jackson2HalModule类的具体用法?Java Jackson2HalModule怎么用?Java Jackson2HalModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Jackson2HalModule类属于org.springframework.hateoas.hal包,在下文中一共展示了Jackson2HalModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRestTemplate

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
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));
}
 
开发者ID:ewolff,项目名称:microservice-cloudfoundry,代码行数:12,代码来源:CatalogClient.java

示例2: setup

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@Before
public void setup() {
	typeResolver = mock(TypeResolver.class);
	configuration = Configuration.build();
	
	instantiator = mock(HandlerInstantiator.class);
	
	doReturn(new ResourceDeserializer(Object.class, typeResolver, configuration))
		.when(instantiator).deserializerInstance(any(DeserializationConfig.class),
				any(Annotated.class), eq(ResourceDeserializer.class));
			
	mapper = new ObjectMapper();
	mapper.setHandlerInstantiator(instantiator);
	mapper.registerModule(new Jackson2HalModule());
	mapper.registerModule(new TestModule());
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:18,代码来源:ResourceDeserializerTest.java

示例3: postProcessAfterInitialization

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@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;
}
 
开发者ID:thomasletsch,项目名称:moserp,代码行数:19,代码来源:ObjectMapperCustomizer.java

示例4: getHttpMessageConverters

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
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;
}
 
开发者ID:spencergibb,项目名称:myfeed,代码行数:17,代码来源:MyfeedAutoConfig.java

示例5: init

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
public void init() {
    HATEOAS_MEDIA_TYPE = MediaType.parseMediaType("application/hal+json");

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.registerModule(new Jackson2HalModule());

    MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    converter.setSupportedMediaTypes(Arrays.asList(HATEOAS_MEDIA_TYPE));
    converter.setObjectMapper(mapper);

    hateoasRestTemplate = new RestTemplate(Arrays.<HttpMessageConverter<?>> asList(converter));
    hateoasRestTemplate.setErrorHandler(new DefaultResponseErrorHandler());

    //restTemplate = new RestTemplate(Arrays.<HttpMessageConverter<?>> asList(new MappingJackson2HttpMessageConverter()));
    //restTemplate.setErrorHandler(new DefaultResponseErrorHandler());
}
 
开发者ID:ssouporg,项目名称:denv,代码行数:18,代码来源:DenvClient.java

示例6: postProcessBeforeInitialization

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String s) {
    if (bean instanceof RequestMappingHandlerAdapter) {
        ((RequestMappingHandlerAdapter) bean).getMessageConverters().stream()
            .filter(converter -> converter instanceof MappingJackson2HttpMessageConverter)
            .forEach(converter -> {
                MappingJackson2HttpMessageConverter halConverterCandidate = (MappingJackson2HttpMessageConverter) converter;
                ObjectMapper objectMapper = halConverterCandidate.getObjectMapper();
                if (Jackson2HalModule.isAlreadyRegisteredIn(objectMapper)) {
                    List<MediaType> vendorSpecificTypes = new ArrayList<>(halConverterCandidate.getSupportedMediaTypes());
                    vendorSpecificTypes.add(V1MediaType.V1_HAL_DOCUMENT_COLLECTION_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_HAL_DOCUMENT_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_HAL_FOLDER_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_HAL_DOCUMENT_CONTENT_VERSION_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_HAL_AUDIT_ENTRY_MEDIA_TYPE);

                    vendorSpecificTypes.add(V1MediaType.V1_HAL_DOCUMENT_AND_METADATA_COLLECTION_MEDIA_TYPE);

                    vendorSpecificTypes.add(V1MediaType.V1_DOCUMENT_COLLECTION_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_DOCUMENT_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_FOLDER_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_DOCUMENT_CONTENT_VERSION_MEDIA_TYPE);
                    vendorSpecificTypes.add(V1MediaType.V1_AUDIT_ENTRY_MEDIA_TYPE);
                    ((MappingJackson2HttpMessageConverter) converter).setSupportedMediaTypes(vendorSpecificTypes);
                }
            });
    }
    return bean;

}
 
开发者ID:hmcts,项目名称:document-management-store-app,代码行数:31,代码来源:AddMediaTypeSupportConfiguration.java

示例7: mappingJackson2HttpMessageConverter

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@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;
}
 
开发者ID:pawankumar8608,项目名称:spring-cloud-microservices-docker,代码行数:12,代码来源:Application.java

示例8: postConstructConfiguration

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@PostConstruct
public void postConstructConfiguration() {
    // Expose ids for the domain entities having repositories
    logger.info("Exposing IDs on repositories...");
    restConfiguration.config().exposeIdsFor(User.class);
    restConfiguration.config().exposeIdsFor(Product.class);

    // Register the ObjectMapper module for properly rendering HATEOAS REST repositories
    logger.info("Registering Jackson2HalModule...");
    restConfiguration.objectMapper().registerModule(new Jackson2HalModule());
}
 
开发者ID:xiaojieliu7,项目名称:MicroServiceProject,代码行数:12,代码来源:Application.java

示例9: postConstructConfiguration

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@PostConstruct
public void postConstructConfiguration() {
    // Expose ids for the domain entities having repositories
    logger.info("Exposing IDs on repositories...");
    restConfiguration.config().exposeIdsFor(User.class);
    restConfiguration.config().exposeIdsFor(Product.class);
    restConfiguration.config().exposeIdsFor(Rating.class);

    // Register the ObjectMapper module for properly rendering HATEOAS REST repositories
    logger.info("Registering Jackson2HalModule...");
    restConfiguration.objectMapper().registerModule(new Jackson2HalModule());
}
 
开发者ID:xiaojieliu7,项目名称:MicroServiceProject,代码行数:13,代码来源:Application.java

示例10: jsonRedisSerializer

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
private Jackson2JsonRedisSerializer jsonRedisSerializer(JavaType javaType)
{
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(javaType);
    ObjectMapper mapper = new ObjectMapper();
    mapper.enableDefaultTyping();
	mapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY);

	mapper.findAndRegisterModules();
    mapper.registerModule(new Jackson2HalModule());
    mapper.setHandlerInstantiator(new Jackson2HalModule.HalHandlerInstantiator(new DefaultRelProvider(), null, null));        
    jackson2JsonRedisSerializer.setObjectMapper(mapper);        
    return jackson2JsonRedisSerializer;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:14,代码来源:CacheConfig.java

示例11: getIncidentsPaged

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@Override
   @JsonSerialize(using = Jackson2HalModule.HalResourcesSerializer.class)
   @JsonDeserialize(using = Jackson2HalModule.HalResourcesDeserializer.class)
public PagedIncidents getIncidentsPaged(int pagenum,int pagesize) {
	LOG.info("Performing get {} web service", applicationProperties.getIncidentApiUrl() +"/incidents");
	final String restUri = applicationProperties.getIncidentApiUrl() +"/incidents?page="+pagenum+"&size="+pagesize;
	ResponseEntity<PagedResources<IncidentBean>> response = restTemplate.exchange(restUri, HttpMethod.GET, null,
			new ParameterizedTypeReference<PagedResources<IncidentBean>>() {});
	//        LOG.info("Total Incidents {}", response.getBody().size());
	PagedResources<IncidentBean> beanResources = response.getBody();
	PagedIncidents incidents = new PagedIncidents(beanResources,pagenum);
	return incidents;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:14,代码来源:IncidentServiceImpl.java

示例12: getRestTemplate

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
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));
}
 
开发者ID:ewolff,项目名称:microservice-consul,代码行数:14,代码来源:CatalogClient.java

示例13: restTemplate

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@Bean
public RestTemplate restTemplate() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jackson2HalModule());

    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
    converter.setObjectMapper(mapper);

    return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:12,代码来源:TestConfig.java

示例14: getHalMessageConverter

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
private HttpMessageConverter getHalMessageConverter() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.registerModule(new Jackson2HalModule());
    MappingJackson2HttpMessageConverter halConverter = new TypeConstrainedMappingJackson2HttpMessageConverter(Resource.class);
    halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
    halConverter.setObjectMapper(objectMapper);
    return halConverter;
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:10,代码来源:StressTesterConfig.java

示例15: create

import org.springframework.hateoas.hal.Jackson2HalModule; //导入依赖的package包/类
@Override
public ObjectMapper create(HandlerInstantiator instantiator) {
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.registerModule(new Jackson2HalModule());
	mapper.registerModule(new JacksonClientModule());
	mapper.setHandlerInstantiator(instantiator);
	return mapper;
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:10,代码来源:DefaultObjectMapperFactory.java


注:本文中的org.springframework.hateoas.hal.Jackson2HalModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。