1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-08 17:45:24 +02:00

[170911] [plan] Improve Discovery and Autodetect in RSE

This commit is contained in:
Javier Montalvo Orus 2007-03-30 10:42:24 +00:00
parent 959445c1b3
commit a0ce5e63f6
6 changed files with 209 additions and 57 deletions

View file

@ -9,6 +9,7 @@ available at http://www.eclipse.org/legal/epl-v10.html
Contributors: Contributors:
Javier Montalvo Orus (Symbian) - initial API and implementation Javier Montalvo Orus (Symbian) - initial API and implementation
Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
--> -->
<plugin> <plugin>
@ -28,14 +29,15 @@ Contributors:
<extension <extension
point="org.eclipse.rse.core.systemTypes"> point="org.eclipse.rse.core.systemTypes">
<systemType id="org.eclipse.rse.systemtype.discovery" <systemType
label="%DiscoverySystemLabel" description="%DiscoverySystemDescription"
name="Discovery" id="org.eclipse.rse.systemtype.discovery"
description="%DiscoverySystemDescription" label="%DiscoverySystemLabel"
iconLive=""/> name="Discovery"
/>
</extension> </extension>
<!-- extension <extension
point="org.eclipse.rse.ui.subsystemConfigurations"> point="org.eclipse.rse.ui.subsystemConfigurations">
<configuration <configuration
systemTypeIds="org.eclipse.rse.systemtype.discovery" systemTypeIds="org.eclipse.rse.systemtype.discovery"
@ -43,12 +45,12 @@ Contributors:
description="Service Discovery Wizard" description="Service Discovery Wizard"
iconlive="" iconlive=""
icon="" icon=""
class="org.eclipse.rse.discovery.ServiceDiscoverySubSystemConfiguration" class="org.eclipse.rse.internal.discovery.ServiceDiscoverySubSystemConfiguration"
vendor="%providerName" vendor="%providerName"
priority="100" priority="100"
id="Discovery"> id="Discovery">
</configuration> </configuration>
</extension --> </extension>
</plugin> </plugin>

View file

