当前位置: 首页>>代码示例>>Java>>正文


Java Client.stop方法代码示例

本文整理汇总了Java中org.restlet.Client.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Client.stop方法的具体用法?Java Client.stop怎么用?Java Client.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.Client的用法示例。


在下文中一共展示了Client.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: list

import org.restlet.Client; //导入方法依赖的package包/类
@Override
public List<Car> list() {
    Client client = new Client(new Context(), Protocol.HTTPS);
    Series<Parameter> parameters = client.getContext().getParameters();
    parameters.add("truststorePath", System.getProperty("javax.net.ssl.trustStore"));

    ClientResource clientResource = new ClientResource("https://localhost:8043/api/cars/cars");
    clientResource.setNext(client);
    ChallengeResponse challenge = new ChallengeResponse(ChallengeScheme.HTTP_OAUTH_BEARER);
    challenge.setRawValue(Request.getCurrent().getAttributes().getOrDefault("token", "").toString());
    clientResource.setChallengeResponse(challenge);
    CarServiceInterface carServiceInterface = clientResource.wrap(CarServiceInterface.class);
    Car[] allCars = carServiceInterface.getAllCars();
    try {
        client.stop();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return asList(allCars);
}
 
开发者ID:cdelmas,项目名称:microservices-comparison,代码行数:21,代码来源:RemoteCarService.java

示例2: postToMF

import org.restlet.Client; //导入方法依赖的package包/类
/**
 * The result of doing POST to MF is returned.
 *
 * @param path path of rest api
 * @param sendParam parameter to send
 * @param seqNo sequence No.
 * @return result that client posted
 * @throws IOException
 */
private String postToMF(String path, String sendParam, String seqNo) throws IOException {
    ClientResource client = new ClientResource(path);
    Client ct = new Client(new Context(), Protocol.HTTP);
    client.setNext(ct);
    logger.info(seqNo + "\t" + "Send path:" + path);
    logger.info(seqNo + "\t" + "Send Param:" + sendParam);
    StringRepresentation srp = new StringRepresentation(sendParam.toCharArray());

    Representation representation = client.post(srp);
    try {
        return representation.getText();
    } finally {
        if (representation != null) {
            representation.release();
        }
        srp.release();
        client.release();

        representation = null;
        srp = null;
        client = null;
        try {
            ct.stop();
        } catch (Exception e) {
            e.printStackTrace();
        }
        ct = null;
    }
}
 
开发者ID:o3project,项目名称:ocnrm,代码行数:39,代码来源:MFApiCaller.java


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