Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2016-02-25 18:12:29 +0000
committerslewis2016-02-25 18:12:29 +0000
commit2b63dc97e9c285e3aa66b8be80e924c8c725e3bf (patch)
treed02181184c0f89ada6c3c003538569b0ef8b01d2 /framework
parent12c2659eae6d37f7748e92186eca19828b4e8d75 (diff)
downloadorg.eclipse.ecf-2b63dc97e9c285e3aa66b8be80e924c8c725e3bf.tar.gz
org.eclipse.ecf-2b63dc97e9c285e3aa66b8be80e924c8c725e3bf.tar.xz
org.eclipse.ecf-2b63dc97e9c285e3aa66b8be80e924c8c725e3bf.zip
Additional RSA API for simplifying distribution provider implementations
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceContainer.java1
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientService.java76
3 files changed, 78 insertions, 1 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceContainer.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceContainer.java
index 65db28758..9e436219c 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceContainer.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceContainer.java
@@ -34,6 +34,7 @@ public class RemoteServiceContainer implements IRemoteServiceContainer {
/**
* @since 3.2
*/
+ @SuppressWarnings("cast")
public RemoteServiceContainer(IContainer container) {
this(container, (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class));
}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java
index 87f093cb2..85bd991d6 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java
@@ -63,7 +63,7 @@ public abstract class AbstractRSAClientContainer extends AbstractClientContainer
return new IRemoteCallable[][] {{RemoteCallableFactory.createCallable(getID().getName())}};
}
- class RSAClientRegistration extends RemoteServiceClientRegistration {
+ public class RSAClientRegistration extends RemoteServiceClientRegistration {
public RSAClientRegistration(ID targetID, String[] classNames, IRemoteCallable[][] restCalls, Dictionary properties) {
super(getConnectNamespace(), classNames, restCalls, properties, AbstractRSAClientContainer.this.registry);
this.containerId = targetID;
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
new file mode 100644
index 000000000..5a1f12098
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientService.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+* Copyright (c) 2016 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.client;
+
+import java.lang.reflect.Method;
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.remoteservice.IRemoteCall;
+import org.eclipse.ecf.remoteservice.RemoteCall;
+import org.osgi.framework.ServiceException;
+
+/**
+ * @since 8.9
+ */
+public abstract class AbstractRSAClientService extends AbstractClientService {
+
+ public static class RSARemoteCall extends RemoteCall {
+
+ private final Method reflectMethod;
+
+ public RSARemoteCall(Method method, String methodName, Object[] parameters, long timeout) {
+ super(methodName, parameters, timeout);
+ this.reflectMethod = method;
+ }
+
+ public Method getReflectMethod() {
+ return reflectMethod;
+ }
+ }
+
+ /**
+ * @throws ECFException
+ */
+ @Override
+ protected Object invokeRemoteCall(IRemoteCall call, IRemoteCallable callable) throws ECFException {
+ return null;
+ }
+
+ public AbstractRSAClientService(AbstractClientContainer container, RemoteServiceClientRegistration registration) {
+ super(container, registration);
+ }
+
+ protected abstract Object invokeAsync(Method method, Object[] args);
+
+ protected abstract Object invokeSync(RSARemoteCall remoteCall) throws ECFException;
+
+ protected RSARemoteCall createRemoteCall(Method method, String methodName, Object[] parameters, long timeout) {
+ return new RSARemoteCall(method, methodName, parameters, timeout);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ try {
+ Object resultObject = invokeObject(proxy, method, args);
+ if (resultObject != null)
+ return resultObject;
+ if (isAsync(proxy, method, args))
+ return invokeAsync(method, args);
+ final String callMethod = getCallMethodNameForProxyInvoke(method, args);
+ final Object[] callParameters = getCallParametersForProxyInvoke(callMethod, method, args);
+ final long callTimeout = getCallTimeoutForProxyInvoke(callMethod, method, args);
+ return invokeSync(createRemoteCall(method, callMethod, callParameters, callTimeout));
+ } catch (Throwable t) {
+ if (t instanceof ServiceException)
+ throw t;
+ // rethrow as service exception
+ throw new ServiceException("Service exception on remote service proxy rsid=" + getRemoteServiceID(), ServiceException.REMOTE, t); //$NON-NLS-1$
+ }
+ }
+}

Back to the top