當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。