本文整理匯總了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;
}
}