Hello,
I'm trying to use the OSGi EventHandler to listen for events posted by an EventAdmin service (the EventAdmin is an Equinox implementation). Using Declarative Services I'm trying to register the EventHandler:
<component name="MyComponentName" immediate="true">
<implementation class="com.impl.ImplementationClass">
<service>
<provide interface="org.osgi.service.event.EventHandler"/>
<provide interface="com.AnotherInterface"/>
</service>
<property name="event.topics" value="com/*"/>
</component>
Note that another interface is registered as well, but this should be possible as the "service" element allows multiple "provide" elements. This configuration does not lead to the handleEvent() method of the EventHandler implementation class being called, while an event is posted with a correct topic.
When the second "provide" element (<provide interface="com.AnotherInterface"/>) is removed from the configuration however, it does work.
I looked into how the services were registered in the two cases. In the first case this is what the service registration looks like:
{org.osgi.service.event.EventHandler, com.AnotherInterface}={event.topics=com/*, component.name=MyComponentName, component.id=13, service.id=34}
Registered by bundle: initial@reference:file:../mybundle/ [52]
No bundles using service.
In the second case:
{org.osgi.service.event.EventHandler}={event.topic s=com/*, component.name=MyComponentName, component.id=13, service.id=35}
Registered by bundle: initial@reference:file:../mybundle/[52]
Bundles using service:
initial@reference:file<img src="imag....v20080225.jar/ [43]
The difference is that in the second case (in which handling event does work) a using bundle is mentioned (which is the bundle containing the EventAdmin), while in the first case it is not. I'm guessing without the using bundle registered no events will be sent to the EventHandler.
Any ideas why the first configuration does not work? Am I doing something wrong or forgetting something? Thank you in advance for your help.
Best regards,
Arjen