You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Rodrigo Madera <ro...@gmail.com> on 2007/09/22 11:20:40 UTC
Proper Dependencies with BND
I have a doubt regarding BND...
Let's say that the bundle WorldwideGreeter-1.0.jar exports the package "
com.acme.greeter.*".
With BND + Maven, you could add a dependency that would actually see the
bundle's JAR file as a normal Maven dependency. This means that every class
in the CLASSPATH is available to be added, depending on the Export-Package
directive (correct me if I'm wrong please).
However, OSGi defines it's own importing mechanism, based on directives on
the MANIFEST.MF file.
So the thing is, how would be the correct way of specifying dependencies of
OSGi bundles when these are other bundles?
If GreeterUser-1.0.jar needs to import the bundle's "com.acme.greeter.*"
package, how can we do this without "getting messy" with BND and CLASSPATH
floods?
Thanks again for your input,
Rodrigo
Re: Proper Dependencies with BND
Posted by Rodrigo Madera <ro...@gmail.com>.
Excellent response, thank you!
One more valuable resource for BND users.
Thanks,
Rodrigo
On 9/22/07, Stuart McCulloch <st...@jayway.net> wrote:
>
> On 22/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
> >
> > I have a doubt regarding BND...
> >
> > Let's say that the bundle WorldwideGreeter-1.0.jar exports the package "
> > com.acme.greeter.*".
> >
> > With BND + Maven, you could add a dependency that would actually see the
> > bundle's JAR file as a normal Maven dependency. This means that every
> > class
> > in the CLASSPATH is available to be added, depending on the
> Export-Package
> > directive (correct me if I'm wrong please).
>
>
> that is correct, everything on the compilation classpath is available...
> except
> provided scope dependencies, because the bundleplugin mojo currently has
> @requiresDependencyResolution set to runtime
>
> However, OSGi defines it's own importing mechanism, based on directives on
> > the MANIFEST.MF file.
>
>
> also true - but BND is about *building* bundles for the OSGi runtime
>
> for example, I have a bundle A with several packages - I might want to
> include
> classes from one of those packages inside bundle B, just in case A isn't
> installed
> (there are several use-cases for this)
>
> so I add A to bundle B's classpath and use BND to include the one package
> I
> want
> and export it. Bnd will also add an import clause for this package ...
> which
> means
> if A is already installed and resolved then bundle B will get these
> classes
> from A
> - but if A isn't there then B can use it's internal copy :)
>
> So the thing is, how would be the correct way of specifying dependencies
> of
> > OSGi bundles when these are other bundles?
>
>
> in general, use "provided" scope for dependencies that are bundles
> (unless you want to include their classes as mentioned above...)
>
> If GreeterUser-1.0.jar needs to import the bundle's "com.acme.greeter.*"
> > package, how can we do this without "getting messy" with BND and
> CLASSPATH
> > floods?
>
>
> it shouldn't get messy :)
>
> BND was designed to work against large classpaths which you break into
> bundles
> by using a different directive file per bundle (see
> http://www.aqute.biz/Code/Bnd)
>
> it uses a "pull" approach - ie. the contents of a bundle are defined by:
>
> Export-Package, Private-Package and Include-Resource
>
> bundle imports are automatically calculated based on the bundle contents
>
> in your example just add WorldwideGreeter as a provided scope dependency
> to GreeterUser, and leave Import-Package as the default - BND should
> detect
> that GreeterUser uses com.acme.greeter and add it to the bundle imports.
>
> but I recommend you read http://www.aqute.biz/Code/Bnd for the full story!
>
> HTH
>
> Thanks again for your input,
> > Rodrigo
> >
>
>
>
> --
> Cheers, Stuart
>
Re: Proper Dependencies with BND
Posted by Stuart McCulloch <st...@jayway.net>.
On 22/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
>
> I have a doubt regarding BND...
>
> Let's say that the bundle WorldwideGreeter-1.0.jar exports the package "
> com.acme.greeter.*".
>
> With BND + Maven, you could add a dependency that would actually see the
> bundle's JAR file as a normal Maven dependency. This means that every
> class
> in the CLASSPATH is available to be added, depending on the Export-Package
> directive (correct me if I'm wrong please).
that is correct, everything on the compilation classpath is available...
except
provided scope dependencies, because the bundleplugin mojo currently has
@requiresDependencyResolution set to runtime
However, OSGi defines it's own importing mechanism, based on directives on
> the MANIFEST.MF file.
also true - but BND is about *building* bundles for the OSGi runtime
for example, I have a bundle A with several packages - I might want to
include
classes from one of those packages inside bundle B, just in case A isn't
installed
(there are several use-cases for this)
so I add A to bundle B's classpath and use BND to include the one package I
want
and export it. Bnd will also add an import clause for this package ... which
means
if A is already installed and resolved then bundle B will get these classes
from A
- but if A isn't there then B can use it's internal copy :)
So the thing is, how would be the correct way of specifying dependencies of
> OSGi bundles when these are other bundles?
in general, use "provided" scope for dependencies that are bundles
(unless you want to include their classes as mentioned above...)
If GreeterUser-1.0.jar needs to import the bundle's "com.acme.greeter.*"
> package, how can we do this without "getting messy" with BND and CLASSPATH
> floods?
it shouldn't get messy :)
BND was designed to work against large classpaths which you break into
bundles
by using a different directive file per bundle (see
http://www.aqute.biz/Code/Bnd)
it uses a "pull" approach - ie. the contents of a bundle are defined by:
Export-Package, Private-Package and Include-Resource
bundle imports are automatically calculated based on the bundle contents
in your example just add WorldwideGreeter as a provided scope dependency
to GreeterUser, and leave Import-Package as the default - BND should detect
that GreeterUser uses com.acme.greeter and add it to the bundle imports.
but I recommend you read http://www.aqute.biz/Code/Bnd for the full story!
HTH
Thanks again for your input,
> Rodrigo
>
--
Cheers, Stuart