@ -6,19 +6,27 @@
* *
* Contributors: * Contributors:
* Javier Montalvo Orus (Symbian) - initial API and implementation * 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; package org.eclipse.rse.internal.discovery;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; 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.IWizardPage;
import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.Wizard;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.subsystems.IConnectorService; 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.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemRefreshAllAction; import org.eclipse.rse.ui.actions.SystemRefreshAllAction;
import org.eclipse.tm.discovery.model.Pair; import org.eclipse.tm.discovery.model.Pair;
@ -32,8 +40,8 @@ import org.eclipse.tm.internal.discovery.wizard.ServiceDiscoveryWizardMainPage;
*/ */
public class ServiceDiscoveryWizard extends Wizard { public class ServiceDiscoveryWizard extends Wizard {
private ServiceDiscoveryWizardMainPage serviceDiscoveryMainPage;
private ServiceDiscoveryWizardMainPage serviceDiscoveryMainPage;
private ServiceDiscoveryWizardDisplayPage serviceDiscoveryPage = null; private ServiceDiscoveryWizardDisplayPage serviceDiscoveryPage = null;
/** /**
@ -76,60 +84,108 @@ public class ServiceDiscoveryWizard extends Wizard {
*/ */
public boolean performFinish() { public boolean performFinish() {
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); SystemRefreshAllAction systemRefreshAllAction = new SystemRefreshAllAction(null);
SystemRegistry registry = RSEUIPlugin.getDefault().getSystemRegistry();
String[] addresses = serviceDiscoveryPage.getAddresses(); String[] addresses = serviceDiscoveryPage.getAddresses();
for (int i = 0; i < addresses.length; i++) { for (int i = 0; i < addresses.length; i++) {
String hostName = addresses[i]; String hostName = addresses[i];
Vector discoveredServices = serviceDiscoveryPage.getSelectedServices(addresses[i]); Vector discoveredServices = serviceDiscoveryPage.getSelectedServices(addresses[i]);
Vector subSystemConfigurationVector = new Vector();
Enumeration serviceEnumeration = discoveredServices.elements(); 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()) { while (serviceEnumeration.hasMoreElements()) {
IHost conn = null;
Service service = (Service) serviceEnumeration.nextElement(); Service service = (Service) serviceEnumeration.nextElement();
String sysTypeString = ((ServiceType) service.eContainer()).getName();
try { //discovered service name
conn = RSEUIPlugin.getDefault().getSystemRegistry().createHost(sysTypeString, service.getName() + "@" + hostName, hostName, "Discovered "+sysTypeString+" server in "+hostName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String serviceName = ((ServiceType) service.eContainer()).getName();
if (conn != null) { //discovered transport (tcp, udp)
//copy discovered properties to RSE models String transport = null;
Iterator pairIterator = service.getPair().iterator(); Iterator pairIterator = service.getPair().iterator();
IConnectorService[] services = conn.getConnectorServices(); while (pairIterator.hasNext()) {
IPropertySet ps;
while (pairIterator.hasNext()) { Pair pair = (Pair) pairIterator.next();
if(pair.getKey().equals("transport")) //$NON-NLS-1$
{
transport = pair.getValue();
}
}
Pair pair = (Pair) pairIterator.next(); //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$
for(int j=0; j<services.length; j++) for (int k = 0; k < types.length; k++) {
if(types[k].equals("_"+serviceName+"._"+transport)) //$NON-NLS-1$ //$NON-NLS-2$
{ {
if((ps = services[j].getPropertySet(sysTypeString))==null) ISubSystemConfiguration config = registry.getSubSystemConfiguration(ce[j].getAttribute("id")); //$NON-NLS-1$
{ IConnectorService connector = config.getConnectorService(conn);
ps = services[j].createPropertySet(sysTypeString); IPropertySet propertySet;
} pairIterator = service.getPair().iterator();
ps.addProperty(pair.getKey(), pair.getValue());
if (pair.getKey().equalsIgnoreCase(Messages.ServiceDiscoveryWizard_Port)) { while (pairIterator.hasNext()) {
int port = Integer.parseInt(pair.getValue());
services[j].setPort(port); Pair pair = (Pair) pairIterator.next();
if((propertySet = connector.getPropertySet(Messages.ServiceDiscoveryWizard_DiscoveryPropertySet))==null)
{
propertySet = connector.createPropertySet(Messages.ServiceDiscoveryWizard_DiscoveryPropertySet);
} }
propertySet.addProperty(pair.getKey(), pair.getValue());
}
subSystemConfigurationVector.add(config);
} }
} }
RSEUIPlugin.getDefault().getSystemRegistry().expandHost(conn);
} }
} catch (Exception e) {
RSEUIPlugin.getDefault().getSystemRegistry().deleteHost(conn);
} finally {
systemRefreshAllAction.run();
} }
} }
ISubSystemConfiguration[] subSystemConfiguration = new ISubSystemConfiguration[subSystemConfigurationVector.size()];
for (int j = 0; j < subSystemConfiguration.length; j++) {
subSystemConfiguration[j]=(ISubSystemConfiguration)subSystemConfigurationVector.elementAt(j);
}
ISubSystem[] subSystem = registry.createSubSystems(conn, subSystemConfiguration);
for (int j = 0; j < subSystem.length; j++) {
IConnectorService connector = subSystem[j].getConnectorService();
IPropertySet propertySet = connector.getPropertySet(Messages.ServiceDiscoveryWizard_DiscoveryPropertySet);
if(propertySet.getProperty(Messages.ServiceDiscoveryWizard_Port)!=null)
{
int port = Integer.parseInt(propertySet.getPropertyValue(Messages.ServiceDiscoveryWizard_Port));
connector.setPort(port);
}
}
RSEUIPlugin.getDefault().getSystemRegistry().expandHost(conn);
} }
systemRefreshAllAction.run();
return true; return true;
} }

View file

