On 07.03.2016 20:49, BJ Hargrave wrote:
If the service publisher imports the package with the advertised
service type, then only bundles which either (a) import the same
package or (b) do not import the package at all will normally see the
service (unless they use getAllServiceReferences or the all option in
ServiceTracker). This is to ensure type safety between the service
publisher and service user.
So if the bundle that publishes the ServiceFactory does not import the
interface package then the ServiceFactory should be visible to all bundles?
Strangely this does not seem to work. When I remove the loadClass call
the service does not seem to be visible. I publish the ServiceFactory
using the dsw-cxf bundle which should not import the user service
interfaces... damn ... I think I found the issue. The itests use some
very basic interfaces like String and Runnable. These are visible of
course.... though I am not sure if they cause an import at all.
If the above works then my plan is to load the interface classes only
when the service is retrieved from the factory and using the consumer
bundle. So I hope to avoid the DynamicImport and also avoid to "pollute"
the dsw-cxf bundle with the imports of user packages.
A proxy bundle solution as used by ECF can help since the proxy bundle
can import the proper version of the package for the service consumers
is needs to support. This also allows the support for multiple
versions of the package since each proxy bundle can be wired to a
different version of the package.
ECF uses only one proxy bundle but I think if they avoid loading the
interface classes in the proxy bundle this should be fine.
As I will need a bundle for the DistributionProvider API anyway I wonder
if I could simply use this bundle to publish the services. It should
import very few packages .. but I guess a clean solution will need to be
a really clean bundle without imports for the proxy bundle.
In any case many thanks. Your explanations already helped me a lot to
understand the mechanism.
Christian
--
BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargr...@us.ibm.com
-- Christian Schneider http://www.liquid-reality.de Open Source
Architect http://www.talend.com
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev