Java 类org.apache.http.client.fluent.Async 实例源码

项目:movilizer-webservice    文件:UploadFileService.java   
private void upload(HttpEntity entity, Integer connectionTimeoutInMillis,
                    FutureCallback<UploadResponse> asyncHandler) {
    try {
        Async.newInstance().execute(Request.Post(documentUploadAddress.toURI())
                .addHeader(USER_AGENT_HEADER_KEY, DefaultValues.USER_AGENT)
                .connectTimeout(connectionTimeoutInMillis)
                .body(entity), new ResponseHandlerAdapter<UploadResponse>(asyncHandler) {
            @Override
            public UploadResponse convertHttpResponse(HttpResponse httpResponse) {
                logger.info(MESSAGES.UPLOAD_COMPLETE);
                int statusCode = httpResponse.getStatusLine().getStatusCode();
                String errorMessage = httpResponse.getStatusLine().getReasonPhrase();
                if (statusCode == POSSIBLE_BAD_CREDENTIALS) {
                    errorMessage = errorMessage
                            + MESSAGES.FAILED_FILE_UPLOAD_CREDENTIALS;
                }
                return new UploadResponse(statusCode, errorMessage);
            }
        });
    } catch (URISyntaxException e) {
        if (logger.isErrorEnabled()) {
            logger.error(String.format(MESSAGES.UPLOAD_ERROR, e.getMessage()));
        }
        asyncHandler.onFailure(new MovilizerWebServiceException(e));
    }
}
项目:GlobalFS    文件:HttpStorageCaching.java   
public HttpStorageCaching() {
threadpool = Executors.newFixedThreadPool(100);
asyncHttp = Async.newInstance().use(threadpool);
      cacheWeighter = new Weigher<String, byte[]>() {
          @Override
          public int weigh(String key, byte[] value) {
              return value.length;
          }
      };

      cache = CacheBuilder.newBuilder()
              .weigher(cacheWeighter)
              .maximumWeight(CACHE_WEIGHT)
              .build();
  }
项目:GlobalFS    文件:HttpStorage.java   
public HttpStorage() {
threadpool = Executors.newFixedThreadPool(100);
asyncHttp = Async.newInstance().use(threadpool);
  }
项目:cyNeo4j    文件:Neo4jRESTServer.java   
protected void setupAsync(){
    threadpool = Executors.newFixedThreadPool(2);
    async = Async.newInstance().use(threadpool);
}