@ -6,6 +6,8 @@
* *
* Contributors: * Contributors:
* Javier Montalvo Orus (Symbian) - initial API and implementation * Javier Montalvo Orus (Symbian) - initial API and implementation
* Javier Montalvo Orus (Symbian) - added transport key
* Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
********************************************************************************/ ********************************************************************************/
package org.eclipse.tm.internal.discovery.protocol.dnssd; package org.eclipse.tm.internal.discovery.protocol.dnssd;
@ -117,7 +119,7 @@ public class DNSSDProtocol implements IProtocol {
// Patterns to parse service name and service type // Patterns to parse service name and service type
private final Pattern srvPattern = Pattern.compile("^(.+)\\._(.+)._.+\\.local."); //$NON-NLS-1$ private final Pattern srvPattern = Pattern.compile("^(.+)\\._(.+)._(.+)\\.local."); //$NON-NLS-1$
private final Pattern ptrPattern = Pattern.compile("^_(.+)._.+\\.local."); //$NON-NLS-1$ private final Pattern ptrPattern = Pattern.compile("^_(.+)._.+\\.local."); //$NON-NLS-1$
private Resource resource = null; private Resource resource = null;
@ -554,6 +556,7 @@ public class DNSSDProtocol implements IProtocol {
String serviceName = null; String serviceName = null;
String serviceTypeName = null; String serviceTypeName = null;
String serviceTransport = null;
// Find if we have a serviceType with this name... // Find if we have a serviceType with this name...
@ -562,6 +565,7 @@ public class DNSSDProtocol implements IProtocol {
{ {
serviceName = matcher.group(1); serviceName = matcher.group(1);
serviceTypeName = matcher.group(2); serviceTypeName = matcher.group(2);
serviceTransport = matcher.group(3);
} }
@ -605,6 +609,15 @@ public class DNSSDProtocol implements IProtocol {
serviceType.getService().add(service); serviceType.getService().add(service);
} }
//add discovered transport
if(serviceTransport != null)
{
Pair transportPair = ModelFactory.eINSTANCE.createPair();
transportPair.setKey("transport"); //$NON-NLS-1$
transportPair.setValue(serviceTransport);
service.getPair().add(transportPair);
}
//process "key=value" pairs //process "key=value" pairs
StringBuffer dataBuffer = new StringBuffer(); StringBuffer dataBuffer = new StringBuffer();

View file

@ -6,17 +6,20 @@
* *
* Contributors: * Contributors:
* Javier Montalvo Orus (Symbian) - initial API and implementation * Javier Montalvo Orus (Symbian) - initial API and implementation
* Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
********************************************************************************/ ********************************************************************************/
package org.eclipse.tm.internal.discovery.wizard; package org.eclipse.tm.internal.discovery.wizard;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.widgets.Button;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
@ -51,6 +54,7 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
@ -108,9 +112,13 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
private String protocolName = null; private String protocolName = null;
private int timeOut = 500; private int timeOut = 500;
//format of serviceType attribute list of names and transports
//of extension point org.eclipse.ui.subsystemConfigurations
private final Pattern serviceTypeFormat = Pattern.compile("_(.+)\\._(.+)"); //$NON-NLS-1$
private Service lastSelectedService = null; private Service lastSelectedService = null;
private Vector supportedServicesType = new Vector(); private Hashtable supportedServicesType = new Hashtable();
/** /**
* Constructor for the wizard page performing and displayin the results of the service discovery * Constructor for the wizard page performing and displayin the results of the service discovery
@ -135,12 +143,36 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
//load all service id's from the extension point registry //load all service id's from the extension point registry
//this id will be used to filter the supported sytem types //this id will be used to filter the supported sytem types
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.core","systemTypes"); //$NON-NLS-1$ //$NON-NLS-2$ IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.ui","subsystemConfigurations"); //$NON-NLS-1$ //$NON-NLS-2$
IConfigurationElement[] ce = ep.getConfigurationElements(); IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) { for (int i = 0; i < ce.length; i++) {
String id = ce[i].getAttribute("name"); //$NON-NLS-1$ String type = ce[i].getAttribute("serviceType"); //$NON-NLS-1$
if(id!=null)
supportedServicesType.add(id); if(type!=null)
{
String[] variants = type.split(";"); //$NON-NLS-1$
for (int j = 0; j < variants.length; j++) {
Matcher match = serviceTypeFormat.matcher(variants[j]);
if(match.matches())
{
String name = match.group(1);
String transport = match.group(2);
if(supportedServicesType.containsKey(name))
{
//insert new transport
((Vector)supportedServicesType.get(name)).add(transport);
}
else
{
//create vector with new transport
Vector transports = new Vector();
transports.add(transport);
supportedServicesType.put(name,transports);
}
}
}
}
} }
this.query = query; this.query = query;
@ -361,17 +393,52 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
public boolean select(Viewer viewer, Object parentElement, Object element) { public boolean select(Viewer viewer, Object parentElement, Object element) {
boolean supported = true; boolean supported = true;
if(element instanceof ServiceType) { if(element instanceof ServiceType) {
//check if the service type is in the supported list
String serviceTypeName = ((ServiceType)element).getName(); String serviceTypeName = ((ServiceType)element).getName();
if(!supportedServicesType.contains(serviceTypeName)) if(!supportedServicesType.containsKey(serviceTypeName))
{ {
supported = false; supported = false;
} }
}
if(element instanceof Service) {
//if the discovered transport value is not contained in the list of supported transports filter this service
supported = false;
String serviceTypeName = ((ServiceType)((Service)element).eContainer()).getName();
//check if the transport service is supported
Vector transports = (Vector)supportedServicesType.get(serviceTypeName);
Iterator it = ((Service)element).getPair().iterator();
while(it.hasNext())
{
Pair pair = (Pair)it.next();
if(pair.getKey().equalsIgnoreCase("transport")) //$NON-NLS-1$
{
String transport = pair.getValue();
for (int i = 0; i < transports.size(); i++) {
if(((String)transports.elementAt(i)).equalsIgnoreCase(transport))
{
//found a supported transport
supported = true;
}
}
}
}
} }
return supported; return supported;
}}; }};
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter); ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter);
} }

View file

@ -12,8 +12,9 @@ Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
Contributors: Contributors:
Javier Montalvo Orús (Symbian) - add Windows to list of valid FTP systems Javier Montalvo Orus (Symbian) - add Windows to list of valid FTP systems
Martin Oberhuber (Wind River) - add FTP Only system type Martin Oberhuber (Wind River) - add FTP Only system type
Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
--> -->
<?eclipse version="3.1"?> <?eclipse version="3.1"?>
<plugin> <plugin>
@ -37,7 +38,8 @@ Martin Oberhuber (Wind River) - add FTP Only system type
class="org.eclipse.rse.subsystems.files.ftp.FTPFileSubSystemConfiguration" class="org.eclipse.rse.subsystems.files.ftp.FTPFileSubSystemConfiguration"
vendor="%providerName" vendor="%providerName"
priority="100" priority="100"
id="ftp.files"> id="ftp.files"
serviceType="_ftp._tcp">
</configuration> </configuration>
</extension> </extension>

View file

@ -160,6 +160,16 @@ Note that ServiceSubSystems that share the same service should always use the sa
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="serviceType" type="string">
<annotation>
<documentation>
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 &lt;code&gt;serviceType=&quot;_ftp._tcp;_ftp._udp&quot;&lt;/code&gt; to advertise a subsystem that supports ftp servers using tcp and udp transport.
</documentation>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>
@ -183,6 +193,7 @@ Note that ServiceSubSystems that share the same service should always use the sa
class=&quot;com.acme.tools.db.DBSubSystemFactory&quot; class=&quot;com.acme.tools.db.DBSubSystemFactory&quot;
category=&quot;databases&quot; category=&quot;databases&quot;
vendor=&quot;ACME&quot; vendor=&quot;ACME&quot;
serviceType=&quot;_database._tcp;_database._udp&quot;
&gt; &gt;
&lt;/configuration&gt; &lt;/configuration&gt;
&lt;/extension&gt; &lt;/extension&gt;
@ -235,6 +246,7 @@ available at http://www.eclipse.org/legal/epl-v10.html
Contributors: Contributors:
IBM Corporation - initial API and implementation IBM Corporation - initial API and implementation
Uwe Stieber (Wind River) - systemTypeIds attribute extensions Uwe Stieber (Wind River) - systemTypeIds attribute extensions
Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
</documentation> </documentation>
</annotation> </annotation>