public abstract class AbstractRemoteService extends AbstractAsyncProxyRemoteService implements IRemoteService, InvocationHandler
Modifier and Type | Class and Description |
---|---|
class |
AbstractRemoteService.AsyncArgs |
class |
AbstractRemoteService.ProxyClassLoader |
Modifier and Type | Field and Description |
---|---|
protected static Object[] |
EMPTY_ARGS |
protected ExecutorService |
futureExecutorService |
protected int |
futureExecutorServiceMaxThreads |
protected org.eclipse.equinox.concurrent.future.IExecutor |
iFutureExecutor |
Constructor and Description |
---|
AbstractRemoteService() |
callFuture
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
callAsync, callSync, fireAsync
protected static final Object[] EMPTY_ARGS
protected int futureExecutorServiceMaxThreads
protected ExecutorService futureExecutorService
protected org.eclipse.equinox.concurrent.future.IExecutor iFutureExecutor
protected ExecutorService getFutureExecutorService(IRemoteCall call)
call
- the remote call to get the ExecutorService forprotected void setFutureExecutorService(ExecutorService executorService)
executorService
- the ExecutorService to use for this remote serviceprotected org.eclipse.equinox.concurrent.future.IExecutor getIFutureExecutor(IRemoteCall call)
call
- the IRemoteCall to get the IExecutor forprotected void setIFutureExecutor(org.eclipse.equinox.concurrent.future.IExecutor executor)
executor
- executorprotected abstract String[] getInterfaceClassNames()
protected abstract IRemoteServiceID getRemoteServiceID()
protected abstract IRemoteServiceReference getRemoteServiceReference()
protected Class loadInterfaceClass(String className) throws ClassNotFoundException
ClassNotFoundException
protected Class loadInterfaceClass(ClassLoader cl, String className) throws ClassNotFoundException
cl
- the ClassLoader to load the interface class. Will not be null
className
- the interface class to loadnull
ClassNotFoundException
- if class cannot be foundprotected IRemoteService getRemoteService()
protected long getDefaultTimeout()
protected org.eclipse.equinox.concurrent.future.IFuture callAsync(AbstractAsyncProxyRemoteCall call)
callAsync
in class AbstractAsyncProxyRemoteService
public org.eclipse.equinox.concurrent.future.IFuture callAsync(IRemoteCall call)
IRemoteService
IFuture
instance. Returned IFuture will not be null
,
and allows the caller to retrieve the actual resulting value from the remote call
(or exception).callAsync
in interface IRemoteService
call
- the remote call to make. Must not be null
.IFuture.isDone()
, and then to IFuture.get()
the actual result.public Object getProxy() throws ECFException
IRemoteService
getProxy
in interface IRemoteService
null
.ECFException
- If some problem in creating the proxy. The underlying problem is
conveyed in the nested exception.protected void addRemoteServiceProxyToProxy(List classes)
classes
- the interface classes to add toprotected List addAsyncProxyClasses(ClassLoader cl, Class[] interfaces)
cl
- ClassLoader to use to add async proxy classesinterfaces
- the Class[] of interface classespublic Object getProxy(ClassLoader cl, Class[] interfaces) throws ECFException
IRemoteService
getProxy
in interface IRemoteService
cl
- ClassLoader to use to create the proxy class.
Must not be null
.interfaces
- array of Class that has the loaded interface classes.
Must not be null
and should have dimension of one or more.null
ECFException
- If some problem in creating the proxy. The underlying problem is
conveyed in the nested exception.protected IRemoteServiceProxyCreator getRemoteServiceProxyCreator()
protected Object createProxy(ClassLoader cl, Class[] classes)
cl
- ClassLoader for proxy creationclasses
- the Class[] for proxy classesprotected Class findAsyncRemoteServiceProxyClass(Class c)
c
- Classprotected Class findAsyncRemoteServiceProxyClass(ClassLoader cl, Class c)
cl
- ClassLoaderc
- Classprotected String convertInterfaceNameToAsyncInterfaceName(String interfaceName)
protected Object[] getCallParametersForProxyInvoke(String callMethod, Method proxyMethod, Object[] args)
protected long getCallTimeoutForProxyInvoke(String callMethod, Method proxyMethod, Object[] args)
protected String getCallMethodNameForProxyInvoke(Method method, Object[] args)
protected Object invokeObject(Object proxy, Method method, Object[] args) throws Throwable
Throwable
protected Object invokeSync(IRemoteCall call) throws ECFException
ECFException
protected boolean isAsync(Object proxy, Method method, Object[] args)
proxy
- proxy instancemethod
- the java Method invokedargs
- argumentsprotected IRemoteCall createRemoteCall(String callMethod, Object[] callParameters, long callTimeout)
callMethod
- call methodcallParameters
- call parameterscallTimeout
- call timeoutnull
protected void handleProxyException(String message, Throwable t) throws org.osgi.framework.ServiceException
message
- message for exceptiont
- Throwable to wraporg.osgi.framework.ServiceException
- thrown if subclasses do not overrideprotected void handleInvokeSyncException(String methodName, ECFException e) throws Throwable
methodName
- method namee
- exception thrown if subclasses do not overrideThrowable
- thrown if subclasses to not overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke
in interface InvocationHandler
Throwable
protected RemoteCall getAsyncRemoteCall(String invokeMethodName, Object[] asyncArgs)
invokeMethodName
- invoke method nameasyncArgs
- asynch argumentsnull
protected Object invokeAsync(Method method, Object[] args) throws Throwable
method
- java Method invokedargs
- argumentsThrowable
- thrown if some problem invoking asyncprotected Object callAsyncWithResult(IRemoteCall call, IRemoteCallListener listener)
call
- remote calllistener
- remote call listenernull
unless subclasses overrideprotected void callCompletableAsync(AbstractAsyncProxyRemoteCall call, IAsyncProxyCompletable completable)
callCompletableAsync
in class AbstractAsyncProxyRemoteService
call
- abstract remote callcompletable
- async proxy completableprotected Future callFutureAsync(AbstractAsyncProxyRemoteCall call)
callFutureAsync
in class AbstractAsyncProxyRemoteService
call
- abstract async proxy remote callprotected Future callFutureAsync(IRemoteCall call)
call
- remote callprotected AbstractRemoteService.AsyncArgs getAsyncArgs(Method method, Object[] args)
method
- methodargs
- argsprotected String getAsyncInvokeMethodName(Method method)
method
- java method invokedpublic void dispose()
Copyright © 2017. All rights reserved.