diff options
author | slewis | 2018-03-09 21:55:02 +0000 |
---|---|---|
committer | slewis | 2018-03-09 21:55:02 +0000 |
commit | 1aa9691b99d3f0deca7b9ea7d4ba976ef4f7276e (patch) | |
tree | 4bfd40b232b5cc09100c7a5b119876f86068df1f /framework | |
parent | a2c6a6429af436a2e30749f75c8a9f88fca9fa45 (diff) | |
download | org.eclipse.ecf-1aa9691b99d3f0deca7b9ea7d4ba976ef4f7276e.tar.gz org.eclipse.ecf-1aa9691b99d3f0deca7b9ea7d4ba976ef4f7276e.tar.xz org.eclipse.ecf-1aa9691b99d3f0deca7b9ea7d4ba976ef4f7276e.zip |
Additional fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205
Change-Id: I0000000000000000000000000000000000000000
Diffstat (limited to 'framework')
10 files changed, 112 insertions, 17 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/META-INF/MANIFEST.MF index 0d9177f30..13189fc78 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/META-INF/MANIFEST.MF @@ -8,7 +8,8 @@ Bundle-Vendor: %bundle.provider Import-Package: org.eclipse.equinox.concurrent.future, org.osgi.util.promise Bundle-Localization: bundle -Export-Package: org.eclipse.ecf.remoteservice.asyncproxy;version="2.0.0" +Export-Package: org.eclipse.ecf.remoteservice.asyncproxy;version="2.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.osgi.util;bundle-version="3.3.100";resolution:=optional +Require-Bundle: org.eclipse.osgi.util;bundle-version="3.3.100";resolution:=optional, + org.eclipse.equinox.common diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AbstractAsyncProxyRemoteService.java b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AbstractAsyncProxyRemoteService.java index e38874844..66dbd3f19 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AbstractAsyncProxyRemoteService.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AbstractAsyncProxyRemoteService.java @@ -33,7 +33,7 @@ public abstract class AbstractAsyncProxyRemoteService { @SuppressWarnings("rawtypes") Class returnType = method.getReturnType(); return (CompletableFuture.class.isAssignableFrom(returnType) || CompletionStage.class.isAssignableFrom(returnType) || - Future.class.isAssignableFrom(returnType) || IFuture.class.isAssignableFrom(returnType)); + Future.class.isAssignableFrom(returnType) || IFuture.class.isAssignableFrom(returnType) || Promise.class.isAssignableFrom(returnType)); } @SuppressWarnings("unchecked") diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java new file mode 100644 index 000000000..215b75f52 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java @@ -0,0 +1,48 @@ +/**************************************************************************** + * Copyright (c) 2018 Composent, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Composent, Inc. - initial API and implementation + *****************************************************************************/ +package org.eclipse.ecf.remoteservice.asyncproxy; + +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.eclipse.equinox.concurrent.future.IFuture; +import org.eclipse.equinox.concurrent.future.TimeoutException; +import org.osgi.util.promise.Promise; + +public class AsyncReturnUtil { + + public static boolean isAsyncType(Class<?> type) { + return (type == null) ? false + : (CompletableFuture.class.isAssignableFrom(type) || CompletionStage.class.isAssignableFrom(type) + || Future.class.isAssignableFrom(type) || IFuture.class.isAssignableFrom(type) + || Promise.class.isAssignableFrom(type)); + } + + @SuppressWarnings("rawtypes") + public static Object asyncReturn(Object returnObject, Class<?> asyncReturnType, long timeout) throws TimeoutException, + InterruptedException, ExecutionException, java.util.concurrent.TimeoutException, InvocationTargetException { + if (returnObject == null) + return null; + else if (asyncReturnType.isAssignableFrom(Future.class)) + return ((Future) returnObject).get(timeout, TimeUnit.MILLISECONDS); + else if (asyncReturnType.isAssignableFrom(CompletionStage.class)) + return ((CompletionStage) returnObject).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS); + else if (asyncReturnType.isAssignableFrom(IFuture.class)) + return ((IFuture) returnObject).get(); + else if (asyncReturnType.isAssignableFrom(Promise.class)) + return ((Promise) returnObject).getValue(); + return returnObject; + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/META-INF/MANIFEST.MF index 28f01865e..0cf892646 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/META-INF/MANIFEST.MF @@ -3,10 +3,11 @@ Bundle-ManifestVersion: 2 Bundle-Name: %bundle.name Bundle-SymbolicName: org.eclipse.ecf.remoteservice.asyncproxy Automatic-Module-Name: org.eclipse.ecf.remoteservice.asyncproxy -Bundle-Version: 1.0.200.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Vendor: %bundle.provider Import-Package: org.eclipse.equinox.concurrent.future Bundle-Localization: bundle -Export-Package: org.eclipse.ecf.remoteservice.asyncproxy;version="1.0.100" +Export-Package: org.eclipse.ecf.remoteservice.asyncproxy;version="1.1.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.equinox.common diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/pom.xml b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/pom.xml index 5baae4009..7cc0a5f49 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/pom.xml +++ b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/pom.xml @@ -10,6 +10,6 @@ </parent> <groupId>org.eclipse.ecf</groupId> <artifactId>org.eclipse.ecf.remoteservice.asyncproxy</artifactId> - <version>1.0.200-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java new file mode 100644 index 000000000..6255dbf38 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java @@ -0,0 +1,39 @@ +/**************************************************************************** + * Copyright (c) 2018 Composent, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Composent, Inc. - initial API and implementation + *****************************************************************************/ +package org.eclipse.ecf.remoteservice.asyncproxy; + +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.eclipse.equinox.concurrent.future.IFuture; +import org.eclipse.equinox.concurrent.future.TimeoutException; + +public class AsyncReturnUtil { + + public static boolean isAsyncType(Class<?> type) { + return (type == null) ? false + : (Future.class.isAssignableFrom(type) || IFuture.class.isAssignableFrom(type)); + } + + @SuppressWarnings("rawtypes") + public static Object asyncReturn(Object returnObject, Class<?> asyncReturnType, long timeout) throws TimeoutException, + InterruptedException, ExecutionException, java.util.concurrent.TimeoutException, InvocationTargetException { + if (returnObject == null) + return null; + else if (asyncReturnType.isAssignableFrom(IFuture.class)) + return ((IFuture) returnObject).get(); + else if (asyncReturnType.isAssignableFrom(Future.class)) + return ((Future) returnObject).get(timeout,TimeUnit.MILLISECONDS); + return returnObject; + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.rpc/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice.rpc/META-INF/MANIFEST.MF index 19cd4f5b4..36b8e0d40 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.rpc/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.remoteservice.rpc/META-INF/MANIFEST.MF @@ -29,7 +29,7 @@ Import-Package: javax.servlet;version="2.6.0", org.eclipse.ecf.core.identity;version="3.0.0", org.eclipse.ecf.core.provider, org.eclipse.ecf.remoteservice;version="6.0.0", - org.eclipse.ecf.remoteservice.asyncproxy;version="1.0.0", + org.eclipse.ecf.remoteservice.asyncproxy, org.eclipse.ecf.remoteservice.client, org.osgi.framework, org.osgi.service.log;version="1.3.0", diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.soap/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice.soap/META-INF/MANIFEST.MF index 2110033ea..951b8fa04 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.soap/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.remoteservice.soap/META-INF/MANIFEST.MF @@ -6,16 +6,16 @@ Bundle-SymbolicName: org.eclipse.ecf.remoteservice.soap;singleton:=true Automatic-Module-Name: org.eclipse.ecf.remoteservice.soap Bundle-Version: 1.1.100.qualifier Bundle-RequiredExecutionEnvironment: J2SE-1.4 -Import-Package: org.eclipse.ecf.core;version="3.0.0", - org.eclipse.ecf.core.identity;version="3.0.0", - org.eclipse.ecf.core.util, - org.eclipse.ecf.remoteservice, +Import-Package: org.eclipse.ecf.remoteservice, org.eclipse.ecf.remoteservice.asyncproxy;version="1.0.0", - org.eclipse.ecf.remoteservice.client + org.eclipse.ecf.remoteservice.client, + org.eclipse.equinox.concurrent.future;version="1.1.0", + org.osgi.framework Bundle-ClassPath: . Export-Package: org.eclipse.ecf.remoteservice.soap.client;version="1.0.0", org.eclipse.ecf.remoteservice.soap.identity;version="1.0.0" DynamicImport-Package: * Eclipse-BuddyPolicy: global -Require-Bundle: org.eclipse.equinox.common +Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.0.0,4.0.0)", + org.eclipse.ecf;bundle-version="[3.0.0,4.0.0)" Bundle-Localization: plugin diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.soap/build.properties b/framework/bundles/org.eclipse.ecf.remoteservice.soap/build.properties index 2f8536959..509525054 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.soap/build.properties +++ b/framework/bundles/org.eclipse.ecf.remoteservice.soap/build.properties @@ -6,7 +6,5 @@ bin.includes = META-INF/,\ about.html,\ plugin.properties src.includes = about.html -additional.bundles = org.eclipse.osgi,\ - org.eclipse.equinox.concurrent jars.extra.classpath = platform:/plugin/org.eclipse.equinox.concurrent,\ platform:/plugin/org.eclipse.osgi 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 412a2c7db..30803d6f1 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 @@ -482,6 +482,13 @@ public abstract class AbstractRemoteService extends AbstractAsyncProxyRemoteServ return interfaceClass.getName().endsWith(IAsyncRemoteServiceProxy.ASYNC_INTERFACE_SUFFIX); } + /** + * @since 8.13 + */ + protected boolean isMethodAsync(String methodName) { + return methodName.endsWith(IAsyncRemoteServiceProxy.ASYNC_METHOD_SUFFIX); + } + public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { Object resultObject = null; try { @@ -497,11 +504,12 @@ public abstract class AbstractRemoteService extends AbstractAsyncProxyRemoteServ try { // If return is async type (Future, IFuture, CompletableFuture, CompletionStage) if (isReturnAsync(proxy, method, args)) { - if (isInterfaceAsync(method.getDeclaringClass())) + if (isInterfaceAsync(method.getDeclaringClass()) && isMethodAsync(method.getName())) return invokeAsync(method, args); - // If OSGI Async + // 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$ |