Java 类com.sun.jersey.api.client.AsyncWebResource 实例源码

项目:visual-scripting    文件:RestClientImpl.java   
public RestClientImpl(Client client, WebResource webResource, AsyncWebResource asyncWebResource, String url) {
    this.client = client;
    this.client.setReadTimeout(READ_TIMEOUT);
    this.webResource = webResource;
    this.asyncWebResource = asyncWebResource;
    this.url = url;
}
项目:jersey-http-client    文件:NonBlockingHttpClient.java   
/**
    * Make HTTP GET call to the given url
    * 
    * @param url
    */
   public void get(String url) {
ClientConfig cc = new DefaultNonBlockingClientConfig();
Client c = NonBlockingClient.create(cc);
AsyncWebResource awr = c.asyncResource(url);
// makes HTTP GET call
awr.get(new TypeListener<ClientResponse>(ClientResponse.class) {

    public void onComplete(Future<ClientResponse> f)
        throws InterruptedException {
    try {
        System.out.println("Got Response. HTTP Code = "
            + f.get().getStatus());
    } catch (ExecutionException e) {
        System.out.println("Something went wrong!");
    }
    }

});
System.out.println("Continued to execute...");
System.out.println("Done!");
   }
项目:pinterest4j    文件:CoreAPI.java   
public void buildAsync(TypeListener<ClientResponse> listener) {
    AsyncWebResource.Builder builder = getAsyncWR(protocol, url, ajaxUsage);
    if(mediaType != null) {
        builder = builder.type(mediaType);
    }
    switch(method) {
        case GET :
            builder.get(listener);
            break;
        case POST :
            builder.post(listener, requestEntity);
            break;
        case DELETE :
            builder.delete(listener);
            break;
        default :
            throw new PinterestRuntimeException("Unknown HTTP method");
    }
}
项目:pinterest4j    文件:CoreAPI.java   
protected AsyncWebResource.Builder getAsyncWR(Protocol protocol, String url, boolean useAJAX) {
    if(asyncClient == null) {
        asyncClient = NonBlockingClient.create(getClientConfig());
    }
    AsyncWebResource.Builder wr = null;
    String requestURL = String.format("%s://%s/%s", protocol.name().toLowerCase(PINTEREST_LOCALE), PINTEREST_DOMAIN, url);
    wr = asyncClient.asyncResource(UriBuilder.fromUri(requestURL).build()).getRequestBuilder();
    wr.header("Referer", "https://pinterest.com/");
    if(accessToken != null) {
        wr = wr.header(COOKIE_HEADER_NAME, accessToken.generateCookieHeader());
        wr = wr.header("X-CSRFToken", accessToken.getCsrfToken().getValue());
        if(useAJAX) {
            wr = wr.header("X-Requested-With", "XMLHttpRequest");
        }
    }
    return wr;
}
项目:apex-core    文件:WebServicesClient.java   
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);
}
项目:apex-core    文件:WebServicesClient.java   
public <T> Future<T> process(final AsyncWebResource wr, final ITypeListener<T> listener, final WebServicesAsyncHandler<T> handler) throws IOException
{
  return SecureExecutor.execute(new SecureExecutor.WorkLoad<Future<T>>()
  {
    @Override
    public Future<T> run()
    {
      return handler.process(wr, listener);
    }
  });
}
项目:apex-core    文件:WebServicesClient.java   
@Override
public Future<T> process(AsyncWebResource webResource, ITypeListener<T> listener)
{
  return webResource.get(listener);
}
项目:apex-core    文件:WebServicesClient.java   
@Override
public Future<T> process(AsyncWebResource webResource, ITypeListener<T> listener)
{
  return webResource.delete(listener);
}
项目:nexus-replication-plugin    文件:ArtifactUpdateApiClientImpl.java   
/**
 * Returns jersey HTTP resource to access to the remote replication servers
 *
 * @param nexusUrl URL of the remote server
 * @param login    Username on the remote server
 * @param password User's password
 * @return Jersey HTTP client
 */
private AsyncWebResource.Builder getService(String nexusUrl, String login, String password) {
    Client client = getClient(login, password);
    client.setExecutorService(jerseyHttpClientExecutor);
    AsyncWebResource webResource = client.asyncResource(UriBuilder.fromUri(nexusUrl).build());
    webResource = webResource.path("service").path("local").path("artifact").path("maven").path("update");
    return webResource.accept(MediaType.APPLICATION_XML_TYPE)
            .type(MediaType.APPLICATION_XML_TYPE);
}
项目:FinanceAnalytics    文件:FudgeRestClient.java   
/**
 * Obtains a class that can be used to call a remote resource asynchronously.
 * 
 * @param uri the URI of the resource, not null
 * @return a class that can be used to call a remote resource, not null
 */
public AsyncWebResource accessAsync(final URI uri) {
  return getClient().asyncResource(uri);
}
项目:apex-core    文件:WebServicesClient.java   
public abstract Future<T> process(AsyncWebResource webResource, ITypeListener<T> listener);