Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-11-07 14:35:33 -0500
committermkuppe2008-11-07 14:35:33 -0500
commitd64bbcec0967bcd4d8e6d7abf6b57b46cd904bed (patch)
treefe690fe9a14ca3a2ed42e5316ebe07c184e4089c
parentbf18b9e3459bc398c768b2a883977dda48e7ba81 (diff)
downloadorg.eclipse.ecf-d64bbcec0967bcd4d8e6d7abf6b57b46cd904bed.tar.gz
org.eclipse.ecf-d64bbcec0967bcd4d8e6d7abf6b57b46cd904bed.tar.xz
org.eclipse.ecf-d64bbcec0967bcd4d8e6d7abf6b57b46cd904bed.zip
NEW - bug 236828: [Discovery] Composite container may register previously registered services with new providers
https://bugs.eclipse.org/bugs/show_bug.cgi?id=236828
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/Messages.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java35
2 files changed, 34 insertions, 3 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/Messages.java b/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/Messages.java
index 1897e92d6..f464d2e80 100644
--- a/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/Messages.java
@@ -13,7 +13,7 @@ package org.eclipse.ecf.internal.provider.discovery;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.discovery.messages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.provider.discovery.messages"; //$NON-NLS-1$
public static String CompositeDiscoveryContainer_AlreadyConnected;
public static String CompositeDiscoveryContainer_DEPRECATED;
public static String CompositeDiscoveryContainerInstantiator;
diff --git a/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java b/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java
index de6289cc5..f7ad9fb1e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java
@@ -101,13 +101,20 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
}
}
- private static final String METHODS_CATCHING = Activator.PLUGIN_ID + "/debug/methods/catching"; //$NON-NLS-1$
+ protected static final String METHODS_CATCHING = Activator.PLUGIN_ID + "/debug/methods/catching"; //$NON-NLS-1$
- private static final String METHODS_TRACING = Activator.PLUGIN_ID + "/debug/methods/tracing"; //$NON-NLS-1$
+ protected static final String METHODS_TRACING = Activator.PLUGIN_ID + "/debug/methods/tracing"; //$NON-NLS-1$
protected final CompositeContainerServiceListener ccsl = new CompositeContainerServiceListener();
protected final CompositeContainerServiceTypeListener ccstl = new CompositeContainerServiceTypeListener();
+ /**
+ * History of services registered with this IDCA
+ *
+ * Used on newly added IDCAs
+ */
+ protected Set registeredServices;
+
protected final List containers;
private ID targetID;
@@ -119,6 +126,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
public CompositeDiscoveryContainer(List containers) throws IDCreateException {
super(CompositeNamespace.NAME, new DiscoveryContainerConfig(IDFactory.getDefault().createStringID(CompositeDiscoveryContainer.class.getName())));
this.containers = containers;
+ this.registeredServices = new HashSet();
}
/* (non-Javadoc)
@@ -156,6 +164,9 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
container.disconnect();
}
}
+ synchronized (registeredServices) {
+ registeredServices.clear();
+ }
fireContainerEvent(new ContainerDisconnectedEvent(this.getID(), getConnectedID()));
}
@@ -280,6 +291,9 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
*/
public void registerService(IServiceInfo serviceInfo) throws ECFException {
Assert.isNotNull(serviceInfo);
+ synchronized (registeredServices) {
+ Assert.isTrue(registeredServices.add(serviceInfo));
+ }
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IDiscoveryContainerAdapter dca = (IDiscoveryContainerAdapter) itr.next();
@@ -296,6 +310,10 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
*/
public void unregisterService(IServiceInfo serviceInfo) throws ECFException {
Assert.isNotNull(serviceInfo);
+ synchronized (registeredServices) {
+ // no assert as unregisterService might be called with an non-existing ISI
+ registeredServices.remove(serviceInfo);
+ }
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IDiscoveryContainerAdapter idca = (IDiscoveryContainerAdapter) itr.next();
@@ -311,6 +329,19 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
* @see java.util.List#add(java.lang.Object)
*/
public boolean addContainer(Object object) {
+ // register previously registered with the new IDS
+ synchronized (registeredServices) {
+ IDiscoveryContainerAdapter idca = (IDiscoveryContainerAdapter) object;
+ for (Iterator itr = registeredServices.iterator(); itr.hasNext();) {
+ IServiceInfo serviceInfo = (IServiceInfo) itr.next();
+ try {
+ idca.registerService(serviceInfo);
+ } catch (ECFException e) {
+ // we eat the exception here since the original registerService call is long done
+ Trace.catching(Activator.PLUGIN_ID, METHODS_CATCHING, this.getClass(), "addContainer(Object)", e); //$NON-NLS-1$
+ }
+ }
+ }
synchronized (containers) {
Trace.trace(Activator.PLUGIN_ID, METHODS_TRACING, this.getClass(), "addContainer(Object)", "addContainer " //$NON-NLS-1$ //$NON-NLS-2$
+ object.toString());

Back to the top