Hi all,

I have another question concerning multiplicity. Given my sample
configuration

<component name="CrawlerControllerComponent">
   ...
    <reference name="crawlers" multiplicity="1..n"
target="CrawlerComponent SpecialCrawlerComponent">
        <binding.sca />
    </reference>

</component>
 
<component name="CrawlerComponent">
    <implementation.java class="impl.CrawlerImpl"/>
    <service name="Crawler">
        <interface.java interface="interfaces.Crawler" />

    </service>
</component>    

<component name="SpecialCrawlerComponent">
    <implementation.java class="impl.SpecialCrawlerImpl"/>
    <service name="Crawler">
        <interface.java interface="interfaces.Crawler" />
    </service>
</component>


I want to create a ServiceReference to one of the Crawlers.
Without multiplicity (assuming the reference name would be "crawler"),
the code would look like this:

        ServiceReference<Crawler> crawlerRef =
componentContext.getServiceReference(Crawler.class, "crawler");
        return crawlerRef.getService();


But How can I achieve this using multiplicity ? How can I choose for
what target a ServiceReference is created?
By simply using this code
        ServiceReference<Crawler> crawlerRef =
componentContext.getServiceReference(Crawler.class, "crawlers");
        return crawlerRef.getService();
always a ServiceReference to the first target (CrawlerComponent) is
created.


Bye,
Daniel

Reply via email to