Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "File-based Discovery"
Line 66: | Line 66: | ||
<read the myremoteservicedescriptions.xml file and publish given services and connect ids/namespaces. | <read the myremoteservicedescriptions.xml file and publish given services and connect ids/namespaces. | ||
</pre> | </pre> | ||
+ | |||
+ | [[Category:Draft Documentation]] |
Revision as of 15:42, 2 November 2009
ECF 3.1 makes available a contribution from Siemens, called File-Based Discovery. File-based discovery allows those using the ECF RFC119 implementation to trigger remote service discovery by publishing remote service interfaces and their associated endpoints in a service description xml file.
The three pieces of information to describe a remote service with the ECF remote services endpoint are
- The service interface (i.e. the fully-qualified classname of the service interface class. Example: org.eclipse.ecf.examples.remoteservices.hello.IHello
- The service publication 'connect id' (aka URI of endpoint). Example (ECF generic provider): ecftcp://localhost:3282/server
- The service publication 'connect namespace'. Example (ECF generic provider): org.eclipse.ecf.core.identity.StringID
<?xml version="1.0" encoding="UTF-8"?> <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> <service-description> <provide interface="org.eclipse.ecf.examples.remoteservices.hello.IHello"/> <property name="ecf.sp.cid">ecftcp://localhost:3282/server</property> <property name="ecf.sp.cns">org.eclipse.ecf.core.identity.StringID</property> </service-description> </service-descriptions>
Here, for another example, is a service description file that publishes the same service interface org.eclipse.ecf.examples.remoteservices.hello.IHello with an ECF service publication connect id (ecf.sp.cid) of r-osgi://localhost:9278 and an ECF service publication connect namespace (ecf.sp.cns) of ecf.namespace.r_osgi.
<?xml version="1.0" encoding="UTF-8"?> <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> <service-description> <provide interface="org.eclipse.ecf.examples.remoteservices.hello.IHello"/> <property name="ecf.sp.cid">r-osgi://localhost:9278</property> <property name="ecf.sp.cns">ecf.namespace.r_osgi</property> </service-description> </service-descriptions>
To read the service description in the xml file, and have it trigger discovery of the given service description the following must occur:
- This bundle: org.eclipse.ecf.osgi.services.discovery.local must be started
- A file with an xml file name suffix must be in either a directory named OSGI-INF/remote-services OR at a path given by the the Remote-Service header in the META-INF/MANIFEST.MF file.
For example, the file named servicedescriptions.xml will be read and processed by the file-based discovery when the bundle is started if the servicedescriptions.xml is present in the following location within your bundle.
[bundle root]/OSGI-INF/remote-services/servicedescriptions.xml
Or, if the manifest of your bundle has the following in it
...<other manifest headers> Remote-Service: foo/bar.xml
Then the file bar.xml will be read for service descriptions and used to publish discovered remote services when the containing bundle is started.
As another way to introduce service descriptions into a running Equinox instance, once the org.eclipse.ecf.osgi.services.discovery.local bundle is started, the OSGi console will allow service description xml files to be published via the OSGi console
osgi>help ...other OSGi console help ---Remote Services and Discovery Commands--- publish <URL of ServiceEndpointDescriptor XML> -- publish the given Service Endpoint Descriptor unpublish <URL of ServiceEndpointDescriptor XML> -- unpublish the given Service ndpoint Descriptor osgi> publish file:/c:/temp/myremoteservicedescriptions.xml <read the myremoteservicedescriptions.xml file and publish given services and connect ids/namespaces.