From a0ce5e63f6131eaf979519d173b6027b52ef682c Mon Sep 17 00:00:00 2001 From: Javier Montalvo Orus Date: Fri, 30 Mar 2007 10:42:24 +0000 Subject: [PATCH] [170911] [plan] Improve Discovery and Autodetect in RSE --- .../org.eclipse.rse.discovery/plugin.xml | 18 +-- .../discovery/ServiceDiscoveryWizard.java | 130 +++++++++++++----- .../protocol/dnssd/DNSSDProtocol.java | 15 +- .../ServiceDiscoveryWizardDisplayPage.java | 83 +++++++++-- .../plugin.xml | 8 +- .../schema/subsystemConfigurations.exsd | 12 ++ 6 files changed, 209 insertions(+), 57 deletions(-) diff --git a/discovery/org.eclipse.rse.discovery/plugin.xml b/discovery/org.eclipse.rse.discovery/plugin.xml index f0658760e12..ca6d9982547 100644 --- a/discovery/org.eclipse.rse.discovery/plugin.xml +++ b/discovery/org.eclipse.rse.discovery/plugin.xml @@ -9,6 +9,7 @@ available at http://www.eclipse.org/legal/epl-v10.html Contributors: Javier Montalvo Orus (Symbian) - initial API and implementation + Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE --> @@ -28,14 +29,15 @@ Contributors: - + - + diff --git a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/internal/discovery/ServiceDiscoveryWizard.java b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/internal/discovery/ServiceDiscoveryWizard.java index 4b6fea2338b..3835158fea4 100644 --- a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/internal/discovery/ServiceDiscoveryWizard.java +++ b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/internal/discovery/ServiceDiscoveryWizard.java @@ -6,19 +6,27 @@ * * Contributors: * Javier Montalvo Orus (Symbian) - initial API and implementation + * Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE ********************************************************************************/ package org.eclipse.rse.internal.discovery; + import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.model.SystemRegistry; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.actions.SystemRefreshAllAction; import org.eclipse.tm.discovery.model.Pair; @@ -32,8 +40,8 @@ import org.eclipse.tm.internal.discovery.wizard.ServiceDiscoveryWizardMainPage; */ public class ServiceDiscoveryWizard extends Wizard { + private ServiceDiscoveryWizardMainPage serviceDiscoveryMainPage; - private ServiceDiscoveryWizardDisplayPage serviceDiscoveryPage = null; /** @@ -76,60 +84,108 @@ public class ServiceDiscoveryWizard extends Wizard { */ public boolean performFinish() { - SystemRefreshAllAction systemRefreshAllAction = new SystemRefreshAllAction(null); + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.ui","subsystemConfigurations"); //$NON-NLS-1$ //$NON-NLS-2$ + IConfigurationElement[] ce = ep.getConfigurationElements(); + SystemRefreshAllAction systemRefreshAllAction = new SystemRefreshAllAction(null); + SystemRegistry registry = RSEUIPlugin.getDefault().getSystemRegistry(); + String[] addresses = serviceDiscoveryPage.getAddresses(); for (int i = 0; i < addresses.length; i++) { String hostName = addresses[i]; Vector discoveredServices = serviceDiscoveryPage.getSelectedServices(addresses[i]); - + Vector subSystemConfigurationVector = new Vector(); + Enumeration serviceEnumeration = discoveredServices.elements(); - + + IHost conn = null; + try { + conn = registry.createHost("Discovery", "Discovery@" + hostName, hostName, "Discovered services in "+hostName);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$; + } catch (Exception e) { + RSEUIPlugin.getDefault().getSystemRegistry().deleteHost(conn); + return false; + } + while (serviceEnumeration.hasMoreElements()) { - IHost conn = null; - - Service service = (Service) serviceEnumeration.nextElement(); - String sysTypeString = ((ServiceType) service.eContainer()).getName(); - - try { - conn = RSEUIPlugin.getDefault().getSystemRegistry().createHost(sysTypeString, service.getName() + "@" + hostName, hostName, "Discovered "+sysTypeString+" server in "+hostName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (conn != null) { - //copy discovered properties to RSE models + Service service = (Service) serviceEnumeration.nextElement(); + + //discovered service name + String serviceName = ((ServiceType) service.eContainer()).getName(); + + //discovered transport (tcp, udp) + String transport = null; + + Iterator pairIterator = service.getPair().iterator(); + while (pairIterator.hasNext()) { + + Pair pair = (Pair) pairIterator.next(); + if(pair.getKey().equals("transport")) //$NON-NLS-1$ + { + transport = pair.getValue(); + } + } + + //find the SubSystemConfiguration plugin that matches the name+transport + for (int j = 0; j < ce.length; j++) { + String typesList = ce[j].getAttribute("serviceType"); //$NON-NLS-1$ + if(typesList!=null) + { + String[] types = typesList.split(";"); //$NON-NLS-1$ - Iterator pairIterator = service.getPair().iterator(); - IConnectorService[] services = conn.getConnectorServices(); - IPropertySet ps; - - while (pairIterator.hasNext()) { - - Pair pair = (Pair) pairIterator.next(); - - for(int j=0; j @@ -37,8 +38,9 @@ Martin Oberhuber (Wind River) - add FTP Only system type class="org.eclipse.rse.subsystems.files.ftp.FTPFileSubSystemConfiguration" vendor="%providerName" priority="100" - id="ftp.files"> + id="ftp.files" + serviceType="_ftp._tcp"> - \ No newline at end of file + diff --git a/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd b/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd index 64ad2f76a1b..1a752315844 100644 --- a/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd +++ b/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd @@ -160,6 +160,16 @@ Note that ServiceSubSystems that share the same service should always use the sa + + + + This optional attribute allows providing a semicolon separated list of standard names and transports expected to be used by service discovery servers to advertise this service. +The name is usually the keyword used by the IANA in the port number allocation (http://www.iana.org/assignments/port-numbers) or in DNS SRV service types (RFC 2782) (http://www.dns-sd.org/ServiceTypes.html). + +For example, this attribute could be <code>serviceType="_ftp._tcp;_ftp._udp"</code> to advertise a subsystem that supports ftp servers using tcp and udp transport. + + + @@ -183,6 +193,7 @@ Note that ServiceSubSystems that share the same service should always use the sa class="com.acme.tools.db.DBSubSystemFactory" category="databases" vendor="ACME" + serviceType="_database._tcp;_database._udp" > </configuration> </extension> @@ -235,6 +246,7 @@ available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation Uwe Stieber (Wind River) - systemTypeIds attribute extensions +Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE