com.sun.jersey.api.client.Client.asyncResource()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(215)

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

Client.asyncResource介绍

[英]Create an asynchronous Web resource from the client.
[中]从客户端创建异步Web资源。

代码示例

代码示例来源:origin: com.sun.jersey/jersey-bundle

/**
 * Create an asynchronous Web resource from the client.
 *
 * @param u the URI of the resource.
 * @return the Web resource.
 */
public AsyncWebResource asyncResource(String u) {
  return asyncResource(URI.create(u));
}

代码示例来源:origin: jersey/jersey-1.x

/**
 * Create an asynchronous Web resource from the client.
 *
 * @param u the URI of the resource.
 * @return the Web resource.
 */
public AsyncWebResource asyncResource(String u) {
  return asyncResource(URI.create(u));
}

代码示例来源:origin: org.apache.apex/apex-engine

public <T> Future<T> process(String url, final ITypeListener<T> listener, WebServicesAsyncHandler<T> handler)
  throws IOException
{
 AsyncWebResource wr = client.asyncResource(url);
 return process(wr, listener, handler);
}

代码示例来源:origin: apache/eagle

protected AsyncWebResource getAsyncWebResource(String relativePath){
  return this.getJerseyClient().asyncResource(this.getBaseEndpoint() + relativePath);
}

代码示例来源:origin: org.apache.eagle/eagle-client-base

protected AsyncWebResource getAsyncWebResource(String relativePath){
  return this.getJerseyClient().asyncResource(this.getBaseEndpoint() + relativePath);
}

代码示例来源:origin: korpling/ANNIS

return user.getClient().asyncResource(uri);
return anonymousClient.get().asyncResource(uri);

代码示例来源:origin: com.applitools/eyes-connectivity-java4-jersey1x

@Override
public void downloadString(URL uri, boolean isSecondRetry, final IDownloadListener listener) {
  AsyncWebResource target = Client.create().asyncResource(uri.toString());
  AsyncWebResource.Builder request = target.accept(MediaType.WILDCARD);
  request.get(new TypeListener<ClientResponse>(ClientResponse.class) {
    public void onComplete(Future<ClientResponse> f) {
      int status = 0;
      ClientResponse clientResponse = null;
      try {
        clientResponse = f.get();
        status = clientResponse.getStatus();
        if (status > 300) {
          logger.verbose("Got response status code - " + status);
          listener.onDownloadFailed();
          return;
        }
        InputStream entityInputStream = clientResponse.getEntityInputStream();
        StringWriter writer = new StringWriter();
        IOUtils.copy(entityInputStream, writer, "UTF-8");
        String theString = writer.toString();
        listener.onDownloadComplete(theString);
      } catch (Exception e) {
        GeneralUtils.logExceptionStackTrace(e);
        logger.verbose("Failed to parse request(status= " + status + ") = "+ clientResponse.getEntity(String.class));
        listener.onDownloadFailed();
      }
    }
  });
}

相关文章