I don´t think that you can influence this... and honestly I don´t think
you should.
The clean way of loading impl classes for the service would be to offer
two impls of a Factory interface as an OSGi service. So you could define
the interfaces at one point and let the Factory service in Bundle1 load
the classes from bundle 1 and the Factory service in Bundle2 load those
in Bundle2.
Christian
Am 20.04.2012 13:43, schrieb Charles Moulliard:
Hi,
I would like to know if this is possible for a bundle to know based on
info defined in the OSGI Service registered in the OSGI Registry that
it must loads package by example com.mycompany.poc.service.Feedback
from a bundle A and not bundle B when its service definition contain a
reference to a specific filter ?
Bundle 1
<service ref="service" interface="com.mycompany.poc.service.Feedback">
<service-properties>
<entry key="version" value="1"/>
</service-properties>
</service>
Bundle 2
<service ref="service" interface="com.mycompany.poc.service.Feedback">
<service-properties>
<entry key="version" value="2"/>
</service-properties>
</service>
Bundle 3 = Client consuming service
<bean id="helloBean" class="com.mycompany.poc.client.HelloBean">
<property name="feedbackService">
<reference interface="com.xtrac.poc.service.Feedback"
filter="(version=1)"/>
</property>
</bean>
Here is the definition of the Bundle 3 Manifest
Import-Service =
com.xtrac.poc.service.Feedback
DynamicImport-Package =
com.xtrac.poc.service
This definition tells the bundle that it has do dynamically loads
classes but in this case, the OSGI runtime will load classes from
maybe Bundle A or bundle B.
Regards,
Charles Moulliard
Apache Committer
Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com