1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 15:45:25 +02:00

Initial commit of org.eclipse.tm.discovery.engine

This commit is contained in:
Javier Montalvo Orus 2006-09-07 10:07:03 +00:00
parent cbbcb043b1
commit 8db77b451d
20 changed files with 887 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.5.0_02"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.tm.discovery.engine</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,4 @@
#Wed Jul 19 12:48:55 BST 2006
eclipse.preferences.version=1
encoding//src/org/eclipse/tm/discovery/engine/messages.properties=8859_1
encoding//src/org/eclipse/tm/discovery/protocol/messages.properties=8859_1

View file

@ -0,0 +1,24 @@
#Thu Jul 27 13:28:01 BST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.source=1.3

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Service Discovery Engine Plug-in
Bundle-SymbolicName: org.eclipse.tm.discovery.engine;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.tm.discovery.engine.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.emf.ecore.xmi,
org.eclipse.tm.discovery.model
Eclipse-LazyStart: true
Export-Package: org.eclipse.tm.discovery.engine,
org.eclipse.tm.discovery.protocol,
org.eclipse.tm.discovery.transport
Import-Package: org.eclipse.tm.discovery.model,
org.eclipse.tm.discovery.model.util
Bundle-Vendor: Symbian

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>July 27, 2006</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in
("Content"). Unless otherwise indicated below, the Content is provided
to you under the terms and conditions of the
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
("Redistributor") and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any
source code in the Content and such source code may be obtained at http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
plugin.xml
src.includes = about.html

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension-point id="discoveryTransport" name="discoveryTransport" schema="schema/discoveryTransport.exsd"/>
<extension-point id="discoveryProtocol" name="discoveryProtocol" schema="schema/discoveryProtocol.exsd"/>
</plugin>

View file

@ -0,0 +1,118 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.tm.discovery.engine">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.tm.discovery.engine" id="discoveryProtocol" name="Service Discovery protocol"/>
</appInfo>
<documentation>
Extension point providing implementations of protocols for service discovery.
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="protocol" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="protocol">
<complexType>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.tm.discovery.protocol.IServiceDiscoveryProtocol"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
This program and the accompanying materials are made available under the terms
of the Eclipse Public License v1.0 which accompanies this distribution, and is
available at http://www.eclipse.org/legal/epl-v10.html
Contributors:
Javier Montalvo Orús (Symbian) - initial API and implementation
</documentation>
</annotation>
</schema>

View file

@ -0,0 +1,118 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.tm.discovery.engine">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.tm.discovery.engine" id="discoveryTransport" name="Service Discovery Transport"/>
</appInfo>
<documentation>
Extension point providing implementations of transports for service discovery.
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="transport" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="transport">
<complexType>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.tm.discovery.transport.ITransport"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
This program and the accompanying materials are made available under the terms
of the Eclipse Public License v1.0 which accompanies this distribution, and is
available at http://www.eclipse.org/legal/epl-v10.html
Contributors:
Javier Montalvo Orús (Symbian) - initial API and implementation
</documentation>
</annotation>
</schema>

View file

@ -0,0 +1,60 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.engine;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.rse.discovery.engine";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,32 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.engine;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "org.eclipse.tm.discovery.engine.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,99 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.engine;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.tm.discovery.model.ModelPackage;
import org.eclipse.tm.discovery.model.util.ModelResourceFactoryImpl;
import org.eclipse.tm.discovery.protocol.IProtocol;
import org.eclipse.tm.discovery.transport.ITransport;
/**
* Engine for service discovery.
* Instantiates the model that contains the discovered services information.
* Provides methods to launch a discovery job given an implementation of ITransport and IProtocol to populate the model.
*
* @see ITransport
* @see IProtocol
*
*/
public class ServiceDiscoveryEngine {
private static ServiceDiscoveryEngine SERVICE_DISCOVERY_ENGINE = null;
private final URI SERVICE_DISCOVERY_URI = URI.createFileURI(Messages.getString("ServiceDiscoveryEngine.DiscoveryModelFileURI")); //$NON-NLS-1$
private Resource resource;
/**
* Gets an instance of the service discovery engine
*/
public static ServiceDiscoveryEngine getServiceDiscoveryEngine() {
if (SERVICE_DISCOVERY_ENGINE == null)
SERVICE_DISCOVERY_ENGINE = new ServiceDiscoveryEngine();
return SERVICE_DISCOVERY_ENGINE;
}
/*
* Private constructor of the ServiceDiscoveryEngine
*/
private ServiceDiscoveryEngine() {
// get model
ResourceSet resourceSet = new ResourceSetImpl();
// Register the appropriate resource factory to handle all file
// extentions.
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new ModelResourceFactoryImpl());
// Register the package to ensure it is available during loading.
resourceSet.getPackageRegistry().put(ModelPackage.eNS_URI,ModelPackage.eINSTANCE);
try {
resource = resourceSet.getResource(SERVICE_DISCOVERY_URI, true);
} catch (WrappedException e) {
resource = resourceSet.createResource(SERVICE_DISCOVERY_URI);
}
}
/**
* Gets the resource
*
* @return the static reference to the resource model
*/
public Resource getResource() {
return resource;
}
/**
* Starts a service discovery job given an implementation of IProtocol and ITransport
*
* @param transport
* the selected transport
* @see ITransport
* @see IProtocol
*/
public void doServiceDiscovery(String query, IProtocol protocol, ITransport transport)
{
protocol.getDiscoveryJob(query, resource,transport).schedule();
}
}

View file

@ -0,0 +1,11 @@
##################################################################################
# Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License v1.0 which accompanies this distribution, and is
# available at http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Javier Montalvo Orús (Symbian) - initial API and implementation
##################################################################################
ServiceDiscoveryEngine.DiscoveryModelFileURI=discoveryModel.xml

View file

@ -0,0 +1,62 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.protocol;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.tm.discovery.transport.ITransport;
/**
* Interface for service discovery protocol implementations.</br>
* Standard protocols that can be implementated from this interface are:
* <ul>
* <li>DNS-SD (Zeroconf)
* <li>Simple Service Discovery Protocol (SSDP)
* <li>Service Location Protocol (SPL)
* </ul>
* As well as propietary/customised protocols
*
*/
public interface IProtocol {
/**
* Instantiates a Job to populate a model given an initial query, a resource containing the model to be populated and an ITranport implementation.
*
* @param query
* Initial query to be sent to the target. This initial query can be obtained from the getQueries() method.
*
* @param resource
* Resource containing the model to be populated with the results of the service discovery action.
*
* @param transport
* ITransport implementation of the transport to be used for the discovery action.
*
* @return
* Job containing the service discovery action.
*
* @see Job
* @see Resource
* @see ITransport
*
*/
public abstract Job getDiscoveryJob(String query, Resource resource, ITransport transport);
/**
* Gets the list of recommended queries to start the service discovery process. This queries can be used in getDiscoveryJob().
*
* @return
* An array containing the recommended queries.
*/
public abstract String[] getQueries();
}

View file

@ -0,0 +1,114 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.protocol;
import java.util.Vector;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
/**
* Static factory to handle the protocol implementations.</br>
*/
public class ProtocolFactory {
/*
* Extension point containing the protocol implementations available in the workbench
*/
private static IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.tm.discovery.engine","discoveryProtocol"); //$NON-NLS-1$ //$NON-NLS-2$
/**
* Returns the available protocol names. This protocol names are registered in the field <b>name</b> of the extension point <b>discoveryProtocol</b>
*
* @return
* Array of available protocol names
*/
public static String[] getProtocolList()
{
Vector protocols = new Vector();
IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) {
String name = ce[i].getAttribute("name"); //$NON-NLS-1$
if(name!=null)
protocols.add(name);
}
String[] protocolsList = new String[protocols.size()];
protocols.copyInto(protocolsList);
return protocolsList;
}
/**
* Returns the recommended queries for the specified protocol
*
* @param protocolName
* Name of the protocol
* @return
* Array of recommended queries to be send using this protocol.
* @throws CoreException
*/
public static String[] getQueryList(String protocolName) throws CoreException
{
IProtocol protocol = null;
IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) {
String name = ce[i].getAttribute("name"); //$NON-NLS-1$
if(name!=null)
if(name.equalsIgnoreCase(protocolName))
{
protocol = (IProtocol)ce[i].createExecutableExtension("class"); //$NON-NLS-1$
}
}
String[] queries = protocol.getQueries();
if(queries==null)
queries = new String[]{};
return queries;
}
/**
* Gets the IProtocol implementation of a protocol given its name
*
* @param protocolName
* Name of the protocolo
* @return
* IProtocol implementation of the protocol matching the given name. Null if the protocol cannot be found.
* @throws CoreException
*
* @see IProtocol
*/
public static IProtocol getProtocol(String protocolName) throws CoreException {
IProtocol protocol = null;
IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) {
String name = ce[i].getAttribute("name"); //$NON-NLS-1$
if(name!=null)
if(name.equalsIgnoreCase(protocolName))
{
protocol = (IProtocol)ce[i].createExecutableExtension("class"); //$NON-NLS-1$
}
}
return protocol;
}
}

View file

@ -0,0 +1,60 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.transport;
import java.io.IOException;
/**
* Interface for service discovery transports
*
*/
public interface ITransport {
/**
* Handles sending data
*
* @param data
* Data packet to be sent.
* @throws IOException
*/
public abstract void send(byte[] packet) throws Exception;
/**
* Handles receiving data
*
* @param packet
* Packet to be filled with the reply data.
* @return
* Address of the replying device.
* @throws IOException
*/
public abstract String receive(byte[] packet) throws Exception;
/**
* Sets the address of the target, depending on the implementation (IP, port...)
* @param address
* Address or identifier of the target.
* @throws Exception
*
*/
public abstract void setTargetAddress(String address) throws Exception;
/**
* Sets the timeout for the transport implementation.
* @param timeOut
* The timeout in milliseconds
* @throws Exception
*/
public abstract void setTimeOut(int timeOut) throws Exception;
}

View file

@ -0,0 +1,85 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.transport;
import java.util.Vector;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
/**
* Factory for the remoste system connection.
*/
public class TransportFactory {
/*
* Extension point containing the transport implementations available in the workbench
*/
private static IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.tm.discovery.engine","discoveryTransport"); //$NON-NLS-1$ //$NON-NLS-2$
/**
* Returns the available transport names. The transport names are registered in the field <b>name</b> of the extension point <b>discoveryTransport</b>
*
* @return
* Array of available transport names
*/
public static String[] getTransportList()
{
Vector transports = new Vector();
IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) {
String name = ce[i].getAttribute("name"); //$NON-NLS-1$
if(name!=null)
transports.add(name);
}
String[] transportsList = new String[transports.size()];
transports.copyInto(transportsList);
return transportsList;
}
/**
* Gets the ITransport implementation of a transport given its name
*
* @param transportName
* Name of the transport
* @param address
* Address of the target device
* @param timeOut
* Timeout in milliseconds
* @return
* ITranport implementation of the transport matching the given name. Null if the transport cannot be found.
* @throws Exception
*/
public static ITransport getTransport(String transportName, String address, int timeOut) throws Exception {
ITransport transport = null;
IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) {
String name = ce[i].getAttribute("name"); //$NON-NLS-1$
if(name!=null)
if(name.equalsIgnoreCase(transportName))
{
transport = (ITransport)ce[i].createExecutableExtension("class"); //$NON-NLS-1$
transport.setTargetAddress(address);
transport.setTimeOut(timeOut);
}
}
return transport;
}
}