Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2007-11-29 07:11:02 -0500
committermkuppe2007-11-29 07:11:02 -0500
commitc8d1453fa7b7adfc2ab3fcc814f39db0298f6bec (patch)
tree09861e42b7ddfc51d20b818897368601d376216e /examples
parent5fa432067851feaba825caf624f9b373157b0035 (diff)
downloadorg.eclipse.ecf-c8d1453fa7b7adfc2ab3fcc814f39db0298f6bec.tar.gz
org.eclipse.ecf-c8d1453fa7b7adfc2ab3fcc814f39db0298f6bec.tar.xz
org.eclipse.ecf-c8d1453fa7b7adfc2ab3fcc814f39db0298f6bec.zip
ASSIGNED - bug 209774: Simplify/generalize discovery API (summary bug)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209774
Diffstat (limited to 'examples')
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/DiscoveryStartup.java20
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/start/Discovery.java27
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/CollabDiscoveryView.java24
3 files changed, 27 insertions, 44 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/DiscoveryStartup.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/DiscoveryStartup.java
index ec9a79b5a..5aa7e1071 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/DiscoveryStartup.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/DiscoveryStartup.java
@@ -10,7 +10,6 @@
*****************************************************************************/
package org.eclipse.ecf.internal.example.collab;
-import java.net.InetAddress;
import java.net.URI;
import java.util.Properties;
@@ -19,7 +18,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.ContainerFactory;
import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
@@ -29,9 +27,7 @@ import org.eclipse.ecf.discovery.IServiceProperties;
import org.eclipse.ecf.discovery.ServiceInfo;
import org.eclipse.ecf.discovery.ServiceProperties;
import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.discovery.identity.ServiceIDFactory;
import org.eclipse.ecf.internal.example.collab.actions.URIClientConnectAction;
-import org.eclipse.osgi.util.NLS;
public class DiscoveryStartup {
public static final String DISCOVERY_CONTAINER = "ecf.discovery.jmdns";
@@ -126,13 +122,10 @@ public class DiscoveryStartup {
props.setProperty(PROP_PW_REQ_NAME, PROP_PW_REQ_VALUE);
props.setProperty(PROP_DEF_USER_NAME, PROP_DEF_USER_VALUE);
props.setProperty(PROP_PATH_NAME, path);
- final InetAddress host = InetAddress.getByName(uri.getHost());
- final int port = uri.getPort();
final String svcName = System.getProperty("user.name") + "." + protocol;
final Namespace namespace = IDFactory.getDefault().getNamespaceByName("zeroconf.jmdns");
final IServiceID srvID = (IServiceID) namespace.createInstance(new String[] {ClientPlugin.TCPSERVER_DISCOVERY_TYPE, svcName});
-
- final ServiceInfo svcInfo = new ServiceInfo(host, srvID, port, SVC_DEF_PRIORITY, SVC_DEF_WEIGHT, new ServiceProperties(props));
+ final ServiceInfo svcInfo = new ServiceInfo(uri, srvID, SVC_DEF_PRIORITY, SVC_DEF_WEIGHT, new ServiceProperties(props));
discovery.registerService(svcInfo);
} catch (final Exception e) {
ClientPlugin.log("Exception registering service " + uri, e);
@@ -145,15 +138,4 @@ public class DiscoveryStartup {
public static void unregisterServer(ISharedObjectContainer container) {
}
- public static void registerServiceTypes() {
- if (discovery != null) {
- for (int i = 0; i < ClientPlugin.serviceTypes.length; i++) {
- try {
- discovery.registerServiceType(ServiceIDFactory.getDefault().createServiceID(discovery.getServicesNamespace(), ClientPlugin.serviceTypes[i]).getServiceTypeID());
- } catch (final IDCreateException e) {
- ClientPlugin.log(NLS.bind("Cannot register service type {0}", ClientPlugin.serviceTypes[i]));
- }
- }
- }
- }
}
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/start/Discovery.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/start/Discovery.java
index 5476837e5..eb9784c5c 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/start/Discovery.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/start/Discovery.java
@@ -15,8 +15,8 @@ import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
import org.eclipse.ecf.discovery.IServiceEvent;
import org.eclipse.ecf.discovery.IServiceListener;
+import org.eclipse.ecf.discovery.IServiceTypeEvent;
import org.eclipse.ecf.discovery.IServiceTypeListener;
-import org.eclipse.ecf.discovery.identity.IServiceID;
public class Discovery {
@@ -35,22 +35,29 @@ public class Discovery {
}
class CollabServiceTypeListener implements IServiceTypeListener {
- public void serviceTypeAdded(IServiceEvent event) {
- final IServiceID svcID = event.getServiceInfo().getServiceID();
- discoveryContainer.addServiceListener(svcID.getServiceTypeID(), new CollabServiceListener());
- discoveryContainer.registerServiceType(svcID.getServiceTypeID());
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IServiceTypeListener#serviceTypeDiscovered(org.eclipse.ecf.discovery.IServiceTypeEvent)
+ */
+ public void serviceTypeDiscovered(IServiceTypeEvent event) {
+ discoveryContainer.addServiceListener(event.getServiceTypeID(), new CollabServiceListener());
}
}
class CollabServiceListener implements IServiceListener {
- public void serviceAdded(IServiceEvent event) {
- discoveryContainer.requestServiceInfo(event.getServiceInfo().getServiceID(), 3000);
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IServiceListener#serviceDiscovered(org.eclipse.ecf.discovery.IServiceEvent)
+ */
+ public void serviceDiscovered(IServiceEvent anEvent) {
+ // TODO Auto-generated method stub
- public void serviceRemoved(IServiceEvent event) {
}
- public void serviceResolved(IServiceEvent event) {
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IServiceListener#serviceUndiscovered(org.eclipse.ecf.discovery.IServiceEvent)
+ */
+ public void serviceUndiscovered(IServiceEvent anEvent) {
+ // TODO Auto-generated method stub
+
}
}
}
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/CollabDiscoveryView.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/CollabDiscoveryView.java
index bf7a34a24..34418583c 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/CollabDiscoveryView.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/CollabDiscoveryView.java
@@ -13,8 +13,8 @@ package org.eclipse.ecf.internal.example.collab.ui;
import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
import org.eclipse.ecf.discovery.IServiceEvent;
import org.eclipse.ecf.discovery.IServiceListener;
+import org.eclipse.ecf.discovery.IServiceTypeEvent;
import org.eclipse.ecf.discovery.IServiceTypeListener;
-import org.eclipse.ecf.discovery.identity.IServiceID;
import org.eclipse.ecf.discovery.ui.views.DiscoveryView;
import org.eclipse.ecf.discovery.ui.views.IDiscoveryController;
import org.eclipse.ecf.internal.example.collab.ClientPlugin;
@@ -38,24 +38,18 @@ public class CollabDiscoveryView extends DiscoveryView {
if (dc != null) {
// setup listeners
dc.addServiceTypeListener(new IServiceTypeListener() {
- public void serviceTypeAdded(IServiceEvent event) {
- final IServiceID svcID = event.getServiceInfo().getServiceID();
- addServiceTypeInfo(svcID.getServiceTypeID().getName());
- dc.addServiceListener(event.getServiceInfo().getServiceID().getServiceTypeID(), new IServiceListener() {
- public void serviceAdded(IServiceEvent evt) {
- addServiceInfo(evt.getServiceInfo().getServiceID());
- dc.requestServiceInfo(evt.getServiceInfo().getServiceID(), SERVICE_REQUEST_TIMEOUT);
+ public void serviceTypeDiscovered(IServiceTypeEvent event) {
+ addServiceTypeInfo(event.getServiceTypeID().getName());
+ dc.addServiceListener(event.getServiceTypeID(), new IServiceListener() {
+ public void serviceDiscovered(IServiceEvent anEvent) {
+ addServiceInfo(anEvent.getServiceInfo().getServiceID());
+ addServiceInfo(anEvent.getServiceInfo());
}
- public void serviceRemoved(IServiceEvent evt) {
- removeServiceInfo(evt.getServiceInfo());
- }
-
- public void serviceResolved(IServiceEvent evt) {
- addServiceInfo(evt.getServiceInfo());
+ public void serviceUndiscovered(IServiceEvent anEvent) {
+ removeServiceInfo(anEvent.getServiceInfo());
}
});
- dc.registerServiceType(svcID.getServiceTypeID());
}
});
}

Back to the top