Package org.eclipse.ecf.remoteservice.rest.client

# Class RestClientService

java.lang.Object
org.eclipse.ecf.remoteservice.asyncproxy.AbstractAsyncProxyRemoteService
org.eclipse.ecf.remoteservice.AbstractRemoteService
org.eclipse.ecf.remoteservice.client.AbstractClientService
org.eclipse.ecf.remoteservice.rest.client.AbstractRestClientService
org.eclipse.ecf.remoteservice.rest.client.RestClientService

All Implemented Interfaces:
  `InvocationHandler`, `IRemoteService`

public class RestClientService extends AbstractRestClientService
This class represents a REST service from the client side of view. So a RESTful web service can be accessed via the methods provided by this class. Mostly the methods are inherited from `IRemoteService`.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.eclipse.ecf.remoteservice.client.AbstractClientService

`AbstractClientService.AsyncResult, AbstractClientService.UriRequest`

## Nested classes/interfaces inherited from class org.eclipse.ecf.remoteservice.AbstractRemoteService

`AbstractRemoteService.AsyncArgs, AbstractRemoteService.ProxyClassLoader`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`connectRequestTimeout`
`static final int`
`connectTimeout`
`protected static final String`
`DEFAULT_HTTP_CONTENT_CHARSET`
`protected static final int`
`DEFAULT_RESPONSE_BUFFER_SIZE`
`protected org.apache.http.client.HttpClient`
`httpClient`
`protected int`
`responseBufferSize`
`static final int`
`socketTimeout`

### Fields inherited from class org.eclipse.ecf.remoteservice.client.AbstractClientService

`container, registration`

### Fields inherited from class org.eclipse.ecf.remoteservice.AbstractRemoteService

`EMPTY_ARGS, futureExecutorService, futureExecutorServiceMaxThreads, iFutureExecutor`

## Constructor Summary

Constructors
Constructor
Description
`RestClientService(RestClientContainer container, RemoteServiceClientRegistration registration)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addRequestHeaders(org.apache.http.message.AbstractHttpMessage httpMethod, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.client.methods.HttpRequestBase`
`createAndPrepareHttpMethod(String uri, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.client.methods.HttpRequestBase`
`createAndPrepareHttpMethod(AbstractClientService.UriRequest request)`
`protected org.apache.http.client.methods.HttpDelete`
`createDeleteMethod(String uri)`
`protected org.apache.http.client.methods.HttpGet`
`createGetMethod(String uri)`
`protected org.apache.http.client.HttpClient`
`createHttpClient()`
`protected org.apache.http.client.methods.HttpPatch`
`createPatchMethod(String uri)`
`protected org.apache.http.client.methods.HttpPost`
`createPostMethod(String uri)`
`protected org.apache.http.client.methods.HttpPut`
`createPutMethod(String uri)`
`protected byte[]`
`getResponseAsBytes(org.apache.http.HttpResponse response)`
`protected org.apache.http.client.entity.UrlEncodedFormEntity`
`getUrlEncodedFormEntity(List list, AbstractEntityRequestType postRequestType)`
`protected Object`
`invokeRemoteCall(IRemoteCall call, IRemoteCallable callable)`
Calls the Rest service with given URL of IRestCall.
`protected org.apache.http.client.methods.HttpRequestBase`
`prepareDeleteMethod(String uri, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.client.methods.HttpRequestBase`
`prepareGetMethod(String uri, IRemoteCall call, IRemoteCallable callable)`
`protected void`
`prepareHttpMethod(org.apache.http.client.methods.HttpRequestBase httpMethod, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.client.methods.HttpRequestBase`
`preparePatchMethod(String uri, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.client.methods.HttpRequestBase`
`preparePostMethod(String uri, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.client.methods.HttpRequestBase`
`preparePutMethod(String uri, IRemoteCall call, IRemoteCallable callable)`
`protected boolean`
`retrieveErrorResponseBody(org.apache.http.HttpResponse response)`
`protected void`
`setupAuthenticaton(org.apache.http.client.HttpClient httpClient, org.apache.http.client.methods.HttpRequestBase method)`
`protected void`
`setupHttpMethod(org.apache.http.client.methods.HttpRequestBase httpMethod, IRemoteCall call, IRemoteCallable callable)`
`protected void`
`setupTimeouts(org.apache.http.client.HttpClient httpClient, IRemoteCall call, IRemoteCallable callable)`
`protected org.apache.http.NameValuePair[]`
`toNameValuePairs(String uri, IRemoteCall call, IRemoteCallable callable)`

### Methods inherited from class org.eclipse.ecf.remoteservice.rest.client.AbstractRestClientService

`handleException, handleException, logException, logWarning, trace`

### Methods inherited from class org.eclipse.ecf.remoteservice.client.AbstractClientService

`callAsync, callAsync, callAsync, callAsync, callSync, createUriRequest, fireAsync, getCallMethodNameForProxyInvoke, getCallParametersForProxyInvoke, getClientContainer, getInterfaceClassNames, getNextRequestID, getRegistration, getRemoteServiceID, getRemoteServiceReference, handleInvokeException, invokeSync, prepareEndpointAddress, prepareParameters, processResponse`

### Methods inherited from class org.eclipse.ecf.remoteservice.AbstractRemoteService

`addAsyncProxyClasses, addRemoteServiceProxyToProxy, callAsync, callAsync, callAsyncWithResult, callAsyncWithTimeout, callAsyncWithTimeout, callCompletableAsync, callFutureAsync, callFutureAsync, callSync, convertInterfaceNameToAsyncInterfaceName, createProxy, createProxy, createRCCE, createRCCEFailure, createRCCESuccess, createRemoteCall, dispose, findAsyncRemoteServiceProxyClass, findAsyncRemoteServiceProxyClass, getAsyncArgs, getAsyncInvokeMethodName, getAsyncRemoteCall, getCallTimeoutForProxyInvoke, getDefaultTimeout, getFutureExecutorService, getIFutureExecutor, getProxy, getProxy, getRemoteService, getRemoteServiceProxyCreator, handleInvokeSyncException, handleProxyException, invoke, invokeAsync, invokeObject, invokeReturnAsync, isAsync, isInterfaceAsync, isMethodAsync, isOSGIAsync, loadInterfaceClass, loadInterfaceClass, setFutureExecutorService, setIFutureExecutor`

### Methods inherited from class org.eclipse.ecf.remoteservice.asyncproxy.AbstractAsyncProxyRemoteService

`callFuture, isReturnAsync`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### socketTimeout

public static final int socketTimeout

### connectRequestTimeout

public static final int connectRequestTimeout

### connectTimeout

public static final int connectTimeout

### DEFAULT_RESPONSE_BUFFER_SIZE

protected static final int DEFAULT_RESPONSE_BUFFER_SIZE

See Also:
  - Constant Field Values

### DEFAULT_HTTP_CONTENT_CHARSET

protected static final String DEFAULT_HTTP_CONTENT_CHARSET

See Also:
  - Constant Field Values

### httpClient

protected org.apache.http.client.HttpClient httpClient

### responseBufferSize

protected int responseBufferSize

## Constructor Details

### RestClientService

public RestClientService(RestClientContainer container, RemoteServiceClientRegistration registration)

## Method Details

### createHttpClient

protected org.apache.http.client.HttpClient createHttpClient()

### createGetMethod

protected org.apache.http.client.methods.HttpGet createGetMethod(String uri)

### createPostMethod

protected org.apache.http.client.methods.HttpPost createPostMethod(String uri)

### createPutMethod

protected org.apache.http.client.methods.HttpPut createPutMethod(String uri)

### createDeleteMethod

protected org.apache.http.client.methods.HttpDelete createDeleteMethod(String uri)

### createPatchMethod

protected org.apache.http.client.methods.HttpPatch createPatchMethod(String uri)

Since:
  2.6

### createAndPrepareHttpMethod

protected org.apache.http.client.methods.HttpRequestBase createAndPrepareHttpMethod(AbstractClientService.UriRequest request)

### invokeRemoteCall

protected Object invokeRemoteCall(IRemoteCall call, IRemoteCallable callable) throws ECFException
Calls the Rest service with given URL of IRestCall. The returned value is the response body as an InputStream.

Specified by:
  `invokeRemoteCall` in class `AbstractClientService`
Parameters:
  `call` - The remote call to make. Must not be `null`.
  `callable` - The callable with default parameters to use to make the call.
Returns:
  The InputStream of the response body or `null` if an error occurs.
Throws:
  `ECFException` - thrown if the call fails.

### retrieveErrorResponseBody

protected boolean retrieveErrorResponseBody(org.apache.http.HttpResponse response)

### getResponseAsBytes

protected byte[] getResponseAsBytes(org.apache.http.HttpResponse response) throws IOException

Throws:
  `IOException`

### setupTimeouts

protected void setupTimeouts(org.apache.http.client.HttpClient httpClient, IRemoteCall call, IRemoteCallable callable)

### addRequestHeaders

protected void addRequestHeaders(org.apache.http.message.AbstractHttpMessage httpMethod, IRemoteCall call, IRemoteCallable callable)

### createAndPrepareHttpMethod

protected org.apache.http.client.methods.HttpRequestBase createAndPrepareHttpMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws RestException

Throws:
  `RestException`

### prepareHttpMethod

protected void prepareHttpMethod(org.apache.http.client.methods.HttpRequestBase httpMethod, IRemoteCall call, IRemoteCallable callable)

### setupHttpMethod

protected void setupHttpMethod(org.apache.http.client.methods.HttpRequestBase httpMethod, IRemoteCall call, IRemoteCallable callable)

### prepareDeleteMethod

protected org.apache.http.client.methods.HttpRequestBase prepareDeleteMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws RestException

Throws:
  `RestException`

### preparePutMethod

protected org.apache.http.client.methods.HttpRequestBase preparePutMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws NotSerializableException, UnsupportedEncodingException

Throws:
  `NotSerializableException`
  `UnsupportedEncodingException`

### preparePatchMethod

protected org.apache.http.client.methods.HttpRequestBase preparePatchMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws NotSerializableException, UnsupportedEncodingException

Throws:
  `UnsupportedEncodingException`
  `ECFException`
  `NotSerializableException`
Since:
  2.6

### preparePostMethod

protected org.apache.http.client.methods.HttpRequestBase preparePostMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws NotSerializableException, UnsupportedEncodingException

Throws:
  `UnsupportedEncodingException`
  `ECFException`
  `NotSerializableException`

### prepareGetMethod

protected org.apache.http.client.methods.HttpRequestBase prepareGetMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws NotSerializableException

Throws:
  `NotSerializableException`
  `ECFException`

### getUrlEncodedFormEntity

protected org.apache.http.client.entity.UrlEncodedFormEntity getUrlEncodedFormEntity(List list, AbstractEntityRequestType postRequestType) throws UnsupportedEncodingException

Throws:
  `UnsupportedEncodingException`

### toNameValuePairs

protected org.apache.http.NameValuePair[] toNameValuePairs(String uri, IRemoteCall call, IRemoteCallable callable) throws NotSerializableException

Throws:
  `NotSerializableException`

### setupAuthenticaton

protected void setupAuthenticaton(org.apache.http.client.HttpClient httpClient, org.apache.http.client.methods.HttpRequestBase method)