Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » OSGI Event on RAP not working
OSGI Event on RAP not working [message #1480066] Thu, 20 November 2014 00:00 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 152
Registered: July 2009
Senior Member
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



Re: OSGI Event on RAP not working [message #1480129 is a reply to message #1480066] Thu, 20 November 2014 01:15 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 152
Registered: July 2009
Senior Member
after some digging ...

ServiceReference<?> ref = ctx.getServiceReference(EventAdmin.class.getName());


res is null.

Is there a solution for it?


Re: OSGI Event on RAP not working [message #1480163 is a reply to message #1480129] Thu, 20 November 2014 01:55 Go to previous message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 152
Registered: July 2009
Senior Member
Solved.
It turns out, in case of RAP i needed to add the org.eclipse.equinox.event plugin manually.

Previous Topic:Client Error with 3.0 M3
Next Topic:Custom Widget with Session Timeout
Goto Forum:
  


Current Time: Thu Apr 09 15:27:26 GMT 2020

Powered by FUDForum. Page generated in 0.02032 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top