If you reference the service with a filter then OSGi will inject the correct impl object. You will not even need to have a dynamic import as the impl is installed by the bundle1.

So this should simply work. What exception do you get?

Christian

Am 20.04.2012 17:55, schrieb Charles Moulliard:
Bundle 1 and Bundle 2 contain a different implementation of the interface which is exposed as OSGI service

Bundle 1

<bean id="service" class="com.mycompany.poc.service.impl.FeedbackTeamWS"/>

<service ref="service" interface="com.mycompany.poc.service.Feedback">
<service-properties>
<entry key="version" value="1"/>
</service-properties>
</service>

Bundle 2

<bean id="service" class="com. mycompany.poc.service.impl.FeedbackTeamDB"/>

<service ref="service" interface="com.mycompany.poc.service.Feedback">
<service-properties>
<entry key="version" value="2"/>
</service-properties>
</service>

So the bundle C do an OSGI lookup to retrieve using as key the interface name "com.mycompany.poc.service.Feedback", the class implemented in bundle 1 or bundle 2.

What would be great is that the bundle C when the following bean is instantiated loads the class from the bundle 1 as the filter of the reference to be found corresponds to it

<property name="feedbackService">
<reference interface="com.mycompany.poc.service.Feedback" filter="(version=1)"/>
</property>

Intrinsically we know that the class implementing this interface belongs to bundle 1 as filter = 1 = OSGI service exposed by bundle 1 = class = com.mycompany.poc.service.impl.FeedbackTeamWS


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com

Reply via email to