本文整理汇总了Java中com.sun.jersey.api.client.WebResource.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java WebResource.Builder方法的具体用法?Java WebResource.Builder怎么用?Java WebResource.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.api.client.WebResource
的用法示例。
在下文中一共展示了WebResource.Builder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postRest
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
* Performs a REST POST operation of a json string on the base
* XOS REST URI with an optional additional URI suffix.
*
* @param uri URI suffix to append to base URI
* @param json JSON string to post
*/
public void postRest(String uri, String json) {
WebResource.Builder builder = getClientBuilder(uri);
ClientResponse response;
try {
response = builder.post(ClientResponse.class, json);
} catch (ClientHandlerException e) {
log.warn("Unable to contact REST server: {}", e.getMessage());
return;
}
if (response.getStatus() != HTTP_CREATED) {
log.info("REST POST request returned error code {}",
response.getStatus());
}
}
示例2: putRest
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
* Performs a REST PUT operation on the base XOS REST URI with
* an optional additional URI.
*
* @param uri URI suffix to append to base URI
* @return JSON string returned by the PUT operation
*/
public String putRest(String uri) {
WebResource.Builder builder = getClientBuilder(uri);
ClientResponse response;
try {
response = builder.put(ClientResponse.class);
} catch (ClientHandlerException e) {
log.warn("Unable to contact REST server: {}", e.getMessage());
return "";
}
if (response.getStatus() != HTTP_OK) {
log.info("REST PUT request returned error code {}",
response.getStatus());
}
return response.getEntity(String.class);
}
示例3: getClientBuilder
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
* Gets a client web resource builder for the base XOS REST API
* with an optional additional URI.
*
* @param uri URI suffix to append to base URI
* @return web resource builder
*/
public WebResource.Builder getClientBuilder(String uri) {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter(AUTH_USER, AUTH_PASS));
WebResource resource = client.resource(baseUrl() + uri);
log.info("XOS REST CALL>> {}", resource);
return resource.accept(UTF_8).type(UTF_8);
}
示例4: getRest
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
* Performs a REST GET operation on the base XOS REST URI with
* an optional additional URI.
*
* @param uri URI suffix to append to base URI
* @return JSON string fetched by the GET operation
*/
public String getRest(String uri) {
WebResource.Builder builder = getClientBuilder(uri);
ClientResponse response = builder.get(ClientResponse.class);
if (response.getStatus() != HTTP_OK) {
log.info("REST GET request returned error code {}",
response.getStatus());
}
return response.getEntity(String.class);
}
示例5: deleteRest
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
* Performs a REST DELETE operation on the base
* XOS REST URI with an optional additional URI.
*
* @param uri URI suffix to append to base URI
*/
public void deleteRest(String uri) {
WebResource.Builder builder = getClientBuilder(uri);
ClientResponse response = builder.delete(ClientResponse.class);
if (response.getStatus() != HTTP_NO_CONTENT) {
log.info("REST DELETE request returned error code {}",
response.getStatus());
}
}