本文整理汇总了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);
}
示例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;
}
}