Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2018-03-10 22:10:22 -0500
committerslewis2018-03-10 22:10:22 -0500
commit0c841087a4c835006de048cac73554af36a40ee4 (patch)
treeec561b8ae42196f0236abc051d6ed6c697cae0f4 /framework/bundles
parent1aa9691b99d3f0deca7b9ea7d4ba976ef4f7276e (diff)
downloadorg.eclipse.ecf-0c841087a4c835006de048cac73554af36a40ee4.tar.gz
org.eclipse.ecf-0c841087a4c835006de048cac73554af36a40ee4.tar.xz
org.eclipse.ecf-0c841087a4c835006de048cac73554af36a40ee4.zip
Dependency fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205 Change-Id: I0000000000000000000000000000000000000000
Diffstat (limited to 'framework/bundles')
-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/AsyncReturnUtil.java71
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.asyncproxy/src/org/eclipse/ecf/remoteservice/asyncproxy/AsyncReturnUtil.java60
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.rpc/META-INF/MANIFEST.MF1
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.rpc/build.properties1
5 files changed, 116 insertions, 20 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 13189fc78..7b11af8c4 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
@@ -11,5 +11,4 @@ Bundle-Localization: bundle
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,
- org.eclipse.equinox.common
+Require-Bundle: org.eclipse.equinox.common
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
index 215b75f52..458aa7fbc 100644
--- 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
@@ -17,12 +17,35 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.concurrent.future.IFuture;
-import org.eclipse.equinox.concurrent.future.TimeoutException;
+import org.eclipse.equinox.concurrent.future.IProgressRunnable;
+import org.eclipse.equinox.concurrent.future.ImmediateExecutor;
+import org.osgi.util.promise.Deferred;
import org.osgi.util.promise.Promise;
public class AsyncReturnUtil {
+ private static IFuture<?> createIFuture(final Object returnObject) {
+ return new ImmediateExecutor().execute(new IProgressRunnable<Object>() {
+ public Object run(IProgressMonitor monitor) throws Exception {
+ return returnObject;
+ }
+ }, null);
+ }
+
+ private static Promise<?> createPromise(final Object returnObject) {
+ Deferred<Object> deferred = new Deferred<Object>();
+ deferred.resolve(returnObject);
+ return deferred.getPromise();
+ }
+
+ private static CompletableFuture<?> createCompletableFuture(final Object returnObject) {
+ CompletableFuture<Object> cf = new CompletableFuture<Object>();
+ cf.complete(returnObject);
+ return cf;
+ }
+
public static boolean isAsyncType(Class<?> type) {
return (type == null) ? false
: (CompletableFuture.class.isAssignableFrom(type) || CompletionStage.class.isAssignableFrom(type)
@@ -30,19 +53,51 @@ public class AsyncReturnUtil {
|| 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 {
+ public static boolean isAsyncType(String className) {
+ return (className == null) ? false
+ : (CompletableFuture.class.getName().equals(className)
+ || CompletionStage.class.getName().equals(className) || Future.class.getName().equals(className)
+ || IFuture.class.getName().equals(className) || Promise.class.getName().equals(className));
+ }
+
+ public static Object convertAsyncToReturn(Object returnObject, Class<?> asyncReturnType, long timeout)
+ throws 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);
+ return ((Future<?>) returnObject).get(timeout, TimeUnit.MILLISECONDS);
else if (asyncReturnType.isAssignableFrom(CompletionStage.class))
- return ((CompletionStage) returnObject).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS);
+ return ((CompletionStage<?>) returnObject).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS);
else if (asyncReturnType.isAssignableFrom(IFuture.class))
- return ((IFuture) returnObject).get();
+ return ((IFuture<?>) returnObject).get();
else if (asyncReturnType.isAssignableFrom(Promise.class))
- return ((Promise) returnObject).getValue();
+ return ((Promise<?>) returnObject).getValue();
+ return null;
+ }
+
+ public static Object convertReturnToAsync(Object returnObject, Class<?> returnType) {
+ if (IFuture.class.isAssignableFrom(returnType)) {
+ return createIFuture(returnObject);
+ } else if (Promise.class.isAssignableFrom(returnType)) {
+ return createPromise(returnObject);
+ } else if (CompletableFuture.class.isAssignableFrom(returnType)
+ || CompletionStage.class.isAssignableFrom(returnType) || Future.class.isAssignableFrom(returnType)) {
+ return createCompletableFuture(returnObject);
+ }
+ return null;
+ }
+
+ public static Object convertReturnToAsync(Object returnObject, String returnType) {
+ if (IFuture.class.getName().equals(returnType)) {
+ return createIFuture(returnObject);
+ } else if (Promise.class.getName().equals(returnType)) {
+ return createPromise(returnObject);
+ } else if (CompletableFuture.class.getName().equals(returnType)
+ || CompletionStage.class.getName().equals(returnType) || Future.class.getName().equals(returnType)) {
+ return createCompletableFuture(returnObject);
+ }
return returnObject;
}
+
}
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
index 6255dbf38..21efa8427 100644
--- 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
@@ -11,29 +11,71 @@
package org.eclipse.ecf.remoteservice.asyncproxy;
import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.concurrent.future.IFuture;
-import org.eclipse.equinox.concurrent.future.TimeoutException;
+import org.eclipse.equinox.concurrent.future.IProgressRunnable;
+import org.eclipse.equinox.concurrent.future.ImmediateExecutor;
public class AsyncReturnUtil {
- public static boolean isAsyncType(Class<?> type) {
+ public static boolean isAsyncType(final 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 {
+ public static boolean isAsyncType(String className) {
+ return (className == null) ? false
+ : (Future.class.getName().equals(className)
+ || IFuture.class.getName().equals(className));
+ }
+
+ public static Object convertAsyncToReturn(final Object returnObject, final Class<?> asyncReturnType, long timeout)
+ throws 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;
+ return ((Future<?>) returnObject).get(timeout, TimeUnit.MILLISECONDS);
+ else if (asyncReturnType.isAssignableFrom(IFuture.class))
+ return ((IFuture<?>) returnObject).get();
+ return null;
+ }
+
+ private static IFuture<?> createIFuture(final Object returnObject) {
+ return new ImmediateExecutor().execute(new IProgressRunnable<Object>() {
+ public Object run(IProgressMonitor monitor) throws Exception {
+ return returnObject;
+ }
+ }, null);
+ }
+
+ private static Future<?> createFuture(final Object returnObject) {
+ return Executors.newSingleThreadExecutor().submit(new Callable<Object>() {
+ public Object call() throws Exception {
+ return returnObject;
+ }});
+ }
+
+ public static Object convertReturnToAsync(final Object returnObject, final Class<?> returnType) {
+ if (IFuture.class.isAssignableFrom(returnType))
+ return createIFuture(returnObject);
+ else if (Future.class.isAssignableFrom(returnType))
+ return createFuture(returnObject);
+ return null;
+ }
+
+ public static Object convertReturnToAsync(final Object returnObject, final String returnType) {
+ if (IFuture.class.getName().equals(returnType)) {
+ return createIFuture(returnObject);
+ } else if (Future.class.getName().equals(returnType)) {
+ return createFuture(returnObject);
+ }
+ return null;
}
}
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 36b8e0d40..652352a89 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
@@ -31,6 +31,7 @@ Import-Package: javax.servlet;version="2.6.0",
org.eclipse.ecf.remoteservice;version="6.0.0",
org.eclipse.ecf.remoteservice.asyncproxy,
org.eclipse.ecf.remoteservice.client,
+ org.eclipse.equinox.concurrent.future;version="1.1.0",
org.osgi.framework,
org.osgi.service.log;version="1.3.0",
org.osgi.util.tracker
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.rpc/build.properties b/framework/bundles/org.eclipse.ecf.remoteservice.rpc/build.properties
index dd3df998b..16d547646 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice.rpc/build.properties
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.rpc/build.properties
@@ -11,5 +11,4 @@ bin.includes = META-INF/,\
.,\
plugin.xml,\
plugin.properties
-additional.bundles = org.eclipse.equinox.concurrent
jars.extra.classpath = platform:/plugin/org.eclipse.equinox.concurrent

Back to the top