geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lin Sun <linsun....@gmail.com>
Subject Re: Whence the geronimo kernel?
Date Fri, 13 Mar 2009 03:40:35 GMT
See comments below.

Lin

On Thu, Mar 12, 2009 at 1:51 AM, Jarek Gawor <jgawor@gmail.com> wrote:
> The point I was trying to make is that with Geronimo the classloader
> hierarchy is pretty much created/setup at build time while in osgi if
> you are using Import-Package is at runtime. Here's an example. Say, we
> have configuration A that has dependency on configuration B and C.
> Both B and C have dependency on commons-logging.jar. In Geronimo it
> would be very likely that you would run into ClassCastExceptions with
> such configuration. And the only way to fix it, it would be to create
> a new configuration D that would have the dependency on
> commons-logging.jar and B and C configurations would have to be
> updated to have dependency on D.
> In osgi world, bundle B and C would define a Import-Package on the
> commons-logging package and the osgi system at runtime would figure
> out that B and C must be wired to the same bundle that provides the
> commons-logging library.
> So classloader-per-jar is important and so is the runtime dependency
> resolution to make sure that the same library is not loaded from two
> different classloaders within the hierarchy.

Here is my understanding on this scenario.  First, you don't really
need to develop a bundle
for commons-logging package(s).  Bundle B and C can just have the
commons-logging packages
on their Import-Package attribute, with the specific versions they
need, for example:

Import-Package = \
 	org.apache.commons...;version=1.1, \
 	*
When bundle A have Bundle B and C's APIs listed on Bundle A's
Import-Package attribute, it won't see the commons-logging package at
all.  It would only see the package if Bundle B/C exports the
commons-logging package on its Export-Package attribute, and Bundle A
has commons-logging package explicitly on its Import-Package
attribute.


>
> <random thoughts>
> Hmm... I'm not sure what would happen if B and C used Require-Bundle
> and specify two different bundle names for libraries that provide the
> commons-logging library. Would we would see ClassCastExceptions (same
> as in Geronimo right now) or would osgi just pick one of these bundles
> as the default?
>

Not sure about Require-Bundle.  I personally has never used it and I
never see it is being used in the OSGi repo.  Require-Bundle may not
offer the level of control that the Import-Package provides but it is
probably a lot harder to come up with the right Import-Package lists.
 I think this scenario should work just fine if using Import-Package.

Mime
View raw message