Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Usage of split packages?
Usage of split packages? [message #104731] Mon, 04 February 2008 15:45 Go to next message
Dmitry Hazin is currently offline Dmitry Hazin
Messages: 6
Registered: July 2009
Junior Member
Hi all,

I'm trying to create bundles for Berkeley DB XML API. I've created 2
bundles, one that exports db.jar (Berkeley DB API) packages and one that
exports dbxml.jar (Berkeley DB XML API) packages. The problem is that
dbxml.jar contains the package with the same name as in the db.jar,
com.sleepycat.db What is the right way to deal with such situation? If I
use Export-Package: com.sleepycat.db in both bundles, I get
NoClassDefFound errors because the package is imported from one of these
bundles. Should I change the way of how I form the bundles for API or is
it possible to export this package from both bundles at the same time?

Thanks,
Dmitry
Re: Usage of split packages? [message #104772 is a reply to message #104731] Tue, 05 February 2008 07:28 Go to previous message
Danail Nachev is currently offline Danail Nachev
Messages: 110
Registered: July 2009
Senior Member
I cannot give you advice for how you can split these APIs, but if you
think you need a split package, all you need is to export the package
twice with a mandatory attribute:

** com.sleepycat.db
Export-Package: com.sleepycat.db; component="db"; mandatory:="component"

** com.sleepycat.dbxml
Export-Package: com.sleepycat.db; component="dbxml"; mandatory:="component"

In the bundle which will export the combined package:

Require-Bundle: com.sleepycat.db, com.sleepycat.dbxml
Export-Package: com.sleepycat.db

What happens is that whenever someone tries to wire to com.sleepycat.db,
it will always wire to the package exported by the combining bundle,
because the others have mandatory attributes which are usually, not
specified.
Requiring the bundles instead of importing the packages circumvent the
mandatory attribute matching and additionally permits that if the class
isn't found in the required bundles, then the search is done locally in
the bundle - the combining bundle can also have parts of the
com.sleepycat.db package.
So, the class loading behavior is the following:

1. Try to load from com.sleepycat.db
2. If 1) failed, try to load from com.sleepycat.dbxml
3. If 2) failed, try to load from the combining bundle

For more information on the subject, look in the 3.6.5 Attribute
Matching, 3.6.6 Mandatory Attributes, 3.13 Requiring Bundles (and more
specifically 3.13.3 Issues With Requiring Bundles) from the OSGi R4.1
specification.

Danail

dhazin wrote:
> Hi all,
>
> I'm trying to create bundles for Berkeley DB XML API. I've created 2
> bundles, one that exports db.jar (Berkeley DB API) packages and one that
> exports dbxml.jar (Berkeley DB XML API) packages. The problem is that
> dbxml.jar contains the package with the same name as in the db.jar,
> com.sleepycat.db What is the right way to deal with such situation? If I
> use Export-Package: com.sleepycat.db in both bundles, I get
> NoClassDefFound errors because the package is imported from one of these
> bundles. Should I change the way of how I form the bundles for API or is
> it possible to export this package from both bundles at the same time?
>
> Thanks,
> Dmitry
Previous Topic:java.lang.LinkageError
Next Topic:Equinox Embedded within WAS 6.1 in Real Live
Goto Forum:
  


Current Time: Sat Oct 25 17:48:56 GMT 2014

Powered by FUDForum. Page generated in 0.14421 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software