1

When I register a ServiceReference I define the topics of the OSGi Events I'm publishing in a Dictionary class, like the context method definition says:

registerService(Class, service, Dictionary)

My Dictionary definition is: dictionary.put(EventConstants.EVENT_TOPIC, topics);

The topics is a String array with a few strings that define very clearly each possible event type I'm publising, like this:

String [] topics = new String[] { "ONE", "TWO" };

I would like to know what bundles are subscribed to a specific property defined in topics at the Dictionary. I mean what bundles are going to handle the publications of "TWO".

Thanks.

user2256799
  • 229
  • 1
  • 3
  • 10

1 Answers1

0

To receive events a bundle registers an EventHandler service with the topics as event.topics property. So to find the bundles that listen on certain topics you search all services of type EventHandler and check their service property event.topics.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • I get the service reference for the event handler ServiceReference sr = context.getServiceReference(EventHandler.class.getName()); and then the bundle with sr.getUsingBundles() right? – user2256799 Apr 06 '17 at 08:57