Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-09-03 17:23:37 +0000
committerslewis2015-09-03 17:23:37 +0000
commit4737a1947fd8c32601ed930a4a82d30aab0a487c (patch)
tree766807d2bac05a0a8e8343d94b943ed42c877b35 /framework
parentc399657803dadaabc9f1412d53a2c7afde6c2522 (diff)
downloadorg.eclipse.ecf-4737a1947fd8c32601ed930a4a82d30aab0a487c.tar.gz
org.eclipse.ecf-4737a1947fd8c32601ed930a4a82d30aab0a487c.tar.xz
org.eclipse.ecf-4737a1947fd8c32601ed930a4a82d30aab0a487c.zip
Additions and generalizations for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=475426 Change-Id: Id97839c4a5e5c65e1cd32449d487615ee882a396
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/internal/remoteservice/Activator.java23
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/AdapterConfig.java7
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/IRemoteServiceDistributionProvider.java42
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java6
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceDistributionProvider.java26
5 files changed, 82 insertions, 22 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/internal/remoteservice/Activator.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/internal/remoteservice/Activator.java
index 4f2e36442..2897fa3f7 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/internal/remoteservice/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/internal/remoteservice/Activator.java
@@ -101,7 +101,7 @@ public class Activator implements BundleActivator {
// If not null
if (dProvider != null) {
// Get ContainerTypeDescription
- ContainerTypeDescription ctd = dProvider.createContainerTypeDescription();
+ ContainerTypeDescription ctd = dProvider.getContainerTypeDescription();
if (ctd == null)
log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Remote Service Provider Container Type Description cannot be null")); //$NON-NLS-1$
else {
@@ -109,7 +109,7 @@ public class Activator implements BundleActivator {
// Register the container type description
ServiceRegistration<ContainerTypeDescription> ctdSR = bundleContext.registerService(ContainerTypeDescription.class, ctd, ctdProps);
// Now process namespace
- Namespace ns = dProvider.createNamespace();
+ Namespace ns = dProvider.getNamespace();
ServiceRegistration<Namespace> nsSR = null;
if (ns != null)
nsSR = bundleContext.registerService(Namespace.class, ns, dProvider.getNamespaceProperties());
@@ -119,15 +119,18 @@ public class Activator implements BundleActivator {
if (am == null)
log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "No adapter manager available for remote service containers")); //$NON-NLS-1$
// Now get AdapterConfig
- AdapterConfig adapterConfig = dProvider.createAdapterConfig();
+ AdapterConfig[] adapterConfigs = dProvider.getAdapterConfigs();
IAdapterFactory adapterFactory = null;
- if (adapterConfig != null) {
- adapterFactory = adapterConfig.getAdapterFactory();
- Class<?> adapterClass = adapterConfig.getAdaptable();
- if (adapterFactory == null || adapterClass == null)
- log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid adapter config for distribution provider=" + ctd.getName())); //$NON-NLS-1$
- // Now register adapters
- am.registerAdapters(adapterFactory, adapterClass);
+ if (adapterConfigs != null) {
+ for (AdapterConfig adapterConfig : adapterConfigs) {
+ adapterFactory = adapterConfig.getAdapterFactory();
+ Class<?> adapterClass = adapterConfig.getAdaptable();
+ if (adapterFactory == null || adapterClass == null)
+ log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid adapter config for distribution provider=" + ctd.getName())); //$NON-NLS-1$
+ // Now register adapters
+ else
+ am.registerAdapters(adapterFactory, adapterClass);
+ }
}
if (ctdSR != null)
svcRefToDSDPRegMap.put(reference, new RSDPRegistrations(ctdSR, nsSR, adapterFactory));
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/AdapterConfig.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/AdapterConfig.java
index 947b52127..77cd7c2d3 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/AdapterConfig.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/AdapterConfig.java
@@ -12,12 +12,19 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdapterFactory;
/**
+ * An adapter config is used to setup an adaptable.
* @since 8.7
*/
public class AdapterConfig {
private final IAdapterFactory adapterFactory;
private final Class<?> adaptable;
+ /**
+ *
+ * @param adapterFactory the adapter factory to use for the given adaptable. Must not be <code>null</code>
+ * @param adaptable the Class that the adapterFactory is to use as the adaptable.
+ * Must not be <code>null</code>.
+ */
public AdapterConfig(IAdapterFactory adapterFactory, Class<?> adaptable) {
this.adapterFactory = adapterFactory;
Assert.isNotNull(this.adapterFactory);
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/IRemoteServiceDistributionProvider.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/IRemoteServiceDistributionProvider.java
index 3160751f8..fff991e8d 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/IRemoteServiceDistributionProvider.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/IRemoteServiceDistributionProvider.java
@@ -17,17 +17,51 @@ import org.eclipse.ecf.core.identity.Namespace;
* A service interface for distribution providers. When instances of this interface are registered, they result in the
* two methods below being called by the org.eclipse.ecf.remoteservice bundle, with the BundleContext from
* the org.eclipse.ecf.remoteservice bundle. Intended to be implemented by remote service distribution provider
- * implementations.
+ * implementations. When instance of this service interface is registered, the methods below will be called
+ * in order to register the ContainerTypeDescription, Namespace, and AdapterConfig for this distribution
+ * provider.
*/
public interface IRemoteServiceDistributionProvider {
- ContainerTypeDescription createContainerTypeDescription();
+ /**
+ * Return the ContainerTypeDescription to register for this distribution provider.
+ * The returned ContainerTypeDescription must not be <code>null</code> and
+ * should be unique identified via it's name (obtained via {@link ContainerTypeDescription#getName()}.
+ *
+ * @return ContainerTypeDescription. Must not be <code>null</code>.
+ */
+ ContainerTypeDescription getContainerTypeDescription();
+ /**
+ * Return any properties that are to be used when registering the ContainerTypeDescription
+ * returned by above method. <code>Null</code> may be returned.
+ * @return Dictionary<String, ?> to use when registering the ContainerTypeDescription.
+ * May be <code>null</code>.
+ */
Dictionary<String, ?> getContainerTypeDescriptionProperties();
- Namespace createNamespace();
+ /**
+ * Return the Namespace (or subclass) to register for this distribution provider.
+ * The returned Namespace may be <code>null</code>. In that case, no
+ * new Namespace will be registered. If the returned Namespace is non-null,
+ * It should be uniquely identified via it's name (obtained via {@link Namespace#getName()}.
+ *
+ * @return ContainerTypeDescription. May be <code>null</code>.
+ */
+ Namespace getNamespace();
+ /**
+ * Return any properties that are to be used when registering the Namespace
+ * returned by above method. <code>Null</code> may be returned.
+ * @return Dictionary<String, ?> to use when registering this provider's Namespace.
+ * May be <code>null</code>.
+ */
Dictionary<String, ?> getNamespaceProperties();
- AdapterConfig createAdapterConfig();
+ /**
+ * Return any AdapterConfigs to register with the IAdapterManager
+ * @return AdapterConfig[] holding any AdapterConfigs to be registered
+ * with the system-wide adaptermanager.
+ */
+ AdapterConfig[] getAdapterConfigs();
}
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
index a893a949f..7262b4237 100644
--- 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
@@ -72,4 +72,10 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn
public IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException {
return createInstance(description, getMap(parameters));
}
+
+ protected IContainer throwCreateException(String message, Throwable cause) throws ContainerCreateException {
+ ContainerCreateException cce = new ContainerCreateException(message, cause);
+ cce.setStackTrace(cause.getStackTrace());
+ throw cce;
+ }
}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceDistributionProvider.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceDistributionProvider.java
index dc454c26e..630cbd079 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceDistributionProvider.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceDistributionProvider.java
@@ -8,7 +8,7 @@
******************************************************************************/
package org.eclipse.ecf.remoteservice.provider;
-import java.util.Dictionary;
+import java.util.*;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.ContainerTypeDescription;
import org.eclipse.ecf.core.identity.Namespace;
@@ -30,7 +30,7 @@ public class RemoteServiceDistributionProvider implements IRemoteServiceDistribu
private Dictionary<String, ?> ctdProperties;
private Namespace namespace;
private Dictionary<String, ?> nsProperties;
- private AdapterConfig adapterConfig;
+ private List<AdapterConfig> adapterConfigs = new ArrayList<AdapterConfig>();
/**
* Builder for RemoteServiceDistributionProvider instances
@@ -89,6 +89,11 @@ public class RemoteServiceDistributionProvider implements IRemoteServiceDistribu
return this;
}
+ public Builder addAdapterConfig(AdapterConfig adapterConfig) {
+ this.instance.addAdapterConfig(adapterConfig);
+ return this;
+ }
+
public RemoteServiceDistributionProvider build() {
this.instance.validateComplete();
return this.instance;
@@ -175,9 +180,14 @@ public class RemoteServiceDistributionProvider implements IRemoteServiceDistribu
return this;
}
+ protected RemoteServiceDistributionProvider addAdapterConfig(AdapterConfig adapterConfig) {
+ Assert.isNotNull(adapterConfig);
+ this.adapterConfigs.add(adapterConfig);
+ return this;
+ }
+
protected RemoteServiceDistributionProvider setAdapterConfig(AdapterConfig adapterConfig) {
- this.adapterConfig = adapterConfig;
- Assert.isNotNull(this.adapterConfig);
+ addAdapterConfig(adapterConfig);
return this;
}
@@ -190,7 +200,7 @@ public class RemoteServiceDistributionProvider implements IRemoteServiceDistribu
throw new NullPointerException("Container type description instantiator cannot be null"); //$NON-NLS-1$
}
- public ContainerTypeDescription createContainerTypeDescription() {
+ public ContainerTypeDescription getContainerTypeDescription() {
validateComplete();
return new ContainerTypeDescription(getName(), getInstantiator(), getDescription(), isServer(), isHidden());
}
@@ -199,7 +209,7 @@ public class RemoteServiceDistributionProvider implements IRemoteServiceDistribu
return ctdProperties;
}
- public Namespace createNamespace() {
+ public Namespace getNamespace() {
return namespace;
}
@@ -207,7 +217,7 @@ public class RemoteServiceDistributionProvider implements IRemoteServiceDistribu
return nsProperties;
}
- public AdapterConfig createAdapterConfig() {
- return adapterConfig;
+ public AdapterConfig[] getAdapterConfigs() {
+ return adapterConfigs.toArray(new AdapterConfig[adapterConfigs.size()]);
}
}

Back to the top