Java 类org.springframework.boot.autoconfigure.web.HttpMessageConverters 实例源码

项目:FastBootWeixin    文件:WxInvokerConfiguration.java   
/**
 * 是否有必要模仿Spring不提供RestTemplate,只提供RestTemplateBuilder
 *
 * @return dummy
 */
@Bean(name = WxBeans.WX_API_TEMPLATE_NAME)
public WxApiTemplate wxApiTemplate() {
    RestTemplateBuilder builder = new RestTemplateBuilder();
    builder = builder.requestFactory(new WxApiHttpRequestFactory(wxProperties))
            .errorHandler(new WxResponseErrorHandler());
    HttpMessageConverters converters = this.messageConverters.getIfUnique();
    List<HttpMessageConverter<?>> converterList = new ArrayList<>();
    // 加入默认转换
    converterList.add(new WxHttpInputMessageConverter());
    if (converters != null) {
        converterList.addAll(converters.getConverters());
        builder = builder.messageConverters(Collections.unmodifiableList(converterList));
    }
    return new WxApiTemplate(builder.build());
}
项目:feign-form    文件:DownloadClient.java   
@Bean
public Decoder feignDecoder () {
    val springConverters = messageConverters.getObject().getConverters();
    val decoderConverters = new ArrayList<HttpMessageConverter<?>>(springConverters.size() + 1);

    decoderConverters.addAll(springConverters);
    decoderConverters.add(new SpringManyMultipartFilesReader(4096));

    val httpMessageConverters = new HttpMessageConverters(decoderConverters);

    return new SpringDecoder(new ObjectFactory<HttpMessageConverters>() {

        @Override
        public HttpMessageConverters getObject () {
            return httpMessageConverters;
        }
    });
}
项目:utils    文件:FastJsonAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter.class)
public HttpMessageConverters customConverters(FastJsonHttpMessageConverter converter) {
    Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();

    if (null == converter) {
        Class<?> converterClass = properties.getConverter();
        converter = (FastJsonHttpMessageConverter) BeanUtils.instantiate(converterClass);
    }

    FastJsonConfig config = new FastJsonConfig();
    List<SerializerFeature> features = properties.getFeatures();
    if (!CollectionUtils.isBlank(features)) {
        SerializerFeature[] featureArray = new SerializerFeature[features.size()];
        config.setSerializerFeatures(features.toArray(featureArray));
    }

    converter.setFastJsonConfig(config);
    messageConverters.add(converter);

    return new HttpMessageConverters(true, messageConverters);
}
项目:runelite    文件:CustomConfiguration.java   
@Bean
public HttpMessageConverters customConverters()
{
    Gson gson = new GsonBuilder()
        .setPrettyPrinting()
        .create();

    GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
    gsonHttpMessageConverter.setGson(gson);

    // normally you can simply exclude jackson from the classpath to cause
    // Spring to use gson, but minio also depends on jackson
    List<HttpMessageConverter<?>> converters = new RestTemplate().getMessageConverters();
    converters.removeIf(converter -> converter.getClass() == MappingJackson2HttpMessageConverter.class);
    converters.add(gsonHttpMessageConverter);

    return new HttpMessageConverters(false, converters);
}
项目:put-it-to-rest    文件:RestClientPostProcessor.java   
private String registerHttpMessageConverters(final String id) {
    return registry.register(id, HttpMessageConverters.class, () -> {
        final List<Object> list = list();

        LOG.debug("Client [{}]: Registering StringHttpMessageConverter", id);
        list.add(genericBeanDefinition(StringHttpMessageConverter.class)
                .addPropertyValue("writeAcceptCharset", false)
                .getBeanDefinition());

        final String objectMapperId = findObjectMapper(id);

        LOG.debug("Client [{}]: Registering MappingJackson2HttpMessageConverter referencing [{}]", id, objectMapperId);
        list.add(genericBeanDefinition(MappingJackson2HttpMessageConverter.class)
                .addConstructorArgReference(objectMapperId)
                .getBeanDefinition());

        LOG.debug("Client [{}]: Registering StreamConverter referencing [{}]", id, objectMapperId);
        list.add(genericBeanDefinition(Streams.class)
                .setFactoryMethod("streamConverter")
                .addConstructorArgReference(objectMapperId)
                .getBeanDefinition());

        return BeanDefinitionBuilder.genericBeanDefinition(ClientHttpMessageConverters.class)
                .addConstructorArgValue(list);
    });
}
项目:spring-cloud-dashboard    文件:WebConfiguration.java   
@Bean
public HttpMessageConverters messageConverters() {
    final ObjectMapper objectMapper = new ObjectMapper();
    setupObjectMapper(objectMapper);
    return new HttpMessageConverters(
            // Prevent default converters
            false,
            // Have Jackson2 converter as the sole converter
            Arrays.<HttpMessageConverter<?>>asList(new MappingJackson2HttpMessageConverter(objectMapper)));
}
项目:easyweb    文件:WebConfig.java   
/**
 * 配置使用springmvc fastjson
 * @return
 */
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    fastConverter.setFastJsonConfig(fastJsonConfig);
    HttpMessageConverter<?> converter = fastConverter;
    return new HttpMessageConverters(converter);
}
项目:springbootWeb    文件:MessageConverterConfig.java   
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    //处理中文乱码
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastConverter.setSupportedMediaTypes(fastMediaTypes);
    return new HttpMessageConverters((HttpMessageConverter<?>) fastConverter);
}
项目:jkes    文件:WebConfig.java   
@Bean
public HttpMessageConverters customConverters() {
    MappingJackson2HttpMessageConverter jsonConverter =
            new MappingJackson2HttpMessageConverter();
    jsonConverter.setSupportedMediaTypes(Arrays.asList(
            new MediaType("application", "json"),
            new MediaType("text", "json")
    ));

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JsonOrgModule());
    jsonConverter.setObjectMapper(objectMapper);
    return new HttpMessageConverters(jsonConverter);
}
项目:apollo-custom    文件:HttpMessageConverterConfiguration.java   
@Bean
public HttpMessageConverters messageConverters() {
  GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
  gsonHttpMessageConverter.setGson(
          new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create());
  final List<HttpMessageConverter<?>> converters = Lists.newArrayList(
          new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(),
          new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter);
  return new HttpMessageConverters() {
    @Override
    public List<HttpMessageConverter<?>> getConverters() {
      return converters;
    }
  };
}
项目:FastBootWeixin    文件:WxInvokerConfiguration.java   
/**
 * 只考虑微信的消息转换,后期可以优化
 * 其实这里完全可以使用系统的Bean,但是这里我想特殊处理,只对微信消息做转换,所以定制化了几个converter
 *
 * @return dummy
 */
private HttpMessageConverters getDefaultWxMessageConverters() {
    StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
    stringConverter.setWriteAcceptCharset(false);
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    Jaxb2RootElementHttpMessageConverter xmlConverter = new Jaxb2RootElementHttpMessageConverter();
    AllEncompassingFormHttpMessageConverter formConverter = new AllEncompassingFormHttpMessageConverter();
    ResourceHttpMessageConverter resourceConverter = new ResourceHttpMessageConverter();
    HttpMessageConverters wxMessageConverters = new HttpMessageConverters(stringConverter, jsonConverter, xmlConverter, formConverter, resourceConverter);
    return wxMessageConverters;
}
项目:OntoBench    文件:WebMvcConfig.java   
@Bean
public HttpMessageConverters customConverters() {
  List<HttpMessageConverter<?>> converters = new ArrayList<>();

  converters.add(new FunctionalSyntaxHttpMessageConverter());
  converters.add(new ManchesterSyntaxHttpMessageConverter());
  converters.add(new OwlXmlHttpMessageConverter());
  converters.add(new RdfXmlOntologyHttpMessageConverter());
  converters.add(new TurtleOntologyHttpMessageConverter());

  return new HttpMessageConverters(converters);
}
项目:apollo    文件:HttpMessageConverterConfiguration.java   
@Bean
public HttpMessageConverters messageConverters() {
  GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
  gsonHttpMessageConverter.setGson(
          new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create());
  final List<HttpMessageConverter<?>> converters = Lists.newArrayList(
          new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(),
          new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter);
  return new HttpMessageConverters() {
    @Override
    public List<HttpMessageConverter<?>> getConverters() {
      return converters;
    }
  };
}
项目:ByteTCC    文件:SpringCloudBackupConfiguration.java   
@org.springframework.context.annotation.Primary
@org.springframework.context.annotation.Bean
public feign.codec.Decoder compensableFeignDecoder(@Autowired feign.codec.Decoder decoder,
        @Autowired ObjectFactory<HttpMessageConverters> objectFactory) {
    CompensableFeignDecoder feignDecoder = new CompensableFeignDecoder(decoder);
    feignDecoder.setObjectFactory(objectFactory);
    return feignDecoder;
}
项目:ByteTCC    文件:SpringCloudConfiguration.java   
@org.springframework.context.annotation.Primary
@org.springframework.context.annotation.Bean
public feign.codec.Decoder compensableFeignDecoder(@Autowired ObjectFactory<HttpMessageConverters> objectFactory) {
    CompensableFeignDecoder feignDecoder = new CompensableFeignDecoder();
    feignDecoder.setObjectFactory(objectFactory);
    return feignDecoder;
}
项目:spring-cloud-dataflow    文件:WebConfiguration.java   
@Bean
public HttpMessageConverters messageConverters(ObjectMapper objectMapper) {
    return new HttpMessageConverters(
            // Prevent default converters
            false,
            // Have Jackson2 converter as the sole converter
            Arrays.<HttpMessageConverter<?>>asList(new MappingJackson2HttpMessageConverter(objectMapper)));
}
项目:riptide    文件:DefaultRiptideRegistrar.java   
private BeanDefinition registerHttpMessageConverters(final String id) {
    // we use the wrong type here since that's the easiest way to influence the name
    // we want exampleHttpMessageConverters, rather than exampleClientHttpMessageConverters
    final String convertersId = registry.registerIfAbsent(id, HttpMessageConverters.class, () -> {
        final List<Object> list = list();

        log.debug("Client [{}]: Registering StringHttpMessageConverter", id);
        list.add(genericBeanDefinition(StringHttpMessageConverter.class)
                .addPropertyValue("writeAcceptCharset", false)
                .getBeanDefinition());

        final String objectMapperId = findObjectMapper(id);

        log.debug("Client [{}]: Registering MappingJackson2HttpMessageConverter referencing [{}]", id,
                objectMapperId);
        list.add(genericBeanDefinition(MappingJackson2HttpMessageConverter.class)
                .addConstructorArgReference(objectMapperId)
                .getBeanDefinition());

        ifPresent("org.zalando.riptide.stream.Streams", () -> {
            log.debug("Client [{}]: Registering StreamConverter referencing [{}]", id, objectMapperId);
            list.add(genericBeanDefinition(Streams.class)
                    .setFactoryMethod("streamConverter")
                    .addConstructorArgReference(objectMapperId)
                    .getBeanDefinition());
        });

        return BeanDefinitionBuilder.genericBeanDefinition(ClientHttpMessageConverters.class)
                .addConstructorArgValue(list);
    });

    final AbstractBeanDefinition converters = BeanDefinitionBuilder.genericBeanDefinition()
            .setFactoryMethod("getConverters")
            .getBeanDefinition();
    converters.setFactoryBeanName(convertersId);

    return converters;
}
项目:ByteJTA    文件:SpringCloudConfiguration.java   
@org.springframework.context.annotation.Primary
@org.springframework.context.annotation.Bean
public feign.codec.Decoder transactionFeignDecoder(@Autowired ObjectFactory<HttpMessageConverters> objectFactory,
        @Autowired feign.codec.Decoder decoder) {
    TransactionFeignDecoder feignDecoder = new TransactionFeignDecoder(decoder);
    feignDecoder.setObjectFactory(objectFactory);
    return feignDecoder;
}
项目:SpringBoot-Study    文件:App.java   
@Bean
HttpMessageConverters fastJsonHttpMessageConverters() {
    return new HttpMessageConverters(new EncrypConverter());
}
项目:spring-boot-vue-simple-sample    文件:JsonSampleControllerTest.java   
public TestRestTemplateConfig(
        final ObjectProvider<HttpMessageConverters> messageConverters,
        final ObjectProvider<List<RestTemplateCustomizer>> restTemplateCustomizers) {
    super(messageConverters, restTemplateCustomizers);
}
项目:spring-cloud-samples    文件:CustomEncode.java   
public CustomEncode(ObjectFactory<HttpMessageConverters> messageConverters) {
    this.messageConverters = messageConverters;
}
项目:FastBootWeixin    文件:WxInvokerConfiguration.java   
public WxInvokerConfiguration(
        WxProperties wxProperties,
        ObjectProvider<HttpMessageConverters> messageConverters) {
    this.wxProperties = wxProperties;
    this.messageConverters = messageConverters;
}
项目:SkyEye    文件:MvcConfig.java   
@Bean
public HttpMessageConverters getJacksonHttpMessageConverters(ObjectMapper objectMapper) {
    MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
    converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN));
    return new HttpMessageConverters(converter);
}
项目:ly-security    文件:AppConfig.java   
@Bean
public HttpMessageConverters httpMessageConverters() {

    //FastJson
    return new HttpMessageConverters(fastJsonHttpMessageConverter4());
}
项目:cloud-native-zwitscher    文件:QuotesOnDesignConfiguration.java   
@Bean
public Decoder feignDecoder() {
    HttpMessageConverter jacksonConverter = new QuoteOnDesignMessageConverter();
    ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
    return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
}
项目:api-server-seed    文件:FastJSONConfig.java   
@Bean
public HttpMessageConverters customConverters() {
    HttpMessageConverter<?> additional = new FastJsonHttpMessageConverter();
    return new HttpMessageConverters(additional);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMvcIntegrationTests.java   
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters() {
    return new HttpMessageConverters(this.converters == null
            ? Collections.<HttpMessageConverter<?>>emptyList() : this.converters);
}
项目:put-it-to-rest    文件:AccessTokensMissingTest.java   
@Bean
@Primary
public HttpMessageConverters httpMessageConverters() {
    return new HttpMessageConverters();
}
项目:ByteTCC    文件:SpringCloudBackupConfiguration.java   
@org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean(feign.codec.Decoder.class)
@org.springframework.context.annotation.Bean
public feign.codec.Decoder feignDecoder(@Autowired ObjectFactory<HttpMessageConverters> messageConverters) {
    return new ResponseEntityDecoder(new SpringDecoder(messageConverters));
}
项目:ByteTCC    文件:CompensableFeignDecoder.java   
public ObjectFactory<HttpMessageConverters> getObjectFactory() {
    return objectFactory;
}
项目:ByteTCC    文件:CompensableFeignDecoder.java   
public void setObjectFactory(ObjectFactory<HttpMessageConverters> objectFactory) {
    this.objectFactory = objectFactory;
}
项目:spring-boot-concourse    文件:EndpointMvcIntegrationTests.java   
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters() {
    return new HttpMessageConverters(this.converters == null
            ? Collections.<HttpMessageConverter<?>>emptyList() : this.converters);
}
项目:spring-cloud-function    文件:ReactorAutoConfiguration.java   
@Bean
public FluxReturnValueHandler fluxReturnValueHandler(FunctionInspector inspector,
        HttpMessageConverters converters) {
    return new FluxReturnValueHandler(inspector, converters.getConverters());
}
项目:contestparser    文件:EndpointMvcIntegrationTests.java   
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters() {
    return new HttpMessageConverters(this.converters);
}
项目:onetwo    文件:ResultErrorDecoder.java   
public ResultErrorDecoder(HttpMessageConverters httpMessageConverters) {
    super();
    this.httpMessageConverters = httpMessageConverters;
}
项目:onetwo    文件:ExtResponseEntityDecoder.java   
public ExtResponseEntityDecoder(ObjectFactory<HttpMessageConverters> messageConverter) {
    this.messageConverters = messageConverter;
}
项目:spring-cloud-square    文件:SpringConverterFactory.java   
public SpringConverterFactory(ObjectFactory<HttpMessageConverters> messageConverters, ConversionService conversionService) {
    this.messageConverters = messageConverters;
    this.conversionService = conversionService;
}
项目:spring-cloud-square    文件:RetrofitRibbonNoAnnotationTests.java   
@Bean
public SpringConverterFactory springConverterFactory(ConversionService conversionService,
                                                     ObjectFactory<HttpMessageConverters> messageConverters) {
    return new SpringConverterFactory(messageConverters, conversionService);
}
项目:spring-cloud-square    文件:RetrofitNoAnnotationTests.java   
@Bean
public SpringConverterFactory springConverterFactory(ConversionService conversionService,
                                                     ObjectFactory<HttpMessageConverters> messageConverters) {
    return new SpringConverterFactory(messageConverters, conversionService);
}
项目:ByteJTA    文件:SpringCloudConfiguration.java   
@org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean(feign.codec.Decoder.class)
@org.springframework.context.annotation.Bean
public feign.codec.Decoder feignDecoder(@Autowired ObjectFactory<HttpMessageConverters> messageConverters) {
    return new ResponseEntityDecoder(new SpringDecoder(messageConverters));
}