• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ListenableFutureAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.util.concurrent.ListenableFutureAdapter的典型用法代码示例。如果您正苦于以下问题:Java ListenableFutureAdapter类的具体用法?Java ListenableFutureAdapter怎么用?Java ListenableFutureAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ListenableFutureAdapter类属于org.springframework.util.concurrent包,在下文中一共展示了ListenableFutureAdapter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: request

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
/**
 * Make an HTTP request
 */
protected <T,U> ListenableFuture<T> request(HttpMethod method, String url, HttpHeaders httpHeaders, U body, Class<T> responseType) {
    if (httpHeaders == null) {
        httpHeaders = getRequestHeaders(url);
    }
    HttpEntity<U> requestEntity = new HttpEntity<>(body, httpHeaders);

    ListenableFuture<ResponseEntity<T>> future = asyncRestTemplate.exchange(url, method, requestEntity, responseType);

    return new ListenableFutureAdapter<T, ResponseEntity<T>>(future) {
        @Override
        protected T adapt(ResponseEntity<T> result) throws ExecutionException {
            return result.getBody();
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi-api,代码行数:19,代码来源:NgsiClient.java


示例2: getV2

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
/**
 * @return the list of supported operations under /v2
 */
public ListenableFuture<Map<String, String>> getV2() {
    ListenableFuture<ResponseEntity<JsonNode>> responseFuture = request(HttpMethod.GET, baseURL + "v2", null, JsonNode.class);
    return new ListenableFutureAdapter<Map<String, String>, ResponseEntity<JsonNode>>(responseFuture) {
        @Override
        protected Map<String, String> adapt(ResponseEntity<JsonNode> result) throws ExecutionException {
            Map<String, String> services = new HashMap<>();
            result.getBody().fields().forEachRemaining(entry -> services.put(entry.getKey(), entry.getValue().textValue()));
            return services;
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:15,代码来源:Ngsi2Client.java


示例3: getRegistrations

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
/**
 * Retrieve the list of all Registrations
 * @return a list of registrations
 */
public ListenableFuture<List<Registration>> getRegistrations() {

    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL);
    builder.path("v2/registrations");

    ListenableFuture<ResponseEntity<Registration[]>> e = request(HttpMethod.GET, builder.toUriString(), null, Registration[].class);
    return new ListenableFutureAdapter<List<Registration>, ResponseEntity<Registration[]>>(e) {
        @Override
        protected List<Registration> adapt(ResponseEntity<Registration[]> result) throws ExecutionException {
            return new ArrayList<>(Arrays.asList(result.getBody()));
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:18,代码来源:Ngsi2Client.java


示例4: addSubscription

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
/**
 * Create a new subscription
 * @param subscription the Subscription to add
 * @return subscription Id
 */
public ListenableFuture<String> addSubscription(Subscription subscription) {
    ListenableFuture<ResponseEntity<Void>> s = request(HttpMethod.POST, UriComponentsBuilder.fromHttpUrl(baseURL).path("v2/subscriptions").toUriString(), subscription, Void.class);
    return new ListenableFutureAdapter<String, ResponseEntity<Void>>(s) {
        @Override
        protected String adapt(ResponseEntity<Void> result) throws ExecutionException {
            return extractId(result);
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:15,代码来源:Ngsi2Client.java


示例5: adapt

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
private <T> ListenableFuture<T> adapt(ListenableFuture<ResponseEntity<T>> responseEntityListenableFuture) {
    return new ListenableFutureAdapter<T, ResponseEntity<T>>(responseEntityListenableFuture) {
        @Override
        protected T adapt(ResponseEntity<T> result) throws ExecutionException {
            return result.getBody();
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:9,代码来源:Ngsi2Client.java


示例6: adaptPaginated

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
private <T> ListenableFuture<Paginated<T>> adaptPaginated(ListenableFuture<ResponseEntity<T[]>> responseEntityListenableFuture, int offset, int limit) {
    return new ListenableFutureAdapter<Paginated<T>, ResponseEntity<T[]>>(responseEntityListenableFuture) {
        @Override
        protected Paginated<T> adapt(ResponseEntity<T[]> result) throws ExecutionException {
            return new Paginated<>(Arrays.asList(result.getBody()), offset, limit, extractTotalCount(result));
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:9,代码来源:Ngsi2Client.java


示例7: adaptFuture

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
public <S, T> ListenableFuture<T> adaptFuture(ListenableFuture<S> futureToAdapt,
                                              FunctionalFutureAdapter<S, T> adapter) {
  return new ListenableFutureAdapter<T, S>(futureToAdapt) {
    @Override
    protected T adapt(S objectToAdapt) throws ExecutionException {
      return adapter.adapt(objectToAdapt);
    }
  };
}
 
开发者ID:STeveShary,项目名称:buildTube,代码行数:10,代码来源:AsyncUtil.java


示例8: adaptResponseEntityFuture

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
protected <T> ListenableFutureAdapter<T, ResponseEntity<T>> adaptResponseEntityFuture(
    final ListenableFuture<ResponseEntity<T>> responseEntity) {
  ListenableFutureAdapter<T, ResponseEntity<T>> returnFuture;
  returnFuture = new ListenableFutureAdapter<T, ResponseEntity<T>>(responseEntity) {
    @Override
    protected T adapt(ResponseEntity<T> adapteeResult) throws ExecutionException {
      return adapteeResult.getBody();
    }
  };
  return returnFuture;
}
 
开发者ID:STeveShary,项目名称:buildTube,代码行数:12,代码来源:RestUtil.java


示例9: request

import org.springframework.util.concurrent.ListenableFutureAdapter; //导入依赖的package包/类
/**
 * Build an Http request
 *
 * @param method       Http method
 * @param url          Url
 * @param body         Request body
 * @param responseType Response type
 * @param <T>          Type to deserialize for the response
 * @param <U>          Type to serialize for the body
 * @return              Listenable for request
 */
private <T, U> ListenableFuture<T> request(HttpMethod method, String url, U body, Class<T> responseType) {
    HttpEntity<U> requestEntity = new HttpEntity<>(body, getHttpHeaders(body != null));
    ListenableFuture<ResponseEntity<T>> future = asyncRestTemplate.exchange(url, method, requestEntity, responseType);
    return new ListenableFutureAdapter<T, ResponseEntity<T>>(future) {
        @Override
        protected T adapt(ResponseEntity<T> result) throws ExecutionException {
            return result.getBody();
        }
    };
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-openlpwa-iotagent,代码行数:22,代码来源:OpenLpwaProvider.java



注:本文中的org.springframework.util.concurrent.ListenableFutureAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IGenome类代码示例发布时间:2022-05-23
下一篇:
Java EventListener类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap