From eca50a8929df30b12b3dfc826e59a73fbe5f07a2 Mon Sep 17 00:00:00 2001 From: slewis Date: Wed, 14 Mar 2018 10:32:30 -0700 Subject: Additional fixes for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205 Change-Id: I0000000000000000000000000000000000000000 --- .../ecf/remoteservice/AbstractRemoteService.java | 17 +++++++++++++++++ .../remoteservice/client/AbstractRSAClientService.java | 15 +++++++++++++-- .../provider/RemoteServiceContainerInstantiator.java | 3 ++- 3 files changed, 32 insertions(+), 3 deletions(-) (limited to 'framework/bundles') diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java index 4c87e71cc..01437f489 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java @@ -12,6 +12,7 @@ package org.eclipse.ecf.remoteservice; import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; +import java.util.concurrent.TimeoutException; import org.eclipse.core.runtime.*; import org.eclipse.ecf.core.jobs.JobsExecutor; import org.eclipse.ecf.core.util.ECFException; @@ -699,6 +700,22 @@ public abstract class AbstractRemoteService extends AbstractAsyncProxyRemoteServ a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, string, e)); } + /** + * @since 8.13 + */ + public Object submitCallable(Callable callable, long timeout) throws ECFException { + Future f = getFutureExecutorService(null).submit(callable); + try { + return f.get(timeout, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + throw new ECFException("submitCallable interrupted", e); //$NON-NLS-1$ + } catch (ExecutionException e) { + throw new ECFException("submitCallable interrupted", e.getCause()); //$NON-NLS-1$ + } catch (TimeoutException e) { + throw new ECFException("submitCallable timed out", e); //$NON-NLS-1$ + } + } + /** * @since 8.2 */ diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientService.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientService.java index 39ded4c48..a7bd70f82 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientService.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientService.java @@ -89,8 +89,19 @@ public abstract class AbstractRSAClientService extends AbstractClientService { Object resultObject = invokeObject(proxy, method, args); if (resultObject != null) return resultObject; - if (isAsync(proxy, method, args)) - return invokeAsync(createRemoteCall(proxy, method, getAsyncInvokeMethodName(method), args, getDefaultTimeout())); + try { + // If return is async type (Future, IFuture, CompletableFuture, CompletionStage) + if (isReturnAsync(proxy, method, args)) { + if (isInterfaceAsync(method.getDeclaringClass()) && isMethodAsync(method.getName())) + return invokeAsync(createRemoteCall(proxy, method, getAsyncInvokeMethodName(method), args, getDefaultTimeout())); + // If OSGI Async then invoke method directly + if (isOSGIAsync()) + return invokeReturnAsync(proxy, method, args); + } + } catch (Throwable t) { + handleProxyException("Exception invoking async method on remote service proxy=" + getRemoteServiceID(), t); //$NON-NLS-1$ + } + final String callMethod = getCallMethodNameForProxyInvoke(method, args); final Object[] callParameters = getCallParametersForProxyInvoke(callMethod, method, args); final long callTimeout = getCallTimeoutForProxyInvoke(callMethod, method, args); diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java index 46377b378..608b73355 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java @@ -12,6 +12,7 @@ import java.util.*; import org.eclipse.ecf.core.*; import org.eclipse.ecf.core.provider.BaseContainerInstantiator; import org.eclipse.ecf.core.provider.IRemoteServiceContainerInstantiator; +import org.eclipse.ecf.remoteservice.Constants; import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter; /** @@ -22,7 +23,7 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn protected static final String[] defaultSupportedAdapterTypes = new String[] {IContainer.class.getName(), IRemoteServiceContainerAdapter.class.getName()}; protected static final Class[][] defaultSupportedParameterTypes = new Class[][] {{Map.class}}; - protected static final String[] defaultSupportedIntents = new String[] {"passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + protected static final String[] defaultSupportedIntents = new String[] {Constants.OSGI_BASIC_INTENT, "passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ public String[] getSupportedAdapterTypes(ContainerTypeDescription description) { return defaultSupportedAdapterTypes; -- cgit v1.2.3