Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2018-04-06 15:15:57 -0400
committerslewis2018-04-06 15:15:57 -0400
commit36a53be07e74f800d9e3a8baa93b99d03ff0f0bd (patch)
tree5250a56822ca5d98fbe93b812d1a1214e184a21d
parent1e55810220d5c6fab6741707d4beef67a18da94a (diff)
downloadorg.eclipse.ecf-36a53be07e74f800d9e3a8baa93b99d03ff0f0bd.tar.gz
org.eclipse.ecf-36a53be07e74f800d9e3a8baa93b99d03ff0f0bd.tar.xz
org.eclipse.ecf-36a53be07e74f800d9e3a8baa93b99d03ff0f0bd.zip
Simplification of API for checking for existence of osgi.async intent on
IRemoteServiceReferences. Change-Id: Id15b6f932eb746dd569c4eba4fbd2540acd7da72
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java16
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/util/AsyncUtil.java34
-rw-r--r--protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteServiceRegistration.java11
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java3
5 files changed, 49 insertions, 17 deletions
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 51dec6acc..6cd97c85d 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
@@ -20,6 +20,7 @@ import org.eclipse.ecf.internal.remoteservice.Activator;
import org.eclipse.ecf.remoteservice.asyncproxy.*;
import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent;
import org.eclipse.ecf.remoteservice.events.IRemoteCallEvent;
+import org.eclipse.ecf.remoteservice.util.AsyncUtil;
import org.eclipse.equinox.concurrent.future.*;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceException;
@@ -468,20 +469,7 @@ public abstract class AbstractRemoteService extends AbstractAsyncProxyRemoteServ
* @since 8.13
*/
protected boolean isOSGIAsync() {
- IRemoteServiceReference ref = getRemoteServiceReference();
- // If osgi.async is set then it's yes
- boolean osgiAsync = ref.getProperty(Constants.OSGI_ASYNC_INTENT) != null;
- if (osgiAsync)
- return true;
- // If service.intents has values, and the osgi.async is present then it's also yes
- String[] serviceIntents = (String[]) ref.getProperty(Constants.OSGI_SERVICE_INTENTS);
- if (serviceIntents != null) {
- List<String> il = Arrays.asList(serviceIntents);
- if (il.contains(Constants.OSGI_ASYNC_INTENT))
- return true;
- }
- // otherwise no
- return false;
+ return AsyncUtil.isOSGIAsync(getRemoteServiceReference());
}
/**
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java
index 61e64ac96..49e5bad06 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java
@@ -153,7 +153,7 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
return (resultProps);
}
- static class Properties extends Hashtable {
+ static class Properties extends Dictionary implements Serializable {
/**
*
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/util/AsyncUtil.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/util/AsyncUtil.java
new file mode 100644
index 000000000..77f64fb2c
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/util/AsyncUtil.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+* 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.util;
+
+import java.util.Arrays;
+import org.eclipse.ecf.remoteservice.Constants;
+import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
+
+/**
+ * @since 8.13
+ */
+public class AsyncUtil {
+
+ public static boolean isOSGIAsync(IRemoteServiceReference ref) {
+ if (ref == null)
+ return false;
+ Object p = ref.getProperty(Constants.OSGI_ASYNC_INTENT);
+ if (p != null)
+ return true;
+ // If service.intents has values, and the osgi.async is present then it's also yes
+ String[] serviceIntents = (String[]) ref.getProperty(Constants.OSGI_SERVICE_INTENTS);
+ if (serviceIntents != null && Arrays.asList(serviceIntents).contains(Constants.OSGI_ASYNC_INTENT))
+ return true;
+ // otherwise no
+ return false;
+ }
+}
diff --git a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteServiceRegistration.java b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteServiceRegistration.java
index f4e98167f..9f42cf876 100644
--- a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteServiceRegistration.java
+++ b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteServiceRegistration.java
@@ -29,6 +29,7 @@
package ch.ethz.iks.r_osgi.impl;
import java.lang.reflect.Method;
+import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
@@ -160,7 +161,15 @@ final class RemoteServiceRegistration {
}
boolean isOSGiAsync() {
- return reference.getProperty(OSGI_ASYNC) != null;
+ Object o = reference.getProperty(OSGI_ASYNC);
+ if (o != null)
+ return true;
+ // If service.intents has values, and the osgi.async is present then it's also yes
+ String[] serviceIntents = (String[]) reference.getProperty("service.intents");
+ if (serviceIntents != null && Arrays.asList(serviceIntents).contains("osgi.async"))
+ return true;
+ // otherwise no
+ return false;
}
long getOSGiTimeout() {
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
index 616fdf47a..a5d539b63 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
@@ -30,6 +30,7 @@ import org.eclipse.ecf.internal.provider.remoteservice.IRemoteServiceProviderDeb
import org.eclipse.ecf.remoteservice.*;
import org.eclipse.ecf.remoteservice.asyncproxy.AsyncReturnUtil;
import org.eclipse.ecf.remoteservice.events.*;
+import org.eclipse.ecf.remoteservice.util.AsyncUtil;
import org.eclipse.equinox.concurrent.future.*;
import org.eclipse.osgi.framework.eventmgr.*;
import org.osgi.framework.InvalidSyntaxException;
@@ -1460,7 +1461,7 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
if (result != null) {
Class returnType = method.getReturnType();
// provider must expose osgi.async property and must be async return type
- if (reg.getProperty(Constants.OSGI_ASYNC_INTENT) != null && AsyncReturnUtil.isAsyncType(returnType))
+ if (AsyncUtil.isOSGIAsync(reg.getReference()) && AsyncReturnUtil.isAsyncType(returnType))
return AsyncReturnUtil.convertAsyncToReturn(result, returnType, call.getTimeout());
}
return result;

Back to the top