mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-08 09:35:23 +02:00
[170911] [plan] Improve Discovery and Autodetect in RSE
This commit is contained in:
parent
959445c1b3
commit
a0ce5e63f6
6 changed files with 209 additions and 57 deletions
|
@ -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
|
||||
-->
|
||||
|
||||
<plugin>
|
||||
|
@ -28,14 +29,15 @@ Contributors:
|
|||
|
||||
<extension
|
||||
point="org.eclipse.rse.core.systemTypes">
|
||||
<systemType id="org.eclipse.rse.systemtype.discovery"
|
||||
<systemType
|
||||
description="%DiscoverySystemDescription"
|
||||
id="org.eclipse.rse.systemtype.discovery"
|
||||
label="%DiscoverySystemLabel"
|
||||
name="Discovery"
|
||||
description="%DiscoverySystemDescription"
|
||||
iconLive=""/>
|
||||
/>
|
||||
</extension>
|
||||
|
||||
<!-- extension
|
||||
<extension
|
||||
point="org.eclipse.rse.ui.subsystemConfigurations">
|
||||
<configuration
|
||||
systemTypeIds="org.eclipse.rse.systemtype.discovery"
|
||||
|
@ -43,12 +45,12 @@ Contributors:
|
|||
description="Service Discovery Wizard"
|
||||
iconlive=""
|
||||
icon=""
|
||||
class="org.eclipse.rse.discovery.ServiceDiscoverySubSystemConfiguration"
|
||||
class="org.eclipse.rse.internal.discovery.ServiceDiscoverySubSystemConfiguration"
|
||||
vendor="%providerName"
|
||||
priority="100"
|
||||
id="Discovery">
|
||||
</configuration>
|
||||
</extension -->
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
||||
|
|
|
@ -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 ServiceDiscoveryWizardMainPage serviceDiscoveryMainPage;
|
||||
private ServiceDiscoveryWizardDisplayPage serviceDiscoveryPage = null;
|
||||
|
||||
/**
|
||||
|
@ -76,60 +84,108 @@ public class ServiceDiscoveryWizard extends Wizard {
|
|||
*/
|
||||
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);
|
||||
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();
|
||||
|
||||
while (serviceEnumeration.hasMoreElements()) {
|
||||
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()) {
|
||||
|
||||
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$
|
||||
//discovered service name
|
||||
String serviceName = ((ServiceType) service.eContainer()).getName();
|
||||
|
||||
if (conn != null) {
|
||||
//copy discovered properties to RSE models
|
||||
//discovered transport (tcp, udp)
|
||||
String transport = null;
|
||||
|
||||
Iterator pairIterator = service.getPair().iterator();
|
||||
IConnectorService[] services = conn.getConnectorServices();
|
||||
IPropertySet ps;
|
||||
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$
|
||||
|
||||
for (int k = 0; k < types.length; k++) {
|
||||
if(types[k].equals("_"+serviceName+"._"+transport)) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
ISubSystemConfiguration config = registry.getSubSystemConfiguration(ce[j].getAttribute("id")); //$NON-NLS-1$
|
||||
IConnectorService connector = config.getConnectorService(conn);
|
||||
IPropertySet propertySet;
|
||||
pairIterator = service.getPair().iterator();
|
||||
|
||||
while (pairIterator.hasNext()) {
|
||||
|
||||
Pair pair = (Pair) pairIterator.next();
|
||||
|
||||
for(int j=0; j<services.length; j++)
|
||||
if((propertySet = connector.getPropertySet(Messages.ServiceDiscoveryWizard_DiscoveryPropertySet))==null)
|
||||
{
|
||||
if((ps = services[j].getPropertySet(sysTypeString))==null)
|
||||
{
|
||||
ps = services[j].createPropertySet(sysTypeString);
|
||||
propertySet = connector.createPropertySet(Messages.ServiceDiscoveryWizard_DiscoveryPropertySet);
|
||||
}
|
||||
propertySet.addProperty(pair.getKey(), pair.getValue());
|
||||
}
|
||||
ps.addProperty(pair.getKey(), pair.getValue());
|
||||
|
||||
if (pair.getKey().equalsIgnoreCase(Messages.ServiceDiscoveryWizard_Port)) {
|
||||
int port = Integer.parseInt(pair.getValue());
|
||||
services[j].setPort(port);
|
||||
subSystemConfigurationVector.add(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
RSEUIPlugin.getDefault().getSystemRegistry().deleteHost(conn);
|
||||
} finally {
|
||||
|
||||
systemRefreshAllAction.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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;
|
||||
|
@ -117,7 +119,7 @@ public class DNSSDProtocol implements IProtocol {
|
|||
|
||||
// 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 Resource resource = null;
|
||||
|
@ -554,6 +556,7 @@ public class DNSSDProtocol implements IProtocol {
|
|||
|
||||
String serviceName = null;
|
||||
String serviceTypeName = null;
|
||||
String serviceTransport = null;
|
||||
|
||||
// Find if we have a serviceType with this name...
|
||||
|
||||
|
@ -562,6 +565,7 @@ public class DNSSDProtocol implements IProtocol {
|
|||
{
|
||||
serviceName = matcher.group(1);
|
||||
serviceTypeName = matcher.group(2);
|
||||
serviceTransport = matcher.group(3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -605,6 +609,15 @@ public class DNSSDProtocol implements IProtocol {
|
|||
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
|
||||
|
||||
StringBuffer dataBuffer = new StringBuffer();
|
||||
|
|
|
@ -6,17 +6,20 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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.IExtensionPoint;
|
||||
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.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
|
@ -108,9 +112,13 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
|
|||
private String protocolName = null;
|
||||
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 Vector supportedServicesType = new Vector();
|
||||
private Hashtable supportedServicesType = new Hashtable();
|
||||
|
||||
/**
|
||||
* 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
|
||||
//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();
|
||||
for (int i = 0; i < ce.length; i++) {
|
||||
String id = ce[i].getAttribute("name"); //$NON-NLS-1$
|
||||
if(id!=null)
|
||||
supportedServicesType.add(id);
|
||||
String type = ce[i].getAttribute("serviceType"); //$NON-NLS-1$
|
||||
|
||||
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;
|
||||
|
@ -361,17 +393,52 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
|
|||
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
boolean supported = true;
|
||||
|
||||
if(element instanceof ServiceType) {
|
||||
|
||||
//check if the service type is in the supported list
|
||||
String serviceTypeName = ((ServiceType)element).getName();
|
||||
if(!supportedServicesType.contains(serviceTypeName))
|
||||
if(!supportedServicesType.containsKey(serviceTypeName))
|
||||
{
|
||||
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;
|
||||
|
||||
}};
|
||||
|
||||
|
||||
|
||||
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter);
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
||||
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
|
||||
Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
|
||||
-->
|
||||
<?eclipse version="3.1"?>
|
||||
<plugin>
|
||||
|
@ -37,7 +38,8 @@ 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">
|
||||
</configuration>
|
||||
</extension>
|
||||
|
||||
|
|
|
@ -160,6 +160,16 @@ Note that ServiceSubSystems that share the same service should always use the sa
|
|||
</documentation>
|
||||
</annotation>
|
||||
</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 <code>serviceType="_ftp._tcp;_ftp._udp"</code> to advertise a subsystem that supports ftp servers using tcp and udp transport.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
@ -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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue