Package org.eclipse.ecf.remoteservice
Class AbstractRemoteService
java.lang.Object
org.eclipse.ecf.remoteservice.asyncproxy.AbstractAsyncProxyRemoteService
org.eclipse.ecf.remoteservice.AbstractRemoteService
- All Implemented Interfaces:
InvocationHandler
,IRemoteService
- Direct Known Subclasses:
AbstractClientService
,RemoteServiceImpl
public abstract class AbstractRemoteService
extends AbstractAsyncProxyRemoteService
implements IRemoteService, InvocationHandler
Abstract remote service implementation. Clients may subclass to avoid re-implementing
methods from IRemoteService.
- Since:
- 4.1
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Object[]
protected ExecutorService
protected int
protected org.eclipse.equinox.concurrent.future.IExecutor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected List
addAsyncProxyClasses
(ClassLoader cl, Class[] interfaces) protected void
addRemoteServiceProxyToProxy
(List classes) protected org.eclipse.equinox.concurrent.future.IFuture
org.eclipse.equinox.concurrent.future.IFuture
callAsync
(IRemoteCall call) Call remote method specified by call parameter asynchronously, and immediately returnIFuture
instance.callAsync
(IRemoteCall call, Callable<Object> callable) protected Object
callAsyncWithResult
(IRemoteCall call, IRemoteCallListener listener) callAsyncWithTimeout
(IRemoteCall call, Callable<Object> callable) protected void
callAsyncWithTimeout
(IRemoteCall call, Callable<IRemoteCallCompleteEvent> callable, IRemoteCallListener callback) protected void
callCompletableAsync
(AbstractAsyncProxyRemoteCall call, IAsyncProxyCompletable completable) protected Future
protected Future
callFutureAsync
(IRemoteCall call) callSync
(IRemoteCall call, Callable<Object> callable) protected String
convertInterfaceNameToAsyncInterfaceName
(String interfaceName) protected Object
createProxy
(Class[] classes) protected Object
createProxy
(ClassLoader cl, Class[] classes) protected IRemoteCallCompleteEvent
createRCCE
(Object result, Throwable e) protected IRemoteCallCompleteEvent
protected IRemoteCallCompleteEvent
createRCCESuccess
(Object result) protected IRemoteCall
createRemoteCall
(String callMethod, Object[] callParameters, long callTimeout) void
dispose()
protected Class
protected Class
protected AbstractRemoteService.AsyncArgs
getAsyncArgs
(Method method, Object[] args) protected String
getAsyncInvokeMethodName
(Method method) protected RemoteCall
getAsyncRemoteCall
(String invokeMethodName, Object[] asyncArgs) protected String
getCallMethodNameForProxyInvoke
(Method method, Object[] args) protected Object[]
getCallParametersForProxyInvoke
(String callMethod, Method proxyMethod, Object[] args) protected long
getCallTimeoutForProxyInvoke
(String callMethod, Method proxyMethod, Object[] args) protected long
protected ExecutorService
protected org.eclipse.equinox.concurrent.future.IExecutor
protected abstract String[]
getProxy()
Get local proxy for remote interface.getProxy
(ClassLoader cl, Class[] interfaces) Get local proxy for remote interface.protected IRemoteService
protected abstract IRemoteServiceID
protected IRemoteServiceProxyCreator
protected abstract IRemoteServiceReference
protected void
handleInvokeSyncException
(String methodName, ECFException e) protected void
handleProxyException
(String message, Throwable t) protected Object
invokeAsync
(Method method, Object[] args) protected Object
invokeObject
(Object proxy, Method method, Object[] args) protected Object
invokeReturnAsync
(Object proxy, Method method, Object[] args) protected Object
invokeSync
(IRemoteCall call) protected boolean
protected boolean
isInterfaceAsync
(Class interfaceClass) protected boolean
isMethodAsync
(String methodName) protected boolean
protected Class
loadInterfaceClass
(ClassLoader cl, String className) protected Class
loadInterfaceClass
(String className) protected void
logWarning
(String string, Throwable e) protected void
setFutureExecutorService
(ExecutorService executorService) protected void
setIFutureExecutor
(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 Details
-
EMPTY_ARGS
-
futureExecutorServiceMaxThreads
protected int futureExecutorServiceMaxThreads- Since:
- 8.2
-
futureExecutorService
- Since:
- 8.2
-
iFutureExecutor
protected org.eclipse.equinox.concurrent.future.IExecutor iFutureExecutor- Since:
- 8.2
-
-
Constructor Details
-
AbstractRemoteService
public AbstractRemoteService()
-
-
Method Details
-
getFutureExecutorService
- Parameters:
call
- the remote call to get the ExecutorService for- Returns:
- ExecutorService
- Since:
- 8.2
-
setFutureExecutorService
- Parameters:
executorService
- the ExecutorService to use for this remote service- Since:
- 8.2
-
getIFutureExecutor
- 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
-
getRemoteServiceID
-
getRemoteServiceReference
-
loadInterfaceClass
- Throws:
ClassNotFoundException
-
loadInterfaceClass
- Parameters:
cl
- the ClassLoader to load the interface class. Will not benull
className
- the interface class to load- Returns:
- Class the class loaded. Must not be
null
- Throws:
ClassNotFoundException
- if class cannot be found- Since:
- 6.0
-
getRemoteService
-
getDefaultTimeout
protected long getDefaultTimeout() -
callAsync
protected org.eclipse.equinox.concurrent.future.IFuture callAsync(AbstractAsyncProxyRemoteCall call) - Specified by:
callAsync
in classAbstractAsyncProxyRemoteService
-
callAsync
Description copied from interface:IRemoteService
Call remote method specified by call parameter asynchronously, and immediately returnIFuture
instance. Returned IFuture will not benull
, and allows the caller to retrieve the actual resulting value from the remote call (or exception).- Specified by:
callAsync
in 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
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 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
- Parameters:
classes
- the interface classes to add to- Since:
- 6.0
-
addAsyncProxyClasses
- 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
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 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 benull
and 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
- Returns:
- IRemoteServiceProxyCreator
- Since:
- 8.0
-
createProxy
- Parameters:
cl
- ClassLoader for proxy creationclasses
- the Class[] for proxy classes- Returns:
- Object the proxy implementing the given Class[]
- Since:
- 6.0
-
createProxy
-
findAsyncRemoteServiceProxyClass
- Parameters:
c
- Class- Returns:
- Class
- Since:
- 3.3
-
findAsyncRemoteServiceProxyClass
- Parameters:
cl
- ClassLoaderc
- Class- Returns:
- Class
- Since:
- 6.0
-
convertInterfaceNameToAsyncInterfaceName
-
getCallParametersForProxyInvoke
-
getCallTimeoutForProxyInvoke
-
getCallMethodNameForProxyInvoke
-
invokeObject
- Throws:
Throwable
-
invokeSync
- Throws:
ECFException
-
isAsync
- 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(String callMethod, 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
- Parameters:
message
- message for exceptiont
- Throwable to wrap- Throws:
ServiceException
- thrown if subclasses do not override- Since:
- 8.6
-
handleInvokeSyncException
- Parameters:
methodName
- method namee
- exception thrown if subclasses do not override- Throws:
Throwable
- thrown if subclasses to not override- Since:
- 8.6
-
invokeReturnAsync
- Throws:
Throwable
- Since:
- 8.13
-
isOSGIAsync
protected boolean isOSGIAsync()- Since:
- 8.13
-
isInterfaceAsync
- Since:
- 8.13
-
isMethodAsync
- Since:
- 8.13
-
invoke
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
getAsyncRemoteCall
- Parameters:
invokeMethodName
- invoke method nameasyncArgs
- asynch arguments- Returns:
- RemoteCall remote call created. Should not be
null
- Since:
- 8.4
-
invokeAsync
- Parameters:
method
- java Method invokedargs
- arguments- Returns:
- Object async future result. Should be of type IFuture, Future, or CompletableFuture
- Throws:
Throwable
- thrown if some problem invoking async- Since:
- 3.3
-
callAsyncWithResult
- Parameters:
call
- remote calllistener
- remote call listener- Returns:
- Object will be
null
unless subclasses override - Since:
- 8.2
-
callCompletableAsync
protected void callCompletableAsync(AbstractAsyncProxyRemoteCall call, IAsyncProxyCompletable completable) - Specified by:
callCompletableAsync
in classAbstractAsyncProxyRemoteService
- Parameters:
call
- abstract remote callcompletable
- async proxy completable- Since:
- 8.4
-
callFutureAsync
- Specified by:
callFutureAsync
in classAbstractAsyncProxyRemoteService
- Parameters:
call
- abstract async proxy remote call- Returns:
- Future future result
- Since:
- 8.4
-
callFutureAsync
- Parameters:
call
- remote call- Returns:
- Future future result
- Since:
- 8.2
-
getAsyncArgs
- Parameters:
method
- methodargs
- args- Returns:
- AsyncArgs async arguments
- Since:
- 3.3
-
getAsyncInvokeMethodName
- Parameters:
method
- java method invoked- Returns:
- String synchronous method name without asynchronous suffix (i.e. fooAsync to foo)
- Since:
- 3.3
-
logWarning
-
callAsync
- Since:
- 8.13
-
callSync
public Object callSync(IRemoteCall call, Callable<Object> callable) throws InterruptedException, ExecutionException, TimeoutException - Throws:
TimeoutException
ExecutionException
InterruptedException
- Since:
- 8.13
-
dispose
public void dispose()- Since:
- 8.2
-
callAsyncWithTimeout
- Since:
- 8.13
-
createRCCESuccess
- Since:
- 8.13
-
createRCCEFailure
- Since:
- 8.13
-
createRCCE
- Since:
- 8.13
-
callAsyncWithTimeout
protected void callAsyncWithTimeout(IRemoteCall call, Callable<IRemoteCallCompleteEvent> callable, IRemoteCallListener callback) - Since:
- 8.13
-