Dmitry, Another thought that occurs to me is that your second option (one large bundle containing all the third party libs), while certainly unattractive, is a reasonable intermediate step towards having all of the libraries as individual bundles.
As long as you use Import-Package in your bundles rather than Require-Bundle, you will be able to gradually dissolve the big lump into smaller pieces without changing the bundles that depend on those libraries. Neil On Wed, Mar 18, 2009 at 10:18 PM, Dmitry Skavish <[email protected]> wrote: > Neil, > > Thanks. I thought about it, but rejected because we have about 150 those jars > and most of them are not available in bundleized version. I believe that > would be the right way to do, it just requires some work which I am not sure > I can afford right now. > > So I guess this is the "official" way to approach it, right? > > Is there a tool which can convert a jar into a bundle? > > Thanks! > > -----Original Message----- > From: Neil Bartlett [mailto:[email protected]] > Sent: Wednesday, March 18, 2009 6:02 PM > To: [email protected] > Subject: Re: how to use classes from system classloader > > Dmitry, > > You appear to be missing the most obvious solution, which is to turn > each of the third party libraries into its own bundle. And in many > cases you won't have to do this yourself, you can use an already > "bundleized" version of the library from one of the common > repositories such as OBR, SpringSource, Eclipse Orbit, etc. > > Regards, > Neil > > On Wed, Mar 18, 2009 at 9:47 PM, Dmitry Skavish > <[email protected]> wrote: >> 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 >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

