Question

I'm sure it's really simple, but I fail to understand the required XML schema to make my component listen to multiple event topics in the OSGi framework.

I want to handle the following 2 events and at some point even more:

basm/event/IAM
basm/event/COV

I tried stuff like this

<properties name="event.topics">
    <entry>basm/event/IAM</entry>
    <entry>basm/event/COV</entry>
</properties>

or

<property name="event.topics" type="String" value="basm/event/IAM,basm/event/COV" />

or

<property name="event.topics" type="String" value="basm/event/IAM" />
<property name="event.topics" type="String" value="basm/event/COV" />

Unfortunately my OSGi book only ever uses one event topic and I surprisingly couldn't find anything on the net. I tried to go by the XML schema for DS component description but failed to understand it: http://www.osgi.org/xmlns/scr/v1.2.0/scr.xsd

Was it helpful?

Solution

Try

<property name="event.topics"> basm/event/IAM basm/event/COV </property>

See 112.4.6 in the OSGi spec.

OTHER TIPS

You can use list of values like this :

<service ref="beanRef" interface="org.osgi.service.event.EventHandler">
    <service-properties>
        <entry key="event.topics">
            <list>
                <value type="java.lang.String">com/company/topic/name1</value>                    
                <value type="java.lang.String">com/company/topic/name2</value> 
            </list>                
        </entry>
    </service-properties>
</service>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top