Skip to main content



      Home
Home » Eclipse Projects » Kura » Using EventAdmin service inside an OSGI bundle
Using EventAdmin service inside an OSGI bundle [message #1748054] Fri, 18 November 2016 03:49 Go to next message
Eclipse UserFriend
Hello,

I want to use asynchronous event inside my bundle.
Thought of using the EventAdmin service but apprently this service is used to notify events between the OSGI bundles not inside one bundle.

Does it make sense to use it inside one bundle or shall I use a different technique?

Thanks!
Re: Using EventAdmin service inside an OSGI bundle [message #1748143 is a reply to message #1748054] Fri, 18 November 2016 17:00 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

I am not sure your end goal, but I see no reason why you couldn't use EventAdmin within a bundle. Obviously you need something implementing EventHandler that will receive events from the postEvent method.

Thanks,
--Dave
Re: Using EventAdmin service inside an OSGI bundle [message #1748205 is a reply to message #1748143] Mon, 21 November 2016 03:42 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

what I have is three classes: the activator, the one implementing the EventHandler and the other sending the event.
What I dont like is that the "EventAdmin m_eventAdmin;" will be set or unset only in the activator class and if I want to use it in another class I need to pass it a parameter.
From the examples that I have seen in kura, the "EventAdmin m_eventAdmin;" is usually a private variable of the Activator class and it is this class that will post the events.

Thanks,
Sabrina

[Updated on: Mon, 21 November 2016 03:43] by Moderator

Re: Using EventAdmin service inside an OSGI bundle [message #1748388 is a reply to message #1748205] Tue, 22 November 2016 11:58 Go to previous message
Eclipse UserFriend
Hello,

Kura doesn't have a use pattern quite the same as yours which is why the Activator class always posts the events. There is no rule that says the service references have to be private, you just have to be careful in how the bundles start and how the EventHandler class and event class are instantiated. It seems to me that the simplest approach would be to instantiate your EventHandler class and event class from the Activator class. This way, you could simply pass the EventAdmin service reference to the event class constructor.

Another option would be to have multiple services declared in your bundle. Then your event class could have its own activator and dependency methods.

Hope this helps.


Thanks,
--Dave
Previous Topic:what rolls kura-console.log?
Next Topic:Does KURA supports lwm2m protocol?
Goto Forum:
  


Current Time: Sun Jul 13 20:49:34 EDT 2025

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

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

Back to the top