Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Export-Package mandatory directive
Export-Package mandatory directive [message #71296] Wed, 02 August 2006 15:15 Go to next message
Erik Vanherck is currently offline Erik VanherckFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

I have a need for the mandatory directive in the Export-Package statements
but it doesn't work as I expected or perhaps I'm just doing something
wrong. Some input from the equinox gurus would be highly appreciated :)

I put the following in the manifest.mf of the exporting plugin
Export-Package: org.apache.batik;provider="com.id";mandatory:="provider",
and
Require-Bundle: org.apache.batik;provider="com.id",
in the importing plugin.

Now I have a few questions :

1) Is the syntax correct, the OSGi spec is a bit unclear and contains some
typos even :)
2) Is this supposed to work with Require-Bundle or only with Import-Package
3) Would the JDT/PDE build see these dependencies and flag them as errors
or do they ignore these
4) Would self-hosting adhere to these directives or do I need a installed
version

I was looking for the code myself to figure out what I might be doing
wrong or when it would work but got stuck in
org.eclipse.osgi.internal.resolver.isSatisfiedBy() as the only place I
could find that checks the directive. Strangely enough it isn't really
strict on what is inside the attributes.
Re: Export-Package mandatory directive [message #71468 is a reply to message #71296] Thu, 03 August 2006 18:44 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
> I put the following in the manifest.mf of the exporting plugin
> Export-Package: org.apache.batik;provider="com.id";mandatory:="provider",
> and Require-Bundle: org.apache.batik;provider="com.id",
> in the importing plugin.

The mandatory directive does not apply to Require-Bundle. You get all
packages that are exported by a bundle when you use Require-Bundle
regardless of the mandatory directives. The provider="com.id" attribute
you added to the Require-Bundle header will be ignored for resolution
purposes.

> Now I have a few questions :
> 1) Is the syntax correct, the OSGi spec is a bit unclear and contains
> some typos even :)
It would be correct if you stuck the provider="com.id" matching
attribute on an Import-Package header (i.e Import-Package:
org.apache.batick;rovider="com.id")

> 2) Is this supposed to work with Require-Bundle or only with Import-Package
Import-Package only.
> 3) Would the JDT/PDE build see these dependencies and flag them as
> errors or do they ignore these
PDE should give you package access errors if you are not allowed to see
the exported package.
> 4) Would self-hosting adhere to these directives or do I need a
> installed version
The behavior should be the same for self-hosting vs. an installed version.

If you really want to restrict the users of a package (even when they
use Require-Bundle) to a limited set of bundles then you can use the
x-friends directive. For example:

Export-Package:
org.apache.batik; x-friends:="org.apache.friend1, org.apache.friend2"

This will only allow the two bundles with the symbolic name of
org.apache.friend1 or org.apache.friend2 to access your package.

This approach has two drawbacks.
1) it is brittle. When you want another bundle (org.apache.friend3) to
have access to the package then you need to update your bundle to
include the new friend.
2) by default the Equinox resolver is not strict WRT the x-friends
directive. You must set the system property osgi.resolverMode=true to
enable strict resolving. But PDE will give you warnings if you are
trying to use a package that you are not a "friend" to at development time.

>
> I was looking for the code myself to figure out what I might be doing
> wrong or when it would work but got stuck in
> org.eclipse.osgi.internal.resolver.isSatisfiedBy() as the only place I
> could find that checks the directive. Strangely enough it isn't really
> strict on what is inside the attributes.

org.eclipse.osgi.internal.resolver.ImportPackageSpecificatio nImpl.isSatisfiedBy
is where the real work is done WRT the mandatory directives. Note that
matching the attribute values is done before the code where the
mandatory directive is checked. The code that checks the mandatory
directive is only checking for the existence of the matching attribute
on the Import-Package statement not the actual value because that was
already checked above.

HTH

Tom
Previous Topic:plugin startup configuration
Next Topic:using ecore in an equinox runtime
Goto Forum:
  


Current Time: Tue Apr 16 21:46:30 GMT 2024

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

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

Back to the top