简体   繁体   中英

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 (eg the package com.prova.xsd.config)
  • bundle C import the packages exported by the bundle B (eg 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 CI 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

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM