Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Osgi eclipse: how to export package from a fragment bundle and make them visible to an external bundle?

Starter situation (without any error):

  • I have three different bundles: bunbdle A (called org.apache.xmlbeans), bundle B and bundle C
  • bundle B import some packages exported from the bundle A
  • bundle B export some packages (e.g. the package com.prova.xsd.config)
  • bundle C import the packages exported by the bundle B (e.g. the package com.prova.xsd.config)

Now I make bundle B a fragment of the bundle A (fragment-host) adding the directive Fragment-Host: org.apache.xmlbeans in the MANIFEST of the bundle B

After this change there are NO errors in the MANIFEST.MF of all the bundles (A,B,C) but in the classes .java of the bundle C I have the compile error: "The import com.prova.xsd.config cannot be resolved" associated to the import at the head of the file .java.

What is the problem? How can I fix it?

Thanks a lot,

Andrea

like image 843
Andrea Avatar asked Oct 01 '22 19:10

Andrea


1 Answers

You need to add "Eclipse-ExtensibleAPI: true" to the Manifest of your host plugin A.

From Eclipse Help: OSGi Manifest Bundle :

The Eclipse-ExtensibleAPI Header

The Eclipse-ExtensibleAPI is used to specify whether a host bundle allows fragment bundles to add additional API to the host. This header should be used if a host bundle wants to allow fragments to add additional packages to the API of the host. If this header is not specified then a default value of 'false' is used. Note that this header is only used by tooling (PDE) to construct proper class paths for building. The runtime does not use this header at all. At runtime a fragment is always allowed to add additional packages, classes and resources to the API of the host. The Eclipse-ExtensibleAPI header must use the following syntax:

Eclipse-ExtensibleAPI ::= ( 'true' | 'false' )

The following is an example of the Eclipse-ExtensibleAPI header:

Eclipse-ExtensibleAPI: true
like image 177
Barnski Avatar answered Oct 04 '22 21:10

Barnski