org.eclipse.ecf.remoteservice
Class RemoteServiceHelper

java.lang.Object
  extended by org.eclipse.ecf.remoteservice.RemoteServiceHelper

public class RemoteServiceHelper
extends java.lang.Object

Helper class for making it easier to call a remote service with method name and optional parameters.

Since:
3.0

Field Summary
static long defaultTimeout
           
static java.lang.Object[] EMPTY_PARAMS
           
 
Constructor Summary
RemoteServiceHelper()
           
 
Method Summary
static void asyncExec(IRemoteService remoteService, java.lang.String method, java.lang.Object[] parameters, IRemoteCallListener listener)
          Invoke given method asynchronously, and call listener upon successful completion.
static void asyncExec(IRemoteService remoteService, java.lang.String method, java.lang.Object[] parameters, long timeout, IRemoteCallListener listener)
          Invoke given method asynchronously, and call listener upon successful completion.
static org.eclipse.equinox.concurrent.future.IFuture futureExec(IRemoteService remoteService, java.lang.String method, java.lang.Object[] parameters)
          Invoke given method asynchronously, return an IFuture immediately that can be subsequently queried for completion.
static org.eclipse.equinox.concurrent.future.IFuture futureExec(IRemoteService remoteService, java.lang.String method, java.lang.Object[] parameters, long timeout)
          Invoke given method asynchronously, return an IFuture immediately that can be subsequently queried for completion.
static long getDefaultTimeout()
           
static void setDefaultTimeout(long timeout)
           
static java.lang.Object syncExec(IRemoteService remoteService, java.lang.String method, java.lang.Object[] parameters)
          Invoke given method synchronously, blocking the calling thread until a result is received or timeout.
static java.lang.Object syncExec(IRemoteService remoteService, java.lang.String method, java.lang.Object[] parameters, long timeout)
          Invoke given method synchronously, blocking the calling thread until a result is received or timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultTimeout

public static long defaultTimeout

EMPTY_PARAMS

public static java.lang.Object[] EMPTY_PARAMS
Constructor Detail

RemoteServiceHelper

public RemoteServiceHelper()
Method Detail

getDefaultTimeout

public static long getDefaultTimeout()

setDefaultTimeout

public static void setDefaultTimeout(long timeout)

asyncExec

public static void asyncExec(IRemoteService remoteService,
                             java.lang.String method,
                             java.lang.Object[] parameters,
                             IRemoteCallListener listener)
Invoke given method asynchronously, and call listener upon successful completion. Uses default timeout.

Parameters:
remoteService - the IRemoteService to invoke. Must not be null.
method - the method to invoke. Must not be null.
parameters - the parameters associated with the method to invoke. May be null (no parameters).
listener - the listener to call back when remote call initiated and completed. Must not be null.

asyncExec

public static void asyncExec(IRemoteService remoteService,
                             java.lang.String method,
                             java.lang.Object[] parameters,
                             long timeout,
                             IRemoteCallListener listener)
Invoke given method asynchronously, and call listener upon successful completion.

Parameters:
remoteService - the IRemoteService to invoke. Must not be null.
method - the method to invoke. Must not be null.
parameters - the parameters associated with the method to invoke. May be null (no parameters).
timeout - the timeout (in ms) for the remote call.
listener - the listener to call back when remote call initiated and completed. Must not be null.

futureExec

public static org.eclipse.equinox.concurrent.future.IFuture futureExec(IRemoteService remoteService,
                                                                       java.lang.String method,
                                                                       java.lang.Object[] parameters,
                                                                       long timeout)
Invoke given method asynchronously, return an IFuture immediately that can be subsequently queried for completion.

Parameters:
remoteService - the IRemoteService to invoke. Must not be null.
method - the method to invoke. Must not be null.
parameters - the parameters associated with the method to invoke. May be null (no parameters).
timeout - the timeout (in ms) for the remote call.

futureExec

public static org.eclipse.equinox.concurrent.future.IFuture futureExec(IRemoteService remoteService,
                                                                       java.lang.String method,
                                                                       java.lang.Object[] parameters)
Invoke given method asynchronously, return an IFuture immediately that can be subsequently queried for completion. Uses default timeout.

Parameters:
remoteService - the IRemoteService to invoke. Must not be null.
method - the method to invoke. Must not be null.
parameters - the parameters associated with the method to invoke. May be null (no parameters).

syncExec

public static java.lang.Object syncExec(IRemoteService remoteService,
                                        java.lang.String method,
                                        java.lang.Object[] parameters,
                                        long timeout)
                                 throws ECFException
Invoke given method synchronously, blocking the calling thread until a result is received or timeout.

Parameters:
remoteService - the IRemoteService to invoke. Must not be null.
method - the method to invoke. Must not be null.
parameters - the parameters associated with the method to invoke. May be null (no parameters).
timeout - the timeout (in ms) for the remote call.
Throws:
ECFException

syncExec

public static java.lang.Object syncExec(IRemoteService remoteService,
                                        java.lang.String method,
                                        java.lang.Object[] parameters)
                                 throws ECFException
Invoke given method synchronously, blocking the calling thread until a result is received or timeout. Uses default timeout.

Parameters:
remoteService - the IRemoteService to invoke. Must not be null.
method - the method to invoke. Must not be null.
parameters - the parameters associated with the method to invoke. May be null (no parameters).
Throws:
ECFException