Hello,

I am complete novice in OSGi and I am stuck trying to find the best solution to 
the following problem (which I think should be fairly typical):

We have a large desktop application which we are trying to break into OSGi 
bundles. The application uses quite a few third party libraries. We want to 
make those libraries available to every bundle. But it does not seem to be that 
easy. I tried several approaches and I am satisfied with none :(

I know about properties: FRAMEWORK_SYSTEMPACKAGES and FRAMEWORK_BOOTDELEGATION. 
So I set FRAMEWORK_BOOTDELEGATION to "*" and I DO NOT set 
FRAMEWORK_SYSTEMPACKAGES to anything.

What I discovered is that in this case if package which comes from libraries on 
a classpath IS present in Import-Package in bundle's manifest then this bundle 
won't be resolved (error). But if the package IS NOT present in Import-Package 
(or is marked with resolution=optional) then the bundle will be resolved 
(naturally).

But in the second case I can use the classes from this package from inside the 
bundle! So I don't have package in Import-Package, but I can use classes from 
this package! But when I have package in Import-Package I can't use classes 
(the bundle is not even resolved)!

It seems to me there is inconsistency here between bundle resolution process 
and classloading.

Yes, I know that if I use FRAMEWORK_SYSTEMPACKAGES property and put all my 
third-party packages into it the bundle resolution will work just fine.

So as far as I understand there are 3 ways to make third libraries available to 
all my bundles:


1.       put all the packages from those libraries into 
FRAMEWORK_SYSTEMPACKAGES property and set FRAMEWORK_BOOTDELEGATION to "*"

2.       put all the libraries (jars) into a separate bundle

3.       set FRAMEWORK_BOOTDELEGATION to "*" and remove packages of those 
third-party jars from Import-Package entry from all bundle's manifests (or mark 
them with resolution=optional)

I don't like the first case because I need to extract package names from all 
those third-party jars at build time and somehow pass this information to my 
java code which starts felix so that I can put it into FRAMEWORK_SYSTEMPACKAGES 
property.

I don't like the second case because I end up with one huge bundle which 
contains all the third-party libraries. I don't like it for several reasons, 
one being load time and another pure aesthetics.

I don't like the third case because that is not how it is supposed to be used 
and basically is a hack.

Am I missing anything? What is the "official" way of achieving it?

Thank you!
--
Dmitry Skavish

Reply via email to