org.eclipse.ecf.remoteservice.rest.client
Class RestClientService

java.lang.Object
  extended by org.eclipse.ecf.remoteservice.asyncproxy.AbstractAsyncProxyRemoteService
      extended by org.eclipse.ecf.remoteservice.AbstractRemoteService
          extended by org.eclipse.ecf.remoteservice.client.AbstractClientService
              extended by org.eclipse.ecf.remoteservice.rest.client.AbstractRestClientService
                  extended by org.eclipse.ecf.remoteservice.rest.client.RestClientService
All Implemented Interfaces:
java.lang.reflect.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
static int connectRequestTimeout
           
static int connectTimeout
           
protected static java.lang.String DEFAULT_HTTP_CONTENT_CHARSET
           
protected static int DEFAULT_RESPONSE_BUFFER_SIZE
           
protected  org.apache.http.client.HttpClient httpClient
           
protected  int responseBufferSize
           
static 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
RestClientService(RestClientContainer container, RemoteServiceClientRegistration registration)
           
 
Method Summary
protected  void addRequestHeaders(org.apache.http.message.AbstractHttpMessage httpMethod, IRemoteCall call, IRemoteCallable callable)
           
protected  org.apache.http.client.methods.HttpRequestBase createAndPrepareHttpMethod(AbstractClientService.UriRequest request)
           
protected  org.apache.http.client.methods.HttpRequestBase createAndPrepareHttpMethod(java.lang.String uri, IRemoteCall call, IRemoteCallable callable)
           
protected  org.apache.http.client.methods.HttpDelete createDeleteMethod(java.lang.String uri)
           
protected  org.apache.http.client.methods.HttpGet createGetMethod(java.lang.String uri)
           
protected  org.apache.http.client.HttpClient createHttpClient()
           
protected  org.apache.http.client.methods.HttpPatch createPatchMethod(java.lang.String uri)
           
protected  org.apache.http.client.methods.HttpPost createPostMethod(java.lang.String uri)
           
protected  org.apache.http.client.methods.HttpPut createPutMethod(java.lang.String uri)
           
protected  byte[] getResponseAsBytes(org.apache.http.HttpResponse response)
           
protected  org.apache.http.client.entity.UrlEncodedFormEntity getUrlEncodedFormEntity(java.util.List list, AbstractEntityRequestType postRequestType)
           
protected  java.lang.Object invokeRemoteCall(IRemoteCall call, IRemoteCallable callable)
          Calls the Rest service with given URL of IRestCall.
protected  org.apache.http.client.methods.HttpRequestBase prepareDeleteMethod(java.lang.String uri, IRemoteCall call, IRemoteCallable callable)
           
protected  org.apache.http.client.methods.HttpRequestBase prepareGetMethod(java.lang.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(java.lang.String uri, IRemoteCall call, IRemoteCallable callable)
           
protected  org.apache.http.client.methods.HttpRequestBase preparePostMethod(java.lang.String uri, IRemoteCall call, IRemoteCallable callable)
           
protected  org.apache.http.client.methods.HttpRequestBase preparePutMethod(java.lang.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(java.lang.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, callAsyncWithResult, callCompletableAsync, callFutureAsync, callFutureAsync, convertInterfaceNameToAsyncInterfaceName, createProxy, createProxy, createRemoteCall, dispose, findAsyncRemoteServiceProxyClass, findAsyncRemoteServiceProxyClass, getAsyncArgs, getAsyncInvokeMethodName, getAsyncRemoteCall, getCallTimeoutForProxyInvoke, getDefaultTimeout, getFutureExecutorService, getIFutureExecutor, getProxy, getProxy, getRemoteService, getRemoteServiceProxyCreator, handleInvokeSyncException, handleProxyException, invoke, invokeAsync, invokeObject, isAsync, loadInterfaceClass, loadInterfaceClass, setFutureExecutorService, setIFutureExecutor
 
Methods inherited from class org.eclipse.ecf.remoteservice.asyncproxy.AbstractAsyncProxyRemoteService
callFuture
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 java.lang.String DEFAULT_HTTP_CONTENT_CHARSET
See Also:
Constant Field Values

httpClient

protected org.apache.http.client.HttpClient httpClient

responseBufferSize

protected int responseBufferSize
Constructor Detail

RestClientService

public RestClientService(RestClientContainer container,
                         RemoteServiceClientRegistration registration)
Method Detail

createHttpClient

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

createGetMethod

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

createPostMethod

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

createPutMethod

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

createDeleteMethod

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

createPatchMethod

protected org.apache.http.client.methods.HttpPatch createPatchMethod(java.lang.String uri)
Since:
2.6

createAndPrepareHttpMethod

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

invokeRemoteCall

protected java.lang.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 java.io.IOException
Throws:
java.io.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(java.lang.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(java.lang.String uri,
                                                                             IRemoteCall call,
                                                                             IRemoteCallable callable)
                                                                      throws RestException
Throws:
RestException

preparePutMethod

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

preparePatchMethod

protected org.apache.http.client.methods.HttpRequestBase preparePatchMethod(java.lang.String uri,
                                                                            IRemoteCall call,
                                                                            IRemoteCallable callable)
                                                                     throws java.io.NotSerializableException,
                                                                            java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException
ECFException
java.io.NotSerializableException
Since:
2.6

preparePostMethod

protected org.apache.http.client.methods.HttpRequestBase preparePostMethod(java.lang.String uri,
                                                                           IRemoteCall call,
                                                                           IRemoteCallable callable)
                                                                    throws java.io.NotSerializableException,
                                                                           java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException
ECFException
java.io.NotSerializableException

prepareGetMethod

protected org.apache.http.client.methods.HttpRequestBase prepareGetMethod(java.lang.String uri,
                                                                          IRemoteCall call,
                                                                          IRemoteCallable callable)
                                                                   throws java.io.NotSerializableException
Throws:
java.io.NotSerializableException
ECFException

getUrlEncodedFormEntity

protected org.apache.http.client.entity.UrlEncodedFormEntity getUrlEncodedFormEntity(java.util.List list,
                                                                                     AbstractEntityRequestType postRequestType)
                                                                              throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

toNameValuePairs

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

setupAuthenticaton

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