Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2018-03-08 18:53:00 -0500
committerslewis2018-03-08 18:53:00 -0500
commit7a6fed32e71982a39047aa0d43effaae56568c66 (patch)
tree965d0d7dd882c17cdc0694beaf9ad307ffadb8ac /framework/bundles
parentf1384a6d3068160830d90678c5ba8237da3d41d9 (diff)
downloadorg.eclipse.ecf-7a6fed32e71982a39047aa0d43effaae56568c66.tar.gz
org.eclipse.ecf-7a6fed32e71982a39047aa0d43effaae56568c66.tar.xz
org.eclipse.ecf-7a6fed32e71982a39047aa0d43effaae56568c66.zip
for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205
Added support for Promise, CompletionStage as return values from ECF async proxy. Change-Id: I0000000000000000000000000000000000000000
Diffstat (limited to 'framework/bundles')
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/META-INF/MANIFEST.MF3
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy.j8/src/org/eclipse/ecf/remoteservice/asyncproxy/AbstractAsyncProxyRemoteService.java27
3 files changed, 25 insertions, 7 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
index 32650c77b..d09fda2ca 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
@@ -27,7 +27,7 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
/**
* @since 2.0
*/
- protected static final String[] genericProviderIntents = {"passByValue", "exactlyOnce", "ordered",}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ protected static final String[] genericProviderIntents = {"osgi.basic", "passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public static final String TCPCLIENT_NAME = "ecf.generic.client"; //$NON-NLS-1$
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 e0388a1e8..eb24c16e2 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
@@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.ecf.remoteservice.asyncproxy
Automatic-Module-Name: org.eclipse.ecf.remoteservice.asyncproxy
Bundle-Version: 2.0.200.qualifier
Bundle-Vendor: %bundle.provider
-Import-Package: org.eclipse.equinox.concurrent.future
+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"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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 c3c96a3d2..5ab531bed 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
@@ -11,9 +11,12 @@
package org.eclipse.ecf.remoteservice.asyncproxy;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
import java.util.concurrent.Future;
import org.eclipse.equinox.concurrent.future.IFuture;
+import org.osgi.util.promise.Deferred;
+import org.osgi.util.promise.Promise;
public abstract class AbstractAsyncProxyRemoteService {
@@ -29,16 +32,30 @@ public abstract class AbstractAsyncProxyRemoteService {
protected Object callFuture(AbstractAsyncProxyRemoteCall call, @SuppressWarnings("rawtypes") Class returnType) {
// If the result value is a CompletableFuture then
// we callCompletableAsync
- if (CompletableFuture.class.isAssignableFrom(returnType)) {
+ if (CompletableFuture.class.isAssignableFrom(returnType)
+ || CompletionStage.class.isAssignableFrom(returnType)) {
@SuppressWarnings("rawtypes")
- CompletableFuture result = new CompletableFuture();
- callCompletableAsync(call, (r,hadException,exception) -> {
- if (hadException) result.completeExceptionally(exception);
- else result.complete(r);
+ CompletableFuture result = new CompletableFuture();
+ callCompletableAsync(call, (r, hadException, exception) -> {
+ if (hadException)
+ result.completeExceptionally(exception);
+ else
+ result.complete(r);
});
// And return the CompletableFuture
return result;
}
+ if (Promise.class.isAssignableFrom(returnType)) {
+ @SuppressWarnings("rawtypes")
+ Deferred d = new Deferred();
+ callCompletableAsync(call, (r, hadException, exception) -> {
+ if (hadException)
+ d.fail(exception);
+ else
+ d.resolve(r);
+ });
+ return d.getPromise();
+ }
// Else if it's an IFuture then return
// IFuture result of callAsync
if (IFuture.class.isAssignableFrom(returnType))

Back to the top