Time for action – dealing with events

There's a more generic way of passing information between components in Eclipse 4, using the OSGi EventAdmin service. This is a message bus, like JMS, but operates in memory. There is also an Eclipse-specific IEventBroker, which provides a slightly simpler API to send messages.

  1. Add the following bundles as dependencies to the com.packtpub.e4.application project, by double-clicking on the project's META-INF/MANIFEST.MF file and going to the Dependencies tab:
    1. org.eclipse.osgi.services
    2. org.eclipse.e4.core.services
    3. org.eclipse.e4.core.di.extensions
  2. Open the Rainbow class and inject an instance of IEventBroker into a private field broker:
    @Inject
    private IEventBroker broker;
  3. Modify the selectionChanged method, so that ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.