OSGI: How to find out what bundles are subscribed to a specific property defined on my service reference dictionary?

45 views Asked by At

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.

1

There are 1 answers

1
Christian Schneider On

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.