Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-10-25 16:58:49 +0000
committermkuppe2008-10-25 16:58:49 +0000
commit83cdba103ddc0fe4a89fa1e089d702b0c456c2b8 (patch)
treefce65c4adb420c93cdd191d4bc2af05445e70dbb
parentd747b6f0a365b2ad513e304270c4281b18bfc9cf (diff)
downloadorg.eclipse.ecf-20081027-0800.tar.gz
org.eclipse.ecf-20081027-0800.tar.xz
org.eclipse.ecf-20081027-0800.zip
NEW - bug 252093: [Discovery][Composite] Composite doesn't throw Exception on second connectv20081027-0800
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252093
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/Messages.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/messages.properties3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java37
3 files changed, 27 insertions, 16 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 a5c5886f1..1897e92d6 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
@@ -14,8 +14,11 @@ 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$
+ public static String CompositeDiscoveryContainer_AlreadyConnected;
public static String CompositeDiscoveryContainer_DEPRECATED;
public static String CompositeDiscoveryContainerInstantiator;
+ public static String CompositeNamespace_WrongParameterCount;
+ public static String CompositeNamespace_WrongParameters;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/messages.properties b/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/messages.properties
index 637b872fb..08ba97adc 100644
--- a/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/messages.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.discovery/src/org/eclipse/ecf/internal/provider/discovery/messages.properties
@@ -1,2 +1,5 @@
CompositeDiscoveryContainerInstantiator=Exception making Composite container
+CompositeDiscoveryContainer_AlreadyConnected=Already connected
CompositeDiscoveryContainer_DEPRECATED=deprecated API isn't supported by CompositeContainer
+CompositeNamespace_WrongParameterCount=Wrong parameter count
+CompositeNamespace_WrongParameters=Wrong parameters
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 b543bb46d..de6289cc5 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
@@ -11,10 +11,10 @@
package org.eclipse.ecf.provider.discovery;
import java.util.*;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.events.ContainerDisconnectedEvent;
-import org.eclipse.ecf.core.events.ContainerDisconnectingEvent;
+import org.eclipse.ecf.core.events.*;
import org.eclipse.ecf.core.identity.*;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.util.ECFException;
@@ -22,8 +22,7 @@ import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.discovery.*;
import org.eclipse.ecf.discovery.identity.*;
import org.eclipse.ecf.discovery.service.IDiscoveryService;
-import org.eclipse.ecf.internal.provider.discovery.Activator;
-import org.eclipse.ecf.internal.provider.discovery.CompositeNamespace;
+import org.eclipse.ecf.internal.provider.discovery.*;
public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapter implements IDiscoveryService {
@@ -88,7 +87,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
}
}
// add ourself as a listener to the underlying providers. This might
- // trigger a serviceAdded already
+ // trigger a serviceAdded alread
IServiceTypeID istid = event.getServiceTypeID();
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
@@ -111,6 +110,8 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
protected final List containers;
+ private ID targetID;
+
/**
* @param containers
* @throws IDCreateException
@@ -123,7 +124,12 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
/* (non-Javadoc)
* @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, org.eclipse.ecf.core.security.IConnectContext)
*/
- public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
+ public void connect(ID aTargetID, IConnectContext connectContext) throws ContainerConnectException {
+ if (targetID != null || getConfig() == null) {
+ throw new ContainerConnectException(Messages.CompositeDiscoveryContainer_AlreadyConnected);
+ }
+ targetID = (aTargetID == null) ? getConfig().getID() : aTargetID;
+ fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID, connectContext));
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IContainer container = (IContainer) itr.next();
@@ -135,6 +141,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
idca.addServiceTypeListener(ccstl);
}
}
+ fireContainerEvent(new ContainerConnectedEvent(this.getID(), targetID));
}
/* (non-Javadoc)
@@ -142,6 +149,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
*/
public void disconnect() {
fireContainerEvent(new ContainerDisconnectingEvent(this.getID(), getConnectedID()));
+ targetID = null;
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IContainer container = (IContainer) itr.next();
@@ -169,15 +177,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
* @see org.eclipse.ecf.core.IContainer#getConnectedID()
*/
public ID getConnectedID() {
- return getID();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter#getConnectNamespace()
- */
- public Namespace getConnectNamespace() {
- //TODO-mkuppe implement CompositeDiscoveryContainer#getConnectNamespace
- throw new java.lang.UnsupportedOperationException("CompositeDiscoveryContainer#getConnectNamespace not yet implemented"); //$NON-NLS-1$
+ return targetID;
}
private IServiceID getServiceIDForDiscoveryContainer(IServiceID service, IDiscoveryContainerAdapter dca) {
@@ -196,6 +196,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
*/
public IServiceInfo getServiceInfo(IServiceID aService) {
+ Assert.isNotNull(aService);
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IDiscoveryContainerAdapter idca = (IDiscoveryContainerAdapter) itr.next();
@@ -233,6 +234,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
*/
public IServiceInfo[] getServices(IServiceTypeID type) {
+ Assert.isNotNull(type);
Set set = new HashSet();
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
@@ -249,7 +251,8 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
Namespace connectNamespace = dca.getServicesNamespace();
if (!connectNamespace.equals(type.getNamespace())) {
try {
- return (IServiceTypeID) connectNamespace.createInstance(new Object[] {type});
+ IServiceID serviceID = (IServiceID) connectNamespace.createInstance(new Object[] {type, null});
+ return serviceID.getServiceTypeID();
} catch (IDCreateException e) {
Trace.catching(Activator.PLUGIN_ID, METHODS_CATCHING, this.getClass(), "getServiceTypeIDForDiscoveryContainer", e); //$NON-NLS-1$
}
@@ -276,6 +279,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
*/
public void registerService(IServiceInfo serviceInfo) throws ECFException {
+ Assert.isNotNull(serviceInfo);
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IDiscoveryContainerAdapter dca = (IDiscoveryContainerAdapter) itr.next();
@@ -291,6 +295,7 @@ public class CompositeDiscoveryContainer extends AbstractDiscoveryContainerAdapt
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
*/
public void unregisterService(IServiceInfo serviceInfo) throws ECFException {
+ Assert.isNotNull(serviceInfo);
synchronized (containers) {
for (Iterator itr = containers.iterator(); itr.hasNext();) {
IDiscoveryContainerAdapter idca = (IDiscoveryContainerAdapter) itr.next();

Back to the top