Exemplo n.º 1
0
  private F.Promise<WSResponse> execute(Request request) {

    final scala.concurrent.Promise<WSResponse> scalaPromise =
        scala.concurrent.Promise$.MODULE$.<WSResponse>apply();
    try {
      AsyncHttpClient asyncHttpClient = (AsyncHttpClient) client.getUnderlying();
      asyncHttpClient.executeRequest(
          request,
          new AsyncCompletionHandler<Response>() {
            @Override
            public Response onCompleted(Response response) {
              final Response ahcResponse = response;
              scalaPromise.success(new AhcWSResponse(ahcResponse));
              return response;
            }

            @Override
            public void onThrowable(Throwable t) {
              scalaPromise.failure(t);
            }
          });
    } catch (RuntimeException exception) {
      scalaPromise.failure(exception);
    }
    return F.Promise.wrap(scalaPromise.future());
  }
Exemplo n.º 2
0
 public void stop() {
   Logger.trace("Releasing http client connections...");
   httpClient.close();
 }