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

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

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

RestTemplate.doExecute介绍

[英]Execute the given method on the provided URI.

The ClientHttpRequest is processed using the RequestCallback; the response with the ResponseExtractor.
[中]在提供的URI上执行给定的方法。
使用RequestCallback处理ClientHttpRequest;使用ResponseExtractor进行响应。

代码示例

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

/**
 * {@inheritDoc}
 * <p>To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
 * but not both, consider using:
 * <ul>
 * <li>{@link #acceptHeaderRequestCallback(Class)}
 * <li>{@link #httpEntityCallback(Object)}
 * <li>{@link #httpEntityCallback(Object, Type)}
 * <li>{@link #responseEntityExtractor(Type)}
 * </ul>
 */
@Override
@Nullable
public <T> T execute(URI url, HttpMethod method, @Nullable RequestCallback requestCallback,
    @Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
  return doExecute(url, method, requestCallback, responseExtractor);
}

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

/**
 * {@inheritDoc}
 * <p>To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
 * but not both, consider using:
 * <ul>
 * <li>{@link #acceptHeaderRequestCallback(Class)}
 * <li>{@link #httpEntityCallback(Object)}
 * <li>{@link #httpEntityCallback(Object, Type)}
 * <li>{@link #responseEntityExtractor(Type)}
 * </ul>
 */
@Override
@Nullable
public <T> T execute(URI url, HttpMethod method, @Nullable RequestCallback requestCallback,
    @Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
  return doExecute(url, method, requestCallback, responseExtractor);
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

@Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
    ResponseExtractor<T> responseExtractor) throws RestClientException {
  try {
    return super.doExecute(url, method, requestCallback, responseExtractor);
  }
  catch (Exception e) {
    log.error("Exception occurred while sending the message to uri [" + url
        + "]. Exception [" + e.getCause() + "]");
    throw new AssertionError(e);
  }
}

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

/**
 * {@inheritDoc}
 * <p>To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
 * but not both, consider using:
 * <ul>
 * <li>{@link #acceptHeaderRequestCallback(Class)}
 * <li>{@link #httpEntityCallback(Object)}
 * <li>{@link #httpEntityCallback(Object, Type)}
 * <li>{@link #responseEntityExtractor(Type)}
 * </ul>
 */
@Override
@Nullable
public <T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
    @Nullable ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException {
  URI expanded = getUriTemplateHandler().expand(url, uriVariables);
  return doExecute(expanded, method, requestCallback, responseExtractor);
}

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

/**
 * {@inheritDoc}
 * <p>To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
 * but not both, consider using:
 * <ul>
 * <li>{@link #acceptHeaderRequestCallback(Class)}
 * <li>{@link #httpEntityCallback(Object)}
 * <li>{@link #httpEntityCallback(Object, Type)}
 * <li>{@link #responseEntityExtractor(Type)}
 * </ul>
 */
@Override
@Nullable
public <T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
    @Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables)
    throws RestClientException {
  URI expanded = getUriTemplateHandler().expand(url, uriVariables);
  return doExecute(expanded, method, requestCallback, responseExtractor);
}

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

/**
 * {@inheritDoc}
 * <p>To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
 * but not both, consider using:
 * <ul>
 * <li>{@link #acceptHeaderRequestCallback(Class)}
 * <li>{@link #httpEntityCallback(Object)}
 * <li>{@link #httpEntityCallback(Object, Type)}
 * <li>{@link #responseEntityExtractor(Type)}
 * </ul>
 */
@Override
@Nullable
public <T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
    @Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables)
    throws RestClientException {
  URI expanded = getUriTemplateHandler().expand(url, uriVariables);
  return doExecute(expanded, method, requestCallback, responseExtractor);
}

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

/**
 * {@inheritDoc}
 * <p>To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
 * but not both, consider using:
 * <ul>
 * <li>{@link #acceptHeaderRequestCallback(Class)}
 * <li>{@link #httpEntityCallback(Object)}
 * <li>{@link #httpEntityCallback(Object, Type)}
 * <li>{@link #responseEntityExtractor(Type)}
 * </ul>
 */
@Override
@Nullable
public <T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
    @Nullable ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException {
  URI expanded = getUriTemplateHandler().expand(url, uriVariables);
  return doExecute(expanded, method, requestCallback, responseExtractor);
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

@Override
protected <T> T doExecute(URI originalUrl, HttpMethod method,
    RequestCallback requestCallback, ResponseExtractor<T> responseExtractor)
    throws RestClientException {
  URI uri = this.extractor.zipkinUrl(this.zipkinProperties);
  URI newUri = resolvedZipkinUri(originalUrl, uri);
  return super.doExecute(newUri, method, requestCallback, responseExtractor);
}

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

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
    throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

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

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
    throws RestClientException {
  Type type = responseType.getType();
  RequestCallback requestCallback = httpEntityCallback(requestEntity, type);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(type);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

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

@Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
    ResponseExtractor<T> responseExtractor) throws RestClientException {
  OAuth2AccessToken accessToken = context.getAccessToken();
  RuntimeException rethrow = null;
  try {
    return super.doExecute(url, method, requestCallback, responseExtractor);
  }
  catch (AccessTokenRequiredException e) {
    rethrow = e;
  }
  catch (OAuth2AccessDeniedException e) {
    rethrow = e;
  }
  catch (InvalidTokenException e) {
    // Don't reveal the token value in case it is logged
    rethrow = new OAuth2AccessDeniedException("Invalid token for client=" + getClientId());
  }
  if (accessToken != null && retryBadAccessTokens) {
    context.setAccessToken(null);
    try {
      return super.doExecute(url, method, requestCallback, responseExtractor);
    }
    catch (InvalidTokenException e) {
      // Don't reveal the token value in case it is logged
      rethrow = new OAuth2AccessDeniedException("Invalid token for client=" + getClientId());
    }
  }
  throw rethrow;
}

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

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
    throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

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

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
    throws RestClientException {
  Type type = responseType.getType();
  RequestCallback requestCallback = httpEntityCallback(requestEntity, type);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(type);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

代码示例来源:origin: kaaproject/kaa

while (true) {
 try {
  return super.doExecute(url, method, requestCallback, responseExtractor);
 } catch (ResourceAccessException ex) {
  logger.info("Connect to ({}:{}) failed", getCurHost(), getCurPort(), ex);

代码示例来源:origin: org.springframework.android/spring-android-rest-template

public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
    ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException {
  UriTemplate uriTemplate = new HttpUrlTemplate(url);
  URI expanded = uriTemplate.expand(urlVariables);
  return doExecute(expanded, method, requestCallback, responseExtractor);
}

代码示例来源:origin: org.springframework.android/spring-android-rest-template

public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
    ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException {
  UriTemplate uriTemplate = new HttpUrlTemplate(url);
  URI expanded = uriTemplate.expand(urlVariables);
  return doExecute(expanded, method, requestCallback, responseExtractor);
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-zipkin

@Override
protected <T> T doExecute(URI originalUrl, HttpMethod method,
    RequestCallback requestCallback, ResponseExtractor<T> responseExtractor)
    throws RestClientException {
  URI uri = this.extractor.zipkinUrl(this.zipkinProperties);
  URI newUri = resolvedZipkinUri(originalUrl, uri);
  return super.doExecute(newUri, method, requestCallback, responseExtractor);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
    throws RestClientException {
  RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
    throws RestClientException {
  Type type = responseType.getType();
  RequestCallback requestCallback = httpEntityCallback(requestEntity, type);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(type);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
    throws RestClientException {
  Type type = responseType.getType();
  RequestCallback requestCallback = httpEntityCallback(requestEntity, type);
  ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(type);
  return nonNull(doExecute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor));
}

相关文章