DZone Forums
Go Back   DZone Forums > Community > Tools & IDEs > Eclipse
Reload this Page OSGi EventHandler registration using DS
Notices
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: May 2009
Default OSGi EventHandler registration using DS - 05-06-2009, 06:03 AM

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
Reply With Quote
Reply

Tags
declarative services, equinox, eventadmin, eventhandler, osgi

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Odd. No registration or email links sent kimberley.r.scott Feedback 5 06-28-2009 08:20 AM
Problem with OSGi and Webservice sinle.1011 Java 1 03-12-2009 01:03 AM
How to use URLClassLoader in a OSGi Bundle? raja00cs Eclipse 0 11-19-2008 11:04 AM
A Conceptual Problem with OSGi AlexandreSH Java 0 10-30-2008 05:23 AM
Access OSGi servicees outside OSGi environment simongdkelly Eclipse 3 02-29-2008 08:43 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com