本文整理汇总了Java中org.apache.cxf.jaxrs.client.WebClient.fromClient方法的典型用法代码示例。如果您正苦于以下问题:Java WebClient.fromClient方法的具体用法?Java WebClient.fromClient怎么用?Java WebClient.fromClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.jaxrs.client.WebClient
的用法示例。
在下文中一共展示了WebClient.fromClient方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendRequest
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
public <T> T sendRequest (Function <WebClient, T> request) {
int retries = 0;
do {
try {
WebClient webClientCopy = WebClient.fromClient(webClient);
T response = request.apply(webClientCopy);
webClientCopy.close();
return response;
}
catch (NotAuthorizedException e) {
if (retries < 5) {
retries ++;
authClient.refreshAuthenticationContext();
}
else throw e;
}
}
while (retries < 5);
return null;
}
示例2: getGroup
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Override
public GSuiteGroup getGroup(String groupKey) {
String path = MessageFormat.format("groups/{0}", new Object[]{groupKey});
WebClient webClient = WebClient.fromClient(directoryApiClient, true);
ClientAccessToken accessToken = tokenCache.get();
webClient.authorization(accessToken);
GSuiteGroup group = webClient.path(path).get(GSuiteGroup.class);
return group;
}
示例3: getUser
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Override
public GSuiteUser getUser(String userKey) {
String path = MessageFormat.format("users/{0}", new Object[]{userKey});
WebClient webClient = WebClient.fromClient(directoryApiClient, true);
ClientAccessToken accessToken = tokenCache.get();
webClient.authorization(accessToken);
GSuiteUser user = webClient.path(path).get(GSuiteUser.class);
return user;
}
示例4: updateUserPassword
import org.apache.cxf.jaxrs.client.WebClient; //导入方法依赖的package包/类
@Override
public void updateUserPassword(String userKey, String password) throws InvalidPasswordException {
String path = MessageFormat.format("users/{0}", new Object[]{userKey});
WebClient webClient = WebClient.fromClient(directoryApiClient, true);
ClientAccessToken accessToken = tokenCache.get();
webClient.authorization(accessToken);
GSuiteUser user = new GSuiteUser();
user.setPassword(password);
Response response = webClient.path(path).put(user);
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
throw new InvalidPasswordException("Can't change password. Response: " + response.readEntity(String.class));
}
}