Simple question: I'm evaluating E4 yet again, and want to send a simple event with the IEventBroker
. Multiple tutorials state that's the way to go:
@Inject
private IEventBroker eventBroker;
this.eventBroker.send("org.acme.event", myEventObject);
However all of the fail to acknowledge how to register "org.acme.event" as a topic, so I won't get this exception:
Caused by: java.lang.IllegalArgumentException: invalid topic: org.acme.event
at org.osgi.service.event.Event.validateTopicName(Event.java:236)
at org.osgi.service.event.Event.<init>(Event.java:78)
at org.eclipse.e4.ui.services.internal.events.EventBroker.constructEvent(EventBroker.java:153)
at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:79)
What is the complete way to send events using the IEventBroker
?
You don't have to register event topics.
Event topic names are defined by the OSGi specification (IEventBroker
is a simplified interface to the OSGI EventAdmin
).
The problem here is that only 'A-Z', 'a-z', '0-9', '_', and '-' are allowed in the parts of the topic name. Parts are separated using '/' not '.'. So 'org/acme/event' would be OK.