On 03/02/2008, Sahoo <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am confused by the manifest headers generated by maven-bundle-plugin.
> I have a class called Bar.class which is defined in a OSGi bundle called
> osgi-test2-bar like this:
>
> package sahoo.osgitest2.bar;
>
> import org.osgi.framework.*;
> import sahoo.osgitest2.foo.api.Foo;
> import sahoo.osgitest2.foo.impl.FooImpl;
>
> public class Bar implements BundleActivator {
> public void start(BundleContext context) throws Exception {
> System.out.println(Foo.class);
> System.out.println(FooImpl.class);
> }
> public void stop(BundleContext context) throws Exception { }
> }
>
> As you can see, this class uses sahoo.osgitest2.foo.api.Foo and
> sahoo.osgitest2.foo.impl.FooImpl. Both these classes are part of another
> bundle called osgi-test2-foo. When I package osgi-test2-bar, it
> generates the following manifest headers:
>
> Export-Package:
> sahoo.osgitest2.bar;uses:="sahoo.osgitest2.foo.impl,
> sahoo.osgitest2.foo.api,org.osgi.framework"
>
> Why does the uses attribute contain foo packages? They are not used in
> the interface of Bar, are they?
The "sahoo.osgitest2.bar" package imports "sahoo.osgitest2.foo.api"
therefore
Bnd will record this usage, because there's no way for it to tell whether
this will
leak outside via the API or other methods - so to be safe it appears in
"uses:".
For a good summary about why you need "uses:", read Glyn's blog entry:
http://underlap.blogspot.com/2007/10/osgi-type-safety-and-uses-directive.html
You can't just go by the method signature, as classes can leak out in other
ways.
The appearance of private packages in "uses:" is fixed in the 1.2.1-SNAPSHOTof
the bundleplugin, and this also allows you to customize "uses:" or remove
them
completely if you decide (although that's not recommended as it could lead
to
type-safety issues, as described in Glyn's blog entry).
See http://issues.apache.org/jira/browse/FELIX-459 for more details
Thanks,
> Sahoo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Cheers, Stuart