Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2016-02-25 06:22:05 +0000
committerslewis2016-02-25 06:22:05 +0000
commit415619f98512f5059c54841889e41ad5c2aa84f3 (patch)
tree0636eefdc2368f1c86634a7930fe32f95cb90d1a /framework
parent6c679af722d80270413935b8081fbb4e149e95af (diff)
downloadorg.eclipse.ecf-415619f98512f5059c54841889e41ad5c2aa84f3.tar.gz
org.eclipse.ecf-415619f98512f5059c54841889e41ad5c2aa84f3.tar.xz
org.eclipse.ecf-415619f98512f5059c54841889e41ad5c2aa84f3.zip
New RSA API for simplifying distribution provider implementations
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF8
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRSAContainer.java75
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAConsumerContainerAdapter.java14
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAHostContainerAdapter.java24
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RSARemoteServiceContainerAdapter.java67
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java6
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java155
7 files changed, 345 insertions, 4 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF
index d9248efe6..c7bbef572 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF
@@ -2,17 +2,17 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.remoteservice
-Bundle-Version: 8.8.0.qualifier
+Bundle-Version: 8.9.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.remoteservice.Activator
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
Eclipse-LazyStart: true
Export-Package: org.eclipse.ecf.internal.remoteservice;x-internal:=true,
- org.eclipse.ecf.remoteservice;version="7.2.0",
- org.eclipse.ecf.remoteservice.client;version="8.0.0",
+ org.eclipse.ecf.remoteservice;version="7.3.0",
+ org.eclipse.ecf.remoteservice.client;version="8.1.0",
org.eclipse.ecf.remoteservice.events;version="6.0.0",
org.eclipse.ecf.remoteservice.provider;version="1.0.0",
- org.eclipse.ecf.remoteservice.util;version="8.1.0",
+ org.eclipse.ecf.remoteservice.util;version="8.2.0",
org.eclipse.ecf.remoteservice.util.tracker;version="6.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.equinox.common,
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRSAContainer.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRSAContainer.java
new file mode 100644
index 000000000..3771b1a15
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRSAContainer.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Composent, Inc. 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: Scott Lewis <slewis@composent.com> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.remoteservice;
+
+import java.util.Map;
+import org.eclipse.ecf.core.AbstractContainer;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.remoteservice.RSARemoteServiceContainerAdapter.RSARemoteServiceRegistration;
+
+/**
+ * @since 8.9
+ */
+public abstract class AbstractRSAContainer extends AbstractContainer {
+
+ private final ID id;
+ private final RSARemoteServiceContainerAdapter containerAdapter;
+
+ public AbstractRSAContainer(ID id) {
+ this.id = id;
+ this.containerAdapter = createContainerAdapter();
+ }
+
+ protected abstract Map<String, Object> registerEndpoint(RSARemoteServiceRegistration registration);
+
+ protected abstract void unregisterEndpoint(RSARemoteServiceRegistration registration);
+
+ protected RSARemoteServiceContainerAdapter createContainerAdapter() {
+ return new RSARemoteServiceContainerAdapter(this, new IRSAHostContainerAdapter() {
+ public void unregisterEndpoint(RSARemoteServiceRegistration registration) {
+ AbstractRSAContainer.this.unregisterEndpoint(registration);
+ }
+
+ public Map<String, Object> registerEndpoint(RSARemoteServiceRegistration registration) {
+ return AbstractRSAContainer.this.registerEndpoint(registration);
+ }
+ });
+ }
+
+ public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
+ throw new ContainerConnectException("Cannot connect this container"); //$NON-NLS-1$
+ }
+
+ public ID getConnectedID() {
+ return null;
+ }
+
+ public Namespace getConnectNamespace() {
+ return getID().getNamespace();
+ }
+
+ public void disconnect() {
+ // do nothing
+ }
+
+ public ID getID() {
+ return id;
+ }
+
+ @Override
+ public Object getAdapter(Class serviceType) {
+ Object result = super.getAdapter(serviceType);
+ if (result == null && serviceType.isAssignableFrom(IRemoteServiceContainerAdapter.class))
+ return containerAdapter;
+ return null;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAConsumerContainerAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAConsumerContainerAdapter.java
new file mode 100644
index 000000000..6871bc67e
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAConsumerContainerAdapter.java
@@ -0,0 +1,14 @@
+package org.eclipse.ecf.remoteservice;
+
+import java.util.Map;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * @since 8.9
+ */
+public interface IRSAConsumerContainerAdapter {
+
+ public IRemoteServiceReference[] importEndpoint(Map<String, Object> endpointDescriptionProperties) throws ContainerConnectException, InvalidSyntaxException;
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAHostContainerAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAHostContainerAdapter.java
new file mode 100644
index 000000000..9c4c84ed8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/IRSAHostContainerAdapter.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+* 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;
+
+import java.util.Map;
+import org.eclipse.ecf.remoteservice.RSARemoteServiceContainerAdapter.RSARemoteServiceRegistration;
+
+/**
+ * @since 8.9
+ */
+public interface IRSAHostContainerAdapter {
+
+ Map<String, Object> registerEndpoint(RSARemoteServiceRegistration registration);
+
+ void unregisterEndpoint(RSARemoteServiceRegistration registration);
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RSARemoteServiceContainerAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RSARemoteServiceContainerAdapter.java
new file mode 100644
index 000000000..a153ecec0
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RSARemoteServiceContainerAdapter.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* 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;
+
+import java.util.Dictionary;
+import java.util.Map;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.equinox.concurrent.future.IExecutor;
+
+/**
+ * @since 8.9
+ */
+public class RSARemoteServiceContainerAdapter extends RemoteServiceContainerAdapterImpl implements IRSAHostContainerAdapter {
+
+ private final IRSAHostContainerAdapter rsaAdapter;
+
+ public RSARemoteServiceContainerAdapter(IContainer container, IExecutor executor, IRSAHostContainerAdapter rsaAdapter) {
+ super(container, executor);
+ this.rsaAdapter = rsaAdapter;
+ }
+
+ public RSARemoteServiceContainerAdapter(IContainer container, IRSAHostContainerAdapter rsaAdapter) {
+ super(container);
+ this.rsaAdapter = rsaAdapter;
+ }
+
+ @Override
+ protected RemoteServiceRegistrationImpl createRegistration() {
+ return new RSARemoteServiceRegistration();
+ }
+
+ public class RSARemoteServiceRegistration extends RemoteServiceRegistrationImpl implements IExtendedRemoteServiceRegistration {
+ private static final long serialVersionUID = 3245045338579222364L;
+
+ private Map<String, Object> extraProperties;
+
+ @Override
+ public void publish(RemoteServiceRegistryImpl reg, Object svc, String[] clzzes, Dictionary props) {
+ super.publish(reg, svc, clzzes, props);
+ this.extraProperties = registerEndpoint(this);
+ }
+
+ public void unregister() {
+ unregisterEndpoint(this);
+ }
+
+ public Map<String, Object> getExtraProperties() {
+ return extraProperties;
+ }
+ }
+
+ public Map<String, Object> registerEndpoint(RSARemoteServiceRegistration registration) {
+ return (rsaAdapter != null) ? rsaAdapter.registerEndpoint(registration) : null;
+ }
+
+ public void unregisterEndpoint(RSARemoteServiceRegistration registration) {
+ if (rsaAdapter != null)
+ rsaAdapter.unregisterEndpoint(registration);
+ }
+}
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 7a6518013..53cf8df6b 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
@@ -393,4 +393,10 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
return this.remoteServiceID;
}
+ /**
+ * @since 8.9
+ */
+ public String[] getInterfaces() {
+ return this.clazzes;
+ }
}
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
new file mode 100644
index 000000000..87f093cb2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/client/AbstractRSAClientContainer.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+* 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.util.*;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.remoteservice.*;
+import org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent;
+import org.eclipse.ecf.remoteservice.util.EndpointDescriptionPropertiesUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * @since 8.9
+ */
+public abstract class AbstractRSAClientContainer extends AbstractClientContainer implements IRSAConsumerContainerAdapter {
+
+ public AbstractRSAClientContainer(ID containerID) {
+ super(containerID);
+ }
+
+ public boolean setRemoteServiceCallPolicy(IRemoteServiceCallPolicy policy) {
+ return false;
+ }
+
+ public Namespace getConnectNamespace() {
+ return getID().getNamespace();
+ }
+
+ private Long getServiceId(Map<String, Object> endpointDescriptionProperties) {
+ return EndpointDescriptionPropertiesUtil.verifyLongProperty(endpointDescriptionProperties, "endpoint.service.id"); //$NON-NLS-1$
+ }
+
+ private String getRemoteServiceFilter(Map<String, Object> endpointDescriptionProperties, Long rsId) {
+ String edRsFilter = EndpointDescriptionPropertiesUtil.verifyStringProperty(endpointDescriptionProperties, "ecf.endpoint.rsfilter"); //$NON-NLS-1$
+ // If it's *still* zero, then just use the raw filter
+ if (rsId == 0)
+ // It's not known...so we just return the 'raw' remote service
+ // filter
+ return edRsFilter;
+ // It's a real remote service id...so we return
+ StringBuffer result = new StringBuffer("(&(") //$NON-NLS-1$
+ .append(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID).append("=").append(rsId).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (edRsFilter != null)
+ result.append(edRsFilter);
+ result.append(")"); //$NON-NLS-1$
+ return result.toString();
+ }
+
+ protected void connectToEndpoint(ID connectTargetID) throws ContainerConnectException {
+ connect(connectTargetID, connectContext);
+ }
+
+ protected IRemoteCallable[][] createRegistrationCallables(ID targetID, String[] interfaces, Dictionary endpointDescriptionProperties) {
+ return new IRemoteCallable[][] {{RemoteCallableFactory.createCallable(getID().getName())}};
+ }
+
+ 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;
+ this.serviceID = new RemoteServiceID(getConnectNamespace(), this.containerId, (Long) properties.get(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID));
+ }
+ }
+
+ protected Dictionary createRegistrationProperties(Map<String, Object> endpointDescriptionProperties) {
+ return EndpointDescriptionPropertiesUtil.createDictionaryFromMap(endpointDescriptionProperties);
+ }
+
+ protected RemoteServiceClientRegistration createRSAClientRegistration(ID targetID, String[] interfaces, Map<String, Object> endpointDescriptionProperties) {
+ Dictionary d = createRegistrationProperties(endpointDescriptionProperties);
+ return new RSAClientRegistration(targetID, interfaces, createRegistrationCallables(targetID, interfaces, d), d);
+ }
+
+ public RemoteServiceClientRegistration registerEndpoint(ID targetID, String[] interfaces, Map<String, Object> endpointDescriptionProperties) {
+ final RemoteServiceClientRegistration registration = createRSAClientRegistration(targetID, interfaces, endpointDescriptionProperties);
+ this.registry.registerRegistration(registration);
+ // notify
+ fireRemoteServiceEvent(new IRemoteServiceRegisteredEvent() {
+
+ public IRemoteServiceReference getReference() {
+ return registration.getReference();
+ }
+
+ public ID getLocalContainerID() {
+ return registration.getContainerID();
+ }
+
+ public ID getContainerID() {
+ return getID();
+ }
+
+ public String[] getClazzes() {
+ return registration.getClazzes();
+ }
+ });
+ return registration;
+ }
+
+ public IRemoteServiceReference[] importEndpoint(Map<String, Object> endpointDescriptionProperties) throws ContainerConnectException, InvalidSyntaxException {
+ // ecf.endpoint.id
+ String ecfid = EndpointDescriptionPropertiesUtil.verifyStringProperty(endpointDescriptionProperties, "ecf.endpoint.id"); //$NON-NLS-1$
+ if (ecfid == null)
+ ecfid = EndpointDescriptionPropertiesUtil.verifyStringProperty(endpointDescriptionProperties, "endpoint.id"); //$NON-NLS-1$
+ // ecf.endpoint.ts
+ Long timestamp = EndpointDescriptionPropertiesUtil.verifyLongProperty(endpointDescriptionProperties, "ecf.endpoint.ts"); //$NON-NLS-1$
+ if (timestamp == null)
+ timestamp = getServiceId(endpointDescriptionProperties);
+ // ecf.endpoint.ns
+ String idNamespace = EndpointDescriptionPropertiesUtil.verifyStringProperty(endpointDescriptionProperties, "ecf.endpoint.id.ns"); //$NON-NLS-1$
+ // Create/verify endpointContainerID
+ ID endpointContainerID = EndpointDescriptionPropertiesUtil.verifyIDProperty(idNamespace, ecfid);
+ // Get rsId
+ Long rsId = EndpointDescriptionPropertiesUtil.verifyLongProperty(endpointDescriptionProperties, Constants.SERVICE_ID);
+ // if null, then set to service.id
+ if (rsId == null)
+ rsId = EndpointDescriptionPropertiesUtil.verifyLongProperty(endpointDescriptionProperties, "endpoint.service.id"); //$NON-NLS-1$
+ // Get connectTargetID
+ ID connectTargetID = EndpointDescriptionPropertiesUtil.verifyIDProperty(idNamespace, EndpointDescriptionPropertiesUtil.verifyStringProperty(endpointDescriptionProperties, "ecf.endpoint.connecttarget.id")); //$NON-NLS-1$
+ // If not explicitly set, then set to endpointContainerID
+ if (connectTargetID == null)
+ connectTargetID = endpointContainerID;
+ // Get idFilter
+ ID[] idFilter = EndpointDescriptionPropertiesUtil.verifyIDArray(endpointDescriptionProperties, "ecf.endpoint.idfilter.ids", idNamespace); //$NON-NLS-1$
+ // If not set, then set to endpointContainerID
+ idFilter = (idFilter == null) ? new ID[] {endpointContainerID} : idFilter;
+ // Get rsFilter
+ String rsFilter = getRemoteServiceFilter(endpointDescriptionProperties, rsId);
+ // Get interfaces
+ List<String> interfaces = EndpointDescriptionPropertiesUtil.verifyObjectClassProperty(endpointDescriptionProperties);
+ // register locally
+ registerEndpoint(connectTargetID, interfaces.toArray(new String[interfaces.size()]), endpointDescriptionProperties);
+ // If we have a non-null targetID we connect
+ if (connectTargetID != null)
+ connectToEndpoint(connectTargetID);
+ return getRemoteServiceReferences(idFilter, interfaces.iterator().next(), rsFilter);
+ }
+
+ @Override
+ protected abstract IRemoteService createRemoteService(RemoteServiceClientRegistration registration);
+
+ @Override
+ protected String prepareEndpointAddress(IRemoteCall call, IRemoteCallable callable) {
+ return null;
+ }
+
+}

Back to the top