當前位置: 首頁>>代碼示例>>Java>>正文


Java WebResource.Builder方法代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:XosManagerRestUtils.java

示例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);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:XosManagerRestUtils.java

示例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);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:XosManagerRestUtils.java

示例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);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:XosManagerRestUtils.java

示例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());
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:16,代碼來源:XosManagerRestUtils.java


注:本文中的com.sun.jersey.api.client.WebResource.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。