Equinox Services and User Interface

I’ve been trying to decide how to work with Equinox services in the user interface.

I’ve started modifying the Organizer application that will soon be part of the Eclipse Examples Project (once it’s provisioned) to use Equinox services. I’ve got a view that updates its appearance based on available services. The implementation is straightforward enough. The view has a ServiceTracker that watches as services of a particular type are added (or removed). As these services come online, the tracker notifies me of the change and I add a button corresponding to the new service to the view. The button is configured (text and image) with information from the service; when clicked, the button invokes behaviour on the service. When the tracker notifies me of that the service has been removed, I dispose() the button (thereby removing it).

It’s pretty cool to see the user interface change in response to commands typed in the Equinox console. Stop the service and the button disappears, start the service and the button reappears. Lather, rinse, repeat. Hours of fun for the whole family.

One advantage of this technique is that I can control aspects of my user interface by selectively enabling services. I can imagine a scenario where, using declarative services, a collection of services depend on the existence of a “role” service. For example, administrative behaviour might be defined in a collection of services that depend on the existence of an “Administrator” service that is only created if the user’s permissions include administrative operations. With declarative services, it’s easy to specify a cardinality on your dependencies; a service can specify, for example, that exactly one service of a particular type must be started before it will start. This isn’t exactly what I have in mind with the example I’m working on, but might be an interesting proof of concept.

The example code is still a little rough. I’m smoothing it out in anticipation of the Examples project being provisioned. In the meantime, I may try to develop a simpler example and post some of the code.

This entry was posted in Equinox. Bookmark the permalink.

4 Responses to Equinox Services and User Interface

  1. Neil Bartlett says:

    Wayne, maybe you’d like to test the mini-framework I wrote for injecting services into extension objects declaratively? This was the subject of one of my EclipseCon talks, and I’m currently looking for a home for the code (possible Equinox incubator).

    Cheers,
    Neil

  2. Pingback: Blog bookmarks 03/26/2008 « My Diigo bookmarks

  3. Alex Blewitt says:

    Neil and I did a talk at JSIG in London last year on the subject of UIs being modified by OSGi (not Equinox!) services; the screencasts and demo code are available for perusal at

    http://www.eclipsezone.com/files/jsig/

    No doubt Neil has done more work since then.

  4. Elias Volanakis says:

    Hi Wayne,

    I would be interested in the sample code. This (i.e. install and start bundle -> UI changes) is something I would like to incorporate into the example I use in my RAP talks.

    I have learned that it is often difficult for a “novice” audience (i.e. java devs without eclipse knowledge) to “get” the benefits of compontentization and OSGi. This could be an excellent example.

    Regards,
    Elias.

Leave a comment