org.springframework.web.client.RestTemplate.getMessageConverters()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.springframework.web.client.RestTemplate.getMessageConverters方法的一些代码示例,展示了RestTemplate.getMessageConverters的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RestTemplate.getMessageConverters方法的具体详情如下:
包路径:org.springframework.web.client.RestTemplate
类名称:RestTemplate
方法名:getMessageConverters

RestTemplate.getMessageConverters介绍

[英]Return the list of message body converters.

The returned List is active and may get appended to.
[中]返回消息正文转换器列表。
返回的列表处于活动状态,可能会被追加到。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return the message body converters.
 */
public List<HttpMessageConverter<?>> getMessageConverters() {
  return this.syncTemplate.getMessageConverters();
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Return the message body converters.
 */
public List<HttpMessageConverter<?>> getMessageConverters() {
  return this.syncTemplate.getMessageConverters();
}

代码示例来源:origin: spring-projects/spring-framework

public ResponseEntityResponseExtractor(@Nullable Type responseType) {
  if (responseType != null && Void.class != responseType) {
    this.delegate = new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  }
  else {
    this.delegate = null;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void doWithRequest(ClientHttpRequest request) throws IOException {
  if (this.responseType != null) {
    List<MediaType> allSupportedMediaTypes = getMessageConverters().stream()
        .filter(converter -> canReadResponse(this.responseType, converter))
        .flatMap(this::getSupportedMediaTypes)
        .distinct()
        .sorted(MediaType.SPECIFICITY_COMPARATOR)
        .collect(Collectors.toList());
    if (logger.isDebugEnabled()) {
      logger.debug("Accept=" + allSupportedMediaTypes);
    }
    request.getHeaders().setAccept(allSupportedMediaTypes);
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T patchForObject(String url, @Nullable Object request, Class<T> responseType,
    Map<String, ?> uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.PATCH, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType)
    throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters());
  return execute(url, HttpMethod.PATCH, requestCallback, responseExtractor);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
    Object... uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: org.springframework/spring-web

public ResponseEntityResponseExtractor(@Nullable Type responseType) {
  if (responseType != null && Void.class != responseType) {
    this.delegate = new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  }
  else {
    this.delegate = null;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
    Map<String, ?> uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T patchForObject(String url, @Nullable Object request, Class<T> responseType,
    Object... uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.PATCH, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T postForObject(URI url, @Nullable Object request, Class<T> responseType)
    throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters());
  return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
  RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
  RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T getForObject(String url, Class<T> responseType, Object... uriVariables) throws RestClientException {
  RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: org.springframework/spring-web

@Override
@Nullable
public <T> T postForObject(URI url, @Nullable Object request, Class<T> responseType)
    throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters());
  return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
}

代码示例来源:origin: org.springframework/spring-web

@Override
@Nullable
public <T> T patchForObject(String url, @Nullable Object request, Class<T> responseType,
    Map<String, ?> uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.PATCH, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: org.springframework/spring-web

@Override
@Nullable
public <T> T patchForObject(String url, @Nullable Object request, Class<T> responseType,
    Object... uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.PATCH, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: org.springframework/spring-web

@Override
@Nullable
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
    Object... uriVariables) throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(request, responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}

代码示例来源:origin: org.springframework/spring-web

@Override
@Nullable
public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
  RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
}

代码示例来源:origin: org.springframework/spring-web

@Override
@Nullable
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
  RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
  HttpMessageConverterExtractor<T> responseExtractor =
      new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
  return execute(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables);
}

相关文章