public class RestClientImpl extends Object implements RestClient
HttpClient.| Constructor and Description |
|---|
RestClientImpl(org.apache.commons.httpclient.HttpClient client)
Constructor allowing the injection of an
org.apache.commons.httpclient.HttpClient. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configureHttpMethod(org.apache.commons.httpclient.HttpMethod m,
String hostAddr,
RestRequest request)
Configures the instance of HttpMethod with the data in the request and
the host address.
|
protected org.apache.commons.httpclient.HttpMethod |
createHttpClientMethod(RestRequest request)
Utility method that creates an instance of
org.apache.commons.httpclient.HttpMethod. |
protected org.apache.commons.httpclient.URI |
createUri(String uriString,
boolean escaped) |
RestResponse |
execute(RestRequest request)
|
RestResponse |
execute(String hostAddr,
RestRequest request)
|
String |
getBaseUrl()
|
org.apache.commons.httpclient.HttpClient |
getClient()
Returns the Http client instance used by this implementation.
|
String |
getContentType(RestRequest request) |
protected String |
getMethodClassnameFromMethodName(String mName)
factory method that maps a string with a HTTP method name to an
implementation class in Apache HttpClient.
|
void |
setBaseUrl(String bUrl)
|
public RestClientImpl(org.apache.commons.httpclient.HttpClient client)
org.apache.commons.httpclient.HttpClient.client - the client
See HttpClientpublic void setBaseUrl(String bUrl)
setBaseUrl in interface RestClientbUrl - a string with the base Url.
See RestClient.execute(RestRequest)public String getBaseUrl()
getBaseUrl in interface RestClientRestClient.setBaseUrl(String)public org.apache.commons.httpclient.HttpClient getClient()
HttpClient
See RestClientImpl(HttpClient)public RestResponse execute(RestRequest request)
execute in interface RestClientrequest - the request to be executedpublic RestResponse execute(String hostAddr, RestRequest request)
execute in interface RestClienthostAddr - the base Urlrequest - the request to be executedRestClient.setBaseUrl(java.lang.String)protected void configureHttpMethod(org.apache.commons.httpclient.HttpMethod m,
String hostAddr,
RestRequest request)
m - the method class to configurehostAddr - the host addressrequest - the rest requestpublic String getContentType(RestRequest request)
protected org.apache.commons.httpclient.URI createUri(String uriString, boolean escaped) throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIExceptionprotected String getMethodClassnameFromMethodName(String mName)
org.apache.commons.httpclient.methods.%sMethod where
%s is the parameter mName.mName - the method nameprotected org.apache.commons.httpclient.HttpMethod createHttpClientMethod(RestRequest request)
org.apache.commons.httpclient.HttpMethod.request - the rest requestorg.apache.commons.httpclient.HttpMethod
matching the method in RestRequest.Copyright © 2016 smartrics. All Rights Reserved.