org.eclipse.ecf.remoteservice.rest
Class RestService

java.lang.Object
  extended by org.eclipse.ecf.remoteservice.rest.RestService
All Implemented Interfaces:
IRemoteService

public class RestService
extends java.lang.Object
implements 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.


Constructor Summary
RestService()
           
RestService(IRemoteServiceReference reference)
           
RestService(java.lang.Object proxy)
           
 
Method Summary
protected  void addGetParams(org.apache.commons.httpclient.HttpMethod httpMethod, java.lang.Object[] restParams)
           
protected  void addPostParams(org.apache.commons.httpclient.HttpMethod httpMethod, java.lang.Object[] restParams, org.apache.commons.httpclient.methods.RequestEntity requestEntity)
           
protected  void addPutRequestBody(IRestCall restCall, org.apache.commons.httpclient.HttpMethod httpMethod)
           
 org.eclipse.equinox.concurrent.future.IFuture callAsync(IRemoteCall call)
          Call remote method specified by call parameter asynchronously, and immediately return IFuture instance.
 void callAsync(IRemoteCall call, IRemoteCallListener listener)
          Call remote method specified by call parameter asynchronously, and notify specified listener when call starts and completes.
 org.eclipse.equinox.concurrent.future.IFuture callAsync(IRestCall call)
           
 void callAsync(IRestCall restCall, IRemoteCallListener listener)
           
 java.lang.Object callHttpMethod(IRestCall restCall)
          Calls the Rest service with given URL of IRestCall.
 java.lang.Object callSync(IRemoteCall call)
          Call remote method specified by call parameter synchronously.
 java.lang.Object callSync(IRestCall call)
           
protected  org.apache.commons.httpclient.HttpMethod createHttpMethod(IRestCall restCall, java.lang.String url)
           
 void fireAsync(IRemoteCall call)
          Fire remote method specified by call parameter.
 java.lang.Object getProxy()
          Get local proxy for remote interface.
protected  void handleAuthentication(org.apache.commons.httpclient.HttpClient httpClient, org.apache.commons.httpclient.HttpMethod method)
           
protected  void handleRequestHeaders(org.apache.commons.httpclient.HttpMethod httpMethod, java.util.Map requestHeaders)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestService

public RestService(IRemoteServiceReference reference)

RestService

public RestService(java.lang.Object proxy)

RestService

public RestService()
Method Detail

callAsync

public void callAsync(IRemoteCall call,
                      IRemoteCallListener listener)
Description copied from interface: IRemoteService
Call remote method specified by call parameter asynchronously, and notify specified listener when call starts and completes.

Specified by:
callAsync in interface IRemoteService
Parameters:
call - the remote call to make. Must not be null .
listener - the listener to notify when call starts and is completed. The listener will be notified via the two event types IRemoteCallStartEvent and IRemoteCallCompleteEvent. Must not be null .
See Also:
IRemoteCallStartEvent, IRemoteCallCompleteEvent

callAsync

public void callAsync(IRestCall restCall,
                      IRemoteCallListener listener)

callAsync

public org.eclipse.equinox.concurrent.future.IFuture callAsync(IRemoteCall call)
Description copied from interface: IRemoteService
Call remote method specified by call parameter asynchronously, and immediately return IFuture instance. Returned IFuture will not be null, and allows the caller to retrieve the actual resulting value from the remote call (or exception).

Specified by:
callAsync in interface IRemoteService
Parameters:
call - the remote call to make. Must not be null .
Returns:
IFuture the asynchronous result to allow the caller to poll for whether the result IFuture.isDone(), and then to IFuture.get() the actual result.

callAsync

public org.eclipse.equinox.concurrent.future.IFuture callAsync(IRestCall call)

callSync

public java.lang.Object callSync(IRemoteCall call)
                          throws ECFException
Description copied from interface: IRemoteService
Call remote method specified by call parameter synchronously.

Specified by:
callSync in interface IRemoteService
Parameters:
call - the remote call to make
Returns:
Object the result of the call. Will be null if remote provides null as result.
Throws:
ECFException - thrown if disconnect occurs, caller not currently connected, or remote throws Exception

callSync

public java.lang.Object callSync(IRestCall call)
                          throws ECFException
Throws:
ECFException

callHttpMethod

public java.lang.Object callHttpMethod(IRestCall restCall)
                                throws ECFException
Calls the Rest service with given URL of IRestCall. The returned value is the response body as an InputStream.

Parameters:
restCall - The Rest Service to call represented by an IRestCall object
Returns:
The InputStream of the response body or null if an error occurs.
Throws:
ECFException

handleRequestHeaders

protected void handleRequestHeaders(org.apache.commons.httpclient.HttpMethod httpMethod,
                                    java.util.Map requestHeaders)

createHttpMethod

protected org.apache.commons.httpclient.HttpMethod createHttpMethod(IRestCall restCall,
                                                                    java.lang.String url)
                                                             throws ECFException
Throws:
ECFException

addPutRequestBody

protected void addPutRequestBody(IRestCall restCall,
                                 org.apache.commons.httpclient.HttpMethod httpMethod)
                          throws ECFException
Throws:
ECFException

addPostParams

protected void addPostParams(org.apache.commons.httpclient.HttpMethod httpMethod,
                             java.lang.Object[] restParams,
                             org.apache.commons.httpclient.methods.RequestEntity requestEntity)

addGetParams

protected void addGetParams(org.apache.commons.httpclient.HttpMethod httpMethod,
                            java.lang.Object[] restParams)

handleAuthentication

protected void handleAuthentication(org.apache.commons.httpclient.HttpClient httpClient,
                                    org.apache.commons.httpclient.HttpMethod method)

getProxy

public java.lang.Object getProxy()
                          throws ECFException
Description copied from interface: IRemoteService
Get local proxy for remote interface. The local proxy may then be used to make remote method calls transparently by invoking the local proxy method

Specified by:
getProxy in interface IRemoteService
Returns:
Object that implements the interface specified in the IRemoteServiceReference instance used to retrieve the IRemoteService object. The result may then be cast to the appropriate type. The getProxy() contract guarantees that if a non-null Object is returned, that it will implement the interface specified for the IRemoteServiceReference. Will not be null .
Throws:
ECFException - if not currently connected to remote service

fireAsync

public void fireAsync(IRemoteCall call)
               throws ECFException
Description copied from interface: IRemoteService
Fire remote method specified by call parameter. The remote method will be invoked as a result of asynchronous message send, but no failure/exception information will be returned, and no result will be returned

Specified by:
fireAsync in interface IRemoteService
Parameters:
call - the remote call to make. Must not be null .
Throws:
ECFException - if caller not currently connected