Hi
I have an RCP application and use the OSGI events to communicte internally.
When I run the same thing in RAP, the events do not work. I mean, the handler does not get called.
public static void doPostEvent (String topic, Dictionary<String, Object> props) {
System.out.printf("Util.doPostEvent() «%s»\n", topic );
Event event = new Event (topic, props);
BundleContext ctx = Activator.getDefault().getBundle().getBundleContext();
ServiceReference<?> ref = ctx.getServiceReference(EventAdmin.class.getName());
if( ref != null){
EventAdmin admin = (EventAdmin) ctx.getService(ref);
admin.sendEvent(event);
ctx.ungetService(ref);
}
}
public static ServiceRegistration<?> registerEventHandler(String topic, Consumer<Event> handler) {
System.out.printf("Util.registerEventHandler() «%s» %s\n", topic, handler );
BundleContext ctx = Activator.getDefault().getBundle().getBundleContext();
Dictionary<String, String> props = new Hashtable<String, String>();
props.put(EventConstants.EVENT_TOPIC, topic);
ServiceRegistration<?> reg = ctx.registerService(EventHandler.class.getName(), new EventHandler() {
public void handleEvent(Event event) {
System.out.printf("Util.registerEventHandler(...).new EventHandler() «%s»\n", event.getTopic() );
handler.accept(event);
}
}, props);
return reg;
}
on console i see the printout for register and sending the event, but the printing for the handler is missing.
Util.registerEventHandler() «PlanData/Instance» ....
Util.doPostEvent() «PlanData/Instance»
these are my defined dependencies:
Require-Bundle: org.eclipse.rap.ui;bundle-version="2.3.1";resolution:=optional,
org.eclipse.ui;bundle-version="3.106.0";resolution:=optional,
org.eclipse.core.runtime;bundle-version="3.10.0",
org.eclipse.ui.forms;bundle-version="3.6.100";resolution:=optional,
org.eclipse.rap.ui.forms;bundle-version="2.3.1";resolution:=optional,
org.eclipse.persistence.moxy;bundle-version="2.5.0",
org.eclipse.osgi.services;bundle-version="3.4.0"
Does someone have an idea?
thx
Frank