Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-09-02 21:56:56 +0000
committerslewis2015-09-02 21:56:56 +0000
commit85624166f52d33ccbe9c2a6570b35a747dcdef91 (patch)
tree217a722d25ceccc1c9c441ce11bb0bf7294a9c4a
parent75fc2aceca63b7c78ad954d85c974faeffe41618 (diff)
downloadorg.eclipse.ecf-85624166f52d33ccbe9c2a6570b35a747dcdef91.tar.gz
org.eclipse.ecf-85624166f52d33ccbe9c2a6570b35a747dcdef91.tar.xz
org.eclipse.ecf-85624166f52d33ccbe9c2a6570b35a747dcdef91.zip
Additions of helper classes for provider API
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/PeerRemoteServiceContainerInstantiator.java19
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java71
2 files changed, 90 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/PeerRemoteServiceContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/PeerRemoteServiceContainerInstantiator.java
new file mode 100644
index 000000000..7327b9195
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/PeerRemoteServiceContainerInstantiator.java
@@ -0,0 +1,19 @@
+package org.eclipse.ecf.remoteservice.provider;
+
+import java.util.*;
+
+/**
+ * @since 8.7
+ */
+public abstract class PeerRemoteServiceContainerInstantiator extends RemoteServiceContainerInstantiator {
+
+ public PeerRemoteServiceContainerInstantiator(String peerA, String peerB) {
+ this.exporterConfigs = new ArrayList<String>();
+ this.exporterConfigs.add(peerA);
+ this.exporterConfigs.add(peerB);
+ this.exporterConfigToImporterConfigs = new HashMap<String, List<String>>();
+ this.exporterConfigToImporterConfigs.put(peerA, Arrays.asList(new String[] {peerA, peerB}));
+ this.exporterConfigToImporterConfigs.put(peerB, Arrays.asList(new String[] {peerA, peerB}));
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java
new file mode 100644
index 000000000..f95cc6aa8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java
@@ -0,0 +1,71 @@
+package org.eclipse.ecf.remoteservice.provider;
+
+import java.util.*;
+import org.eclipse.ecf.core.*;
+import org.eclipse.ecf.core.provider.BaseContainerInstantiator;
+import org.eclipse.ecf.core.provider.IRemoteServiceContainerInstantiator;
+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
+
+/**
+ * @since 8.7
+ */
+public abstract class RemoteServiceContainerInstantiator extends BaseContainerInstantiator implements IRemoteServiceContainerInstantiator {
+
+ protected static final String[] defaultSupportedAdapterTypes = new String[] {IRemoteServiceContainerAdapter.class.getName()};
+ protected static final Class[][] defaultSupportedParameterTypes = new Class[][] {{Map.class}};
+
+ protected static final String[] defaultSupportedIntents = new String[] {"passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ public String[] getSupportedAdapterTypes(ContainerTypeDescription description) {
+ return defaultSupportedAdapterTypes;
+ }
+
+ public Class[][] getSupportedParameterTypes(ContainerTypeDescription description) {
+ return defaultSupportedParameterTypes;
+ }
+
+ public String[] getSupportedIntents(ContainerTypeDescription description) {
+ return defaultSupportedIntents;
+ }
+
+ protected List<String> exporterConfigs;
+ protected Map<String, List<String>> exporterConfigToImporterConfigs;
+
+ protected RemoteServiceContainerInstantiator(List<String> exporterConfigs, Map<String, List<String>> exporterConfigToImporterConfig) {
+ this.exporterConfigs = (exporterConfigs == null) ? new ArrayList<String>() : exporterConfigs;
+ this.exporterConfigToImporterConfigs = (exporterConfigToImporterConfig == null) ? new HashMap<String, List<String>>() : exporterConfigToImporterConfig;
+ }
+
+ protected RemoteServiceContainerInstantiator() {
+ this.exporterConfigs = new ArrayList<String>();
+ this.exporterConfigToImporterConfigs = new HashMap<String, List<String>>();
+ }
+
+ public String[] getSupportedConfigs(ContainerTypeDescription description) {
+ List<String> results = new ArrayList<String>();
+ String descriptionName = description.getName();
+ if (this.exporterConfigs.contains(descriptionName))
+ results.add(descriptionName);
+ return results.toArray(new String[results.size()]);
+ }
+
+ public String[] getImportedConfigs(ContainerTypeDescription description, String[] exporterSupportedConfigs) {
+ if (exporterSupportedConfigs == null)
+ return null;
+ List<String> results = new ArrayList<String>();
+ for (String exporterConfig : exporterSupportedConfigs) {
+ List<String> importerConfigs = exporterConfigToImporterConfigs.get(exporterConfig);
+ if (importerConfigs != null)
+ for (String importerConfig : importerConfigs)
+ if (description.getName().equals(importerConfig))
+ results.add(importerConfig);
+ }
+ return results.toArray(new String[results.size()]);
+ }
+
+ public Dictionary getPropertiesForImportedConfigs(ContainerTypeDescription description, String[] importedConfigs, Dictionary exportedProperties) {
+ return null;
+ }
+
+ public abstract IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException;
+}

Back to the top