Jump to: navigation, search

Discovery of Remote Services

More work on examples...this time an example that combines the use of the ECF discovery API with the use of the ECF remote services API.

Here is a screen shot of the ECF service discovery view, after having discovered a remote service:

Rs1.png

Note the type of the service is 'remotesvcs', a new type. For those interested, the publicly registered types for RFC 2782 are listed here.

Note that in this case the discovery is being done by the ECF zeroconf/bonjour/rendevous provider. The UI and the code that uses the discovery, is, however, discovery protocol independent, so that it can (and will) also be used with SLP discovery...with no changes to the middleware or application code.

Here is an expanded view of the info about the service provided by service host via the discovery API:

Rs2.png

Now, the ECF discovery view UI has an extension point called 'serviceAccessHandler' that allows context menu contributions to be optionally added by extensions, based upon the discovered service info. For the client there is a serviceAccessHandler defined for the 'remotesvcs' type (defined in the schema here as extension point org.eclipse.ecf.discovery.ui.serviceAccessHandler) that presents the following when the user opens the context menu for the service

Rs3.png

If the user is not already connected to the given service, then it allows the connection to be established as above. If already connected, however, the context menu presents options for invoking a remote 'getProperty' method (part of the Equinox EnvironmentInfo service)

Rs4.png

This menu provides access to four different ways of invoking the 'getProperty' method remotely...and is just an example UI (a better UI for selecting a remote method and providing parameters is forthcoming). The four ways are

(s) = synchronously -- block calling thread until service host responds (a) = asynchronously -- calling thread does not block and result is provided via notification to a listener (f) = future -- calling thread does not block, and an instance of IAsynchResult is returned immediately Receiver can inspect IAsynchResult for completion. (p) = proxy -- calling thread calls a proxy instance of service interface) with normal call/return semantics

These access methods are made available via the ECF IRemoteService. Note that the proxy can also be accessed directly in the OSGi service registry via BundleContext.getServiceReference() or a ServiceTracker.