public class HttpContext extends Object
Constructor and Description |
---|
HttpContext(javax.ws.rs.client.Client client,
String protocol,
String hostname,
int port)
Constructor that takes a client, protocol, hostname and port.
|
Modifier and Type | Method and Description |
---|---|
void |
DELETE(String partialUrl)
Execute a DELETE call against the partial URL.
|
void |
DELETE(String partialUrl,
Map<String,Object> headers,
List<String> queryParams)
Execute a DELETE call against the partial URL.
|
protected void |
executeDeleteRequest(URI uri)
Execute a DELETE request.
|
protected void |
executeDeleteRequest(URI uri,
Map<String,Object> headers,
List<String> queryParams)
Execute a DELETE request.
|
protected <T> com.google.common.base.Optional<T> |
executeGetRequest(URI uri,
javax.ws.rs.core.GenericType<T> returnType)
Execute a GET request and return the result.
|
protected <T> com.google.common.base.Optional<T> |
executeGetRequest(URI uri,
Map<String,Object> headers,
List<String> queryParams,
javax.ws.rs.core.GenericType<T> returnType)
Execute a GET request and return the result.
|
protected void |
executePatchRequest(URI uri,
Object obj)
Execute a PATCH request.
|
protected void |
executePatchRequest(URI uri,
Object obj,
Map<String,Object> headers,
List<String> queryParams)
Execute a PATCH request.
|
protected <T> com.google.common.base.Optional<T> |
executePatchRequest(URI uri,
Object obj,
Map<String,Object> headers,
List<String> queryParams,
javax.ws.rs.core.GenericType<T> returnType)
Execute a PATCH request with a return object.
|
protected com.google.common.base.Optional<javax.ws.rs.core.Response> |
executePostRequest(URI uri,
Object obj)
Execute a POST request.
|
protected <T> com.google.common.base.Optional<T> |
executePostRequest(URI uri,
Object obj,
javax.ws.rs.core.GenericType<T> returnType)
Execute a POST request with a return object.
|
protected com.google.common.base.Optional<javax.ws.rs.core.Response> |
executePostRequest(URI uri,
Object obj,
Map<String,Object> headers)
Execute a POST request.
|
protected <T> com.google.common.base.Optional<T> |
executePostRequest(URI uri,
Object obj,
Map<String,Object> headers,
javax.ws.rs.core.GenericType<T> returnType)
Execute a POST request with a return object.
|
protected void |
executePutRequest(URI uri,
Object obj)
Execute a PUT request.
|
protected void |
executePutRequest(URI uri,
Object obj,
Map<String,Object> headers,
List<String> queryParams)
Execute a PUT request.
|
protected <T> com.google.common.base.Optional<T> |
executePutRequest(URI uri,
Object obj,
Map<String,Object> headers,
List<String> queryParams,
javax.ws.rs.core.GenericType<T> returnType)
Execute a PUT request with a return object.
|
<T> com.google.common.base.Optional<T> |
GET(String partialUrl,
javax.ws.rs.core.GenericType<T> returnType)
Execute a GET call against the partial URL and deserialize the results.
|
<T> com.google.common.base.Optional<T> |
GET(String partialUrl,
Map<String,Object> headers,
List<String> queryParams,
javax.ws.rs.core.GenericType<T> returnType)
Execute a GET call against the partial URL and deserialize the results.
|
String |
getUriPrefix()
Returns the uri prefix for resources used by the client.
|
void |
PATCH(String partialUrl,
Object payload)
Execute a PATCH call against the partial URL.
|
<T> com.google.common.base.Optional<T> |
PATCH(String partialUrl,
Object payload,
javax.ws.rs.core.GenericType<T> returnType)
Execute a PATCH call against the partial URL.
|
void |
PATCH(String partialUrl,
Object payload,
Map<String,Object> headers,
List<String> queryParams)
Execute a PATCH call against the partial URL.
|
<T> com.google.common.base.Optional<T> |
PATCH(String partialUrl,
Object payload,
Map<String,Object> headers,
List<String> queryParams,
javax.ws.rs.core.GenericType<T> returnType)
Execute a PATCH call against the partial URL.
|
com.google.common.base.Optional<javax.ws.rs.core.Response> |
POST(String partialUrl,
Object payload)
Execute a POST call against the partial URL.
|
<T> com.google.common.base.Optional<T> |
POST(String partialUrl,
Object payload,
javax.ws.rs.core.GenericType<T> returnType)
Execute a POST call against the partial URL.
|
com.google.common.base.Optional<javax.ws.rs.core.Response> |
POST(String partialUrl,
Object payload,
Map<String,Object> headers)
Execute a POST call against the partial URL.
|
<T> com.google.common.base.Optional<T> |
POST(String partialUrl,
Object payload,
Map<String,Object> headers,
javax.ws.rs.core.GenericType<T> returnType)
Execute a POST call against the partial URL.
|
void |
PUT(String partialUrl,
Object payload)
Execute a PUT call against the partial URL.
|
<T> com.google.common.base.Optional<T> |
PUT(String partialUrl,
Object payload,
javax.ws.rs.core.GenericType<T> returnType)
Execute a PUT call against the partial URL.
|
void |
PUT(String partialUrl,
Object payload,
Map<String,Object> headers,
List<String> queryParams)
Execute a PUT call against the partial URL.
|
<T> com.google.common.base.Optional<T> |
PUT(String partialUrl,
Object payload,
Map<String,Object> headers,
List<String> queryParams,
javax.ws.rs.core.GenericType<T> returnType)
Execute a PUT call against the partial URL.
|
void |
setThrowExceptions(boolean throwExceptions)
Set to
true if an exception should be thrown on an error HTTP response. |
void |
setUriPrefix(String uriPrefix)
Sets the uri prefix for resources used by the client.
|
boolean |
throwExceptions()
Returns
true if an exception should be thrown on an error HTTP response. |
public HttpContext(javax.ws.rs.client.Client client, String protocol, String hostname, int port)
client
- The Jersey clientprotocol
- The protocol used to connect to the serverhostname
- The hostname of the serverport
- The port of the serverpublic <T> com.google.common.base.Optional<T> GET(String partialUrl, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildreturnType
- The expected return typepublic <T> com.google.common.base.Optional<T> GET(String partialUrl, Map<String,Object> headers, List<String> queryParams, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildreturnType
- The expected return typeheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestpublic void PUT(String partialUrl, Object payload)
partialUrl
- The partial URL to buildpayload
- The object to use for the PUTpublic void PUT(String partialUrl, Object payload, Map<String,Object> headers, List<String> queryParams)
partialUrl
- The partial URL to buildpayload
- The object to use for the PUTheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestpublic <T> com.google.common.base.Optional<T> PUT(String partialUrl, Object payload, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildpayload
- The object to use for the PUTreturnType
- The expected return typepublic <T> com.google.common.base.Optional<T> PUT(String partialUrl, Object payload, Map<String,Object> headers, List<String> queryParams, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildpayload
- The object to use for the PUTheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestreturnType
- The expected return typepublic com.google.common.base.Optional<javax.ws.rs.core.Response> POST(String partialUrl, Object payload)
partialUrl
- The partial URL to buildpayload
- The object to use for the POSTpublic com.google.common.base.Optional<javax.ws.rs.core.Response> POST(String partialUrl, Object payload, Map<String,Object> headers)
partialUrl
- The partial URL to buildpayload
- The object to use for the POSTheaders
- A set of headers to add to the requestpublic <T> com.google.common.base.Optional<T> POST(String partialUrl, Object payload, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildpayload
- The object to use for the POSTreturnType
- The expected return typepublic <T> com.google.common.base.Optional<T> POST(String partialUrl, Object payload, Map<String,Object> headers, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildpayload
- The object to use for the POSTheaders
- A set of headers to add to the requestreturnType
- The expected return typepublic void PATCH(String partialUrl, Object payload)
partialUrl
- The partial URL to buildpayload
- The object to use for the PATCHpublic void PATCH(String partialUrl, Object payload, Map<String,Object> headers, List<String> queryParams)
partialUrl
- The partial URL to buildpayload
- The object to use for the PATCHheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestpublic <T> com.google.common.base.Optional<T> PATCH(String partialUrl, Object payload, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildpayload
- The object to use for the PATCHreturnType
- The expected return typepublic <T> com.google.common.base.Optional<T> PATCH(String partialUrl, Object payload, Map<String,Object> headers, List<String> queryParams, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objectpartialUrl
- The partial URL to buildpayload
- The object to use for the PATCHheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestreturnType
- The expected return typepublic void DELETE(String partialUrl)
partialUrl
- The partial URL to buildpublic void DELETE(String partialUrl, Map<String,Object> headers, List<String> queryParams)
partialUrl
- The partial URL to buildheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestprotected <T> com.google.common.base.Optional<T> executeGetRequest(URI uri, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objecturi
- The URI to callreturnType
- The type to marshall the result back intoprotected <T> com.google.common.base.Optional<T> executeGetRequest(URI uri, Map<String,Object> headers, List<String> queryParams, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objecturi
- The URI to callreturnType
- The type to marshall the result back intoheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestprotected void executePutRequest(URI uri, Object obj)
uri
- The URI to callobj
- The object to use for the PUTprotected void executePutRequest(URI uri, Object obj, Map<String,Object> headers, List<String> queryParams)
uri
- The URI to callobj
- The object to use for the PUTheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestprotected <T> com.google.common.base.Optional<T> executePutRequest(URI uri, Object obj, Map<String,Object> headers, List<String> queryParams, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objecturi
- The URI to callobj
- The object to use for the PUTheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestreturnType
- The type to marshall the result back intoprotected com.google.common.base.Optional<javax.ws.rs.core.Response> executePostRequest(URI uri, Object obj)
uri
- The URI to callobj
- The object to use for the POSTprotected com.google.common.base.Optional<javax.ws.rs.core.Response> executePostRequest(URI uri, Object obj, Map<String,Object> headers)
uri
- The URI to callobj
- The object to use for the POSTheaders
- A set of headers to add to the requestprotected <T> com.google.common.base.Optional<T> executePostRequest(URI uri, Object obj, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objecturi
- The URI to callobj
- The object to use for the POSTreturnType
- The type to marshall the result back intoprotected <T> com.google.common.base.Optional<T> executePostRequest(URI uri, Object obj, Map<String,Object> headers, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objecturi
- The URI to callobj
- The object to use for the POSTheaders
- A set of headers to add to the requestreturnType
- The type to marshall the result back intoprotected void executePatchRequest(URI uri, Object obj)
uri
- The URI to callobj
- The object to use for the PATCHprotected void executePatchRequest(URI uri, Object obj, Map<String,Object> headers, List<String> queryParams)
uri
- The URI to callobj
- The object to use for the PATCHheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestprotected <T> com.google.common.base.Optional<T> executePatchRequest(URI uri, Object obj, Map<String,Object> headers, List<String> queryParams, javax.ws.rs.core.GenericType<T> returnType)
T
- The type parameter used for the return objecturi
- The URI to callobj
- The object to use for the PATCHheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestreturnType
- The type to marshall the result back intoprotected void executeDeleteRequest(URI uri)
uri
- The URI to callprotected void executeDeleteRequest(URI uri, Map<String,Object> headers, List<String> queryParams)
uri
- The URI to callheaders
- A set of headers to add to the requestqueryParams
- A set of query parameters to add to the requestpublic void setThrowExceptions(boolean throwExceptions)
true
if an exception should be thrown on an error HTTP response.throwExceptions
- true
if an exception should be thrown on an error HTTP responsepublic boolean throwExceptions()
true
if an exception should be thrown on an error HTTP response.true
if an exception should be thrown on an error HTTP responsepublic void setUriPrefix(String uriPrefix)
uriPrefix
- The uri prefix for the clientpublic String getUriPrefix()
Copyright © 2018. All rights reserved.