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
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
Modifier and TypeFieldDescriptionstatic final int
static final int
protected static final String
protected static final int
protected org.apache.http.client.HttpClient
protected int
static final int
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
ConstructorDescriptionRestClientService
(RestClientContainer container, RemoteServiceClientRegistration registration) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
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
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
-
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:
-
DEFAULT_HTTP_CONTENT_CHARSET
- See Also:
-
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
-
createPostMethod
-
createPutMethod
-
createDeleteMethod
-
createPatchMethod
- Since:
- 2.6
-
createAndPrepareHttpMethod
protected org.apache.http.client.methods.HttpRequestBase createAndPrepareHttpMethod(AbstractClientService.UriRequest request) -
invokeRemoteCall
Calls the Rest service with given URL of IRestCall. The returned value is the response body as an InputStream.- Specified by:
invokeRemoteCall
in classAbstractClientService
- Parameters:
call
- The remote call to make. Must not benull
.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
- 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 -
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 -
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)
-