Java 类org.apache.http.concurrent.BasicFuture 实例源码

项目:purecloud-iot    文件:Async.java   
public <T> Future<T> execute(
        final Request request, final ResponseHandler<T> handler, final FutureCallback<T> callback) {
    final BasicFuture<T> future = new BasicFuture<T>(callback);
    final ExecRunnable<T> runnable = new ExecRunnable<T>(
            future,
            request,
            this.executor != null ? this.executor : Executor.newInstance(),
            handler);
    if (this.concurrentExec != null) {
        this.concurrentExec.execute(runnable);
    } else {
        final Thread t = new Thread(runnable);
        t.setDaemon(true);
        t.start();
    }
    return future;
}
项目:pinpoint    文件:DefaultClientExchangeHandlerImplStartMethodInterceptor.java   
private boolean isAsynchronousInvocation(final Object target, final Object[] args) {
    if (!(target instanceof ResultFutureGetter)) {
        logger.debug("Invalid target object. Need field accessor({}).", HttpClient4Constants.FIELD_RESULT_FUTURE);
        return false;
    }

    BasicFuture<?> future = ((ResultFutureGetter)target)._$PINPOINT$_getResultFuture();

    if (future == null) {
        logger.debug("Invalid target object. field is null({}).", HttpClient4Constants.FIELD_RESULT_FUTURE);
        return false;
    }

    if (!(future instanceof AsyncContextAccessor)) {
        logger.debug("Invalid resultFuture field object. Need metadata accessor({}).", HttpClient4Constants.METADATA_ASYNC_CONTEXT);
        return false;
    }

    return true;
}
项目:purecloud-iot    文件:Async.java   
ExecRunnable(
        final BasicFuture<T> future,
        final Request request,
        final Executor executor,
        final ResponseHandler<T> handler) {
    super();
    this.future = future;
    this.request = request;
    this.executor = executor;
    this.handler = handler;
}
项目:pinpoint    文件:ClosableAsyncHttpClientIT.java   
@Test
 public void test() throws Exception {
     CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom().useSystemProperties().build();
     httpClient.start();

     try {
         HttpPost httpRequest = new HttpPost(webServer.getCallHttpUrl());

         List<NameValuePair> params = new ArrayList<NameValuePair>();
         params.add(new BasicNameValuePair("param1", "value1"));
         httpRequest.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8.name()));

         Future<HttpResponse> responseFuture = httpClient.execute(httpRequest, null);
         HttpResponse response = (HttpResponse) responseFuture.get();

         if ((response != null) && (response.getEntity() != null)) {
             EntityUtils.consume(response.getEntity());
         }
     } finally {
         httpClient.close();
     }

     PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
     verifier.printCache();

     verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", CloseableHttpAsyncClient.class.getMethod("execute", HttpUriRequest.class, FutureCallback.class)));
     final String destinationId = webServer.getHostAndPort();
     final String httpUrl = webServer.getCallHttpUrl();
     verifier.verifyTrace(async(
                 event("HTTP_CLIENT_4", Class.forName("org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl").getMethod("start"), null, null, destinationId,
                         annotation("http.url", httpUrl), annotation("http.entity", "param1=value1")),
                 event("ASYNC","Asynchronous Invocation"),
                 event("HTTP_CLIENT_4_INTERNAL", BasicFuture.class.getMethod("completed", Object.class))
     ));
     verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", BasicFuture.class.getMethod("get")));

     verifier.verifyTraceCount(0);
}
项目:pinpoint    文件:ResultFutureGetter.java   
@SuppressWarnings("rawtypes")
BasicFuture _$PINPOINT$_getResultFuture();