Package org.eclipse.ecf.remoteservice
Class AbstractRemoteService
- java.lang.Object
-
- org.eclipse.ecf.remoteservice.asyncproxy.AbstractAsyncProxyRemoteService
-
- org.eclipse.ecf.remoteservice.AbstractRemoteService
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler,IRemoteService
- Direct Known Subclasses:
AbstractClientService,RemoteServiceImpl
public abstract class AbstractRemoteService extends AbstractAsyncProxyRemoteService implements IRemoteService, java.lang.reflect.InvocationHandler
Abstract remote service implementation. Clients may subclass to avoid re-implementing methods from IRemoteService.- Since:
- 4.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractRemoteService.AsyncArgsclassAbstractRemoteService.ProxyClassLoader
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.Object[]EMPTY_ARGSprotected java.util.concurrent.ExecutorServicefutureExecutorServiceprotected intfutureExecutorServiceMaxThreadsprotected org.eclipse.equinox.concurrent.future.IExecutoriFutureExecutor
-
Constructor Summary
Constructors Constructor Description AbstractRemoteService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.util.ListaddAsyncProxyClasses(java.lang.ClassLoader cl, java.lang.Class[] interfaces)protected voidaddRemoteServiceProxyToProxy(java.util.List classes)protected org.eclipse.equinox.concurrent.future.IFuturecallAsync(AbstractAsyncProxyRemoteCall call)org.eclipse.equinox.concurrent.future.IFuturecallAsync(IRemoteCall call)Call remote method specified by call parameter asynchronously, and immediately returnIFutureinstance.java.util.concurrent.Future<java.lang.Object>callAsync(IRemoteCall call, java.util.concurrent.Callable<java.lang.Object> callable)protected java.lang.ObjectcallAsyncWithResult(IRemoteCall call, IRemoteCallListener listener)protected java.util.concurrent.Future<java.lang.Object>callAsyncWithTimeout(IRemoteCall call, java.util.concurrent.Callable<java.lang.Object> callable)protected voidcallAsyncWithTimeout(IRemoteCall call, java.util.concurrent.Callable<IRemoteCallCompleteEvent> callable, IRemoteCallListener callback)protected voidcallCompletableAsync(AbstractAsyncProxyRemoteCall call, IAsyncProxyCompletable completable)protected java.util.concurrent.FuturecallFutureAsync(AbstractAsyncProxyRemoteCall call)protected java.util.concurrent.FuturecallFutureAsync(IRemoteCall call)java.lang.ObjectcallSync(IRemoteCall call, java.util.concurrent.Callable<java.lang.Object> callable)protected java.lang.StringconvertInterfaceNameToAsyncInterfaceName(java.lang.String interfaceName)protected java.lang.ObjectcreateProxy(java.lang.Class[] classes)protected java.lang.ObjectcreateProxy(java.lang.ClassLoader cl, java.lang.Class[] classes)protected IRemoteCallCompleteEventcreateRCCE(java.lang.Object result, java.lang.Throwable e)protected IRemoteCallCompleteEventcreateRCCEFailure(java.lang.Throwable e)protected IRemoteCallCompleteEventcreateRCCESuccess(java.lang.Object result)protected IRemoteCallcreateRemoteCall(java.lang.String callMethod, java.lang.Object[] callParameters, long callTimeout)voiddispose()protected java.lang.ClassfindAsyncRemoteServiceProxyClass(java.lang.Class c)protected java.lang.ClassfindAsyncRemoteServiceProxyClass(java.lang.ClassLoader cl, java.lang.Class c)protected AbstractRemoteService.AsyncArgsgetAsyncArgs(java.lang.reflect.Method method, java.lang.Object[] args)protected java.lang.StringgetAsyncInvokeMethodName(java.lang.reflect.Method method)protected RemoteCallgetAsyncRemoteCall(java.lang.String invokeMethodName, java.lang.Object[] asyncArgs)protected java.lang.StringgetCallMethodNameForProxyInvoke(java.lang.reflect.Method method, java.lang.Object[] args)protected java.lang.Object[]getCallParametersForProxyInvoke(java.lang.String callMethod, java.lang.reflect.Method proxyMethod, java.lang.Object[] args)protected longgetCallTimeoutForProxyInvoke(java.lang.String callMethod, java.lang.reflect.Method proxyMethod, java.lang.Object[] args)protected longgetDefaultTimeout()protected java.util.concurrent.ExecutorServicegetFutureExecutorService(IRemoteCall call)protected org.eclipse.equinox.concurrent.future.IExecutorgetIFutureExecutor(IRemoteCall call)protected abstract java.lang.String[]getInterfaceClassNames()java.lang.ObjectgetProxy()Get local proxy for remote interface.java.lang.ObjectgetProxy(java.lang.ClassLoader cl, java.lang.Class[] interfaces)Get local proxy for remote interface.protected IRemoteServicegetRemoteService()protected abstract IRemoteServiceIDgetRemoteServiceID()protected IRemoteServiceProxyCreatorgetRemoteServiceProxyCreator()protected abstract IRemoteServiceReferencegetRemoteServiceReference()protected voidhandleInvokeSyncException(java.lang.String methodName, ECFException e)protected voidhandleProxyException(java.lang.String message, java.lang.Throwable t)java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)protected java.lang.ObjectinvokeAsync(java.lang.reflect.Method method, java.lang.Object[] args)protected java.lang.ObjectinvokeObject(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)protected java.lang.ObjectinvokeReturnAsync(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)protected java.lang.ObjectinvokeSync(IRemoteCall call)protected booleanisAsync(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)protected booleanisInterfaceAsync(java.lang.Class interfaceClass)protected booleanisMethodAsync(java.lang.String methodName)protected booleanisOSGIAsync()protected java.lang.ClassloadInterfaceClass(java.lang.ClassLoader cl, java.lang.String className)protected java.lang.ClassloadInterfaceClass(java.lang.String className)protected voidlogWarning(java.lang.String string, java.lang.Throwable e)protected voidsetFutureExecutorService(java.util.concurrent.ExecutorService executorService)protected voidsetIFutureExecutor(org.eclipse.equinox.concurrent.future.IExecutor executor)-
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
-
Methods inherited from interface org.eclipse.ecf.remoteservice.IRemoteService
callAsync, callSync, fireAsync
-
-
-
-
Field Detail
-
EMPTY_ARGS
protected static final java.lang.Object[] EMPTY_ARGS
-
futureExecutorServiceMaxThreads
protected int futureExecutorServiceMaxThreads
- Since:
- 8.2
-
futureExecutorService
protected java.util.concurrent.ExecutorService futureExecutorService
- Since:
- 8.2
-
iFutureExecutor
protected org.eclipse.equinox.concurrent.future.IExecutor iFutureExecutor
- Since:
- 8.2
-
-
Method Detail
-
getFutureExecutorService
protected java.util.concurrent.ExecutorService getFutureExecutorService(IRemoteCall call)
- Parameters:
call- the remote call to get the ExecutorService for- Returns:
- ExecutorService
- Since:
- 8.2
-
setFutureExecutorService
protected void setFutureExecutorService(java.util.concurrent.ExecutorService executorService)
- Parameters:
executorService- the ExecutorService to use for this remote service- Since:
- 8.2
-
getIFutureExecutor
protected org.eclipse.equinox.concurrent.future.IExecutor getIFutureExecutor(IRemoteCall call)
- Parameters:
call- the IRemoteCall to get the IExecutor for- Returns:
- IExecutor the executor to use for the given call instance.
- Since:
- 8.2
-
setIFutureExecutor
protected void setIFutureExecutor(org.eclipse.equinox.concurrent.future.IExecutor executor)
- Parameters:
executor- executor- Since:
- 8.2
-
getInterfaceClassNames
protected abstract java.lang.String[] getInterfaceClassNames()
-
getRemoteServiceID
protected abstract IRemoteServiceID getRemoteServiceID()
-
getRemoteServiceReference
protected abstract IRemoteServiceReference getRemoteServiceReference()
-
loadInterfaceClass
protected java.lang.Class loadInterfaceClass(java.lang.String className) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
loadInterfaceClass
protected java.lang.Class loadInterfaceClass(java.lang.ClassLoader cl, java.lang.String className) throws java.lang.ClassNotFoundException- Parameters:
cl- the ClassLoader to load the interface class. Will not benullclassName- the interface class to load- Returns:
- Class the class loaded. Must not be
null - Throws:
java.lang.ClassNotFoundException- if class cannot be found- Since:
- 6.0
-
getRemoteService
protected IRemoteService getRemoteService()
-
getDefaultTimeout
protected long getDefaultTimeout()
-
callAsync
protected org.eclipse.equinox.concurrent.future.IFuture callAsync(AbstractAsyncProxyRemoteCall call)
- Specified by:
callAsyncin classAbstractAsyncProxyRemoteService
-
callAsync
public org.eclipse.equinox.concurrent.future.IFuture callAsync(IRemoteCall call)
Description copied from interface:IRemoteServiceCall remote method specified by call parameter asynchronously, and immediately returnIFutureinstance. Returned IFuture will not benull, and allows the caller to retrieve the actual resulting value from the remote call (or exception).- Specified by:
callAsyncin interfaceIRemoteService- Parameters:
call- the remote call to make. Must not benull.- Returns:
- IFuture the asynchronous result to allow the caller to poll
for whether the result
IFuture.isDone(), and then toIFuture.get()the actual result.
-
getProxy
public java.lang.Object getProxy() throws ECFExceptionDescription copied from interface:IRemoteServiceGet 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:
getProxyin interfaceIRemoteService- 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. Will not be
null. - Throws:
ECFException- If some problem in creating the proxy. The underlying problem is conveyed in the nested exception.
-
addRemoteServiceProxyToProxy
protected void addRemoteServiceProxyToProxy(java.util.List classes)
- Parameters:
classes- the interface classes to add to- Since:
- 6.0
-
addAsyncProxyClasses
protected java.util.List addAsyncProxyClasses(java.lang.ClassLoader cl, java.lang.Class[] interfaces)- Parameters:
cl- ClassLoader to use to add async proxy classesinterfaces- the Class[] of interface classes- Returns:
- List the list of interfaces plus any async proxy interface classes.
- Since:
- 8.3
-
getProxy
public java.lang.Object getProxy(java.lang.ClassLoader cl, java.lang.Class[] interfaces) throws ECFExceptionDescription copied from interface:IRemoteServiceGet 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:
getProxyin interfaceIRemoteService- Parameters:
cl- ClassLoader to use to create the proxy class. Must not benull.interfaces- array of Class that has the loaded interface classes. Must not benulland should have dimension of one or more.- Returns:
- Object that implements the given interfaceClasses. The result may then
be cast to the one of the types given in interfaceClasses. Will not be
null - Throws:
ECFException- If some problem in creating the proxy. The underlying problem is conveyed in the nested exception.- Since:
- 6.0
-
getRemoteServiceProxyCreator
protected IRemoteServiceProxyCreator getRemoteServiceProxyCreator()
- Returns:
- IRemoteServiceProxyCreator
- Since:
- 8.0
-
createProxy
protected java.lang.Object createProxy(java.lang.ClassLoader cl, java.lang.Class[] classes)- Parameters:
cl- ClassLoader for proxy creationclasses- the Class[] for proxy classes- Returns:
- Object the proxy implementing the given Class[]
- Since:
- 6.0
-
createProxy
protected java.lang.Object createProxy(java.lang.Class[] classes)
-
findAsyncRemoteServiceProxyClass
protected java.lang.Class findAsyncRemoteServiceProxyClass(java.lang.Class c)
- Parameters:
c- Class- Returns:
- Class
- Since:
- 3.3
-
findAsyncRemoteServiceProxyClass
protected java.lang.Class findAsyncRemoteServiceProxyClass(java.lang.ClassLoader cl, java.lang.Class c)- Parameters:
cl- ClassLoaderc- Class- Returns:
- Class
- Since:
- 6.0
-
convertInterfaceNameToAsyncInterfaceName
protected java.lang.String convertInterfaceNameToAsyncInterfaceName(java.lang.String interfaceName)
-
getCallParametersForProxyInvoke
protected java.lang.Object[] getCallParametersForProxyInvoke(java.lang.String callMethod, java.lang.reflect.Method proxyMethod, java.lang.Object[] args)
-
getCallTimeoutForProxyInvoke
protected long getCallTimeoutForProxyInvoke(java.lang.String callMethod, java.lang.reflect.Method proxyMethod, java.lang.Object[] args)
-
getCallMethodNameForProxyInvoke
protected java.lang.String getCallMethodNameForProxyInvoke(java.lang.reflect.Method method, java.lang.Object[] args)
-
invokeObject
protected java.lang.Object invokeObject(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
invokeSync
protected java.lang.Object invokeSync(IRemoteCall call) throws ECFException
- Throws:
ECFException
-
isAsync
protected boolean isAsync(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)- Parameters:
proxy- proxy instancemethod- the java Method invokedargs- arguments- Returns:
- true if given proxy/method/args combination represents an async proxy class
- Since:
- 8.3
-
createRemoteCall
protected IRemoteCall createRemoteCall(java.lang.String callMethod, java.lang.Object[] callParameters, long callTimeout)
- Parameters:
callMethod- call methodcallParameters- call parameterscallTimeout- call timeout- Returns:
- IRemoteCall remote call created. Should not be
null - Since:
- 8.3
-
handleProxyException
protected void handleProxyException(java.lang.String message, java.lang.Throwable t) throws ServiceException- Parameters:
message- message for exceptiont- Throwable to wrap- Throws:
ServiceException- thrown if subclasses do not override- Since:
- 8.6
-
handleInvokeSyncException
protected void handleInvokeSyncException(java.lang.String methodName, ECFException e) throws java.lang.Throwable- Parameters:
methodName- method namee- exception thrown if subclasses do not override- Throws:
java.lang.Throwable- thrown if subclasses to not override- Since:
- 8.6
-
invokeReturnAsync
protected java.lang.Object invokeReturnAsync(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable- Throws:
java.lang.Throwable- Since:
- 8.13
-
isOSGIAsync
protected boolean isOSGIAsync()
- Since:
- 8.13
-
isInterfaceAsync
protected boolean isInterfaceAsync(java.lang.Class interfaceClass)
- Since:
- 8.13
-
isMethodAsync
protected boolean isMethodAsync(java.lang.String methodName)
- Since:
- 8.13
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable- Specified by:
invokein interfacejava.lang.reflect.InvocationHandler- Throws:
java.lang.Throwable
-
getAsyncRemoteCall
protected RemoteCall getAsyncRemoteCall(java.lang.String invokeMethodName, java.lang.Object[] asyncArgs)
- Parameters:
invokeMethodName- invoke method nameasyncArgs- asynch arguments- Returns:
- RemoteCall remote call created. Should not be
null - Since:
- 8.4
-
invokeAsync
protected java.lang.Object invokeAsync(java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable- Parameters:
method- java Method invokedargs- arguments- Returns:
- Object async future result. Should be of type IFuture, Future, or CompletableFuture
- Throws:
java.lang.Throwable- thrown if some problem invoking async- Since:
- 3.3
-
callAsyncWithResult
protected java.lang.Object callAsyncWithResult(IRemoteCall call, IRemoteCallListener listener)
- Parameters:
call- remote calllistener- remote call listener- Returns:
- Object will be
nullunless subclasses override - Since:
- 8.2
-
callCompletableAsync
protected void callCompletableAsync(AbstractAsyncProxyRemoteCall call, IAsyncProxyCompletable completable)
- Specified by:
callCompletableAsyncin classAbstractAsyncProxyRemoteService- Parameters:
call- abstract remote callcompletable- async proxy completable- Since:
- 8.4
-
callFutureAsync
protected java.util.concurrent.Future callFutureAsync(AbstractAsyncProxyRemoteCall call)
- Specified by:
callFutureAsyncin classAbstractAsyncProxyRemoteService- Parameters:
call- abstract async proxy remote call- Returns:
- Future future result
- Since:
- 8.4
-
callFutureAsync
protected java.util.concurrent.Future callFutureAsync(IRemoteCall call)
- Parameters:
call- remote call- Returns:
- Future future result
- Since:
- 8.2
-
getAsyncArgs
protected AbstractRemoteService.AsyncArgs getAsyncArgs(java.lang.reflect.Method method, java.lang.Object[] args)
- Parameters:
method- methodargs- args- Returns:
- AsyncArgs async arguments
- Since:
- 3.3
-
getAsyncInvokeMethodName
protected java.lang.String getAsyncInvokeMethodName(java.lang.reflect.Method method)
- Parameters:
method- java method invoked- Returns:
- String synchronous method name without asynchronous suffix (i.e. fooAsync to foo)
- Since:
- 3.3
-
logWarning
protected void logWarning(java.lang.String string, java.lang.Throwable e)
-
callAsync
public java.util.concurrent.Future<java.lang.Object> callAsync(IRemoteCall call, java.util.concurrent.Callable<java.lang.Object> callable)
- Since:
- 8.13
-
callSync
public java.lang.Object callSync(IRemoteCall call, java.util.concurrent.Callable<java.lang.Object> callable) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Throws:
java.util.concurrent.TimeoutExceptionjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedException- Since:
- 8.13
-
dispose
public void dispose()
- Since:
- 8.2
-
callAsyncWithTimeout
protected java.util.concurrent.Future<java.lang.Object> callAsyncWithTimeout(IRemoteCall call, java.util.concurrent.Callable<java.lang.Object> callable)
- Since:
- 8.13
-
createRCCESuccess
protected IRemoteCallCompleteEvent createRCCESuccess(java.lang.Object result)
- Since:
- 8.13
-
createRCCEFailure
protected IRemoteCallCompleteEvent createRCCEFailure(java.lang.Throwable e)
- Since:
- 8.13
-
createRCCE
protected IRemoteCallCompleteEvent createRCCE(java.lang.Object result, java.lang.Throwable e)
- Since:
- 8.13
-
callAsyncWithTimeout
protected void callAsyncWithTimeout(IRemoteCall call, java.util.concurrent.Callable<IRemoteCallCompleteEvent> callable, IRemoteCallListener callback)
- Since:
- 8.13
-
-