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.
- Add the following bundles as dependencies to the
com.packtpub.e4.application
project, by double-clicking on the project'sMETA-INF/MANIFEST.MF
file and going to the Dependencies tab:org.eclipse.osgi.services
org.eclipse.e4.core.services
org.eclipse.e4.core.di.extensions
- Open the
Rainbow
class and inject an instance ofIEventBroker
into aprivate
fieldbroker
:@Inject private IEventBroker broker;
- 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.