Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Can fragments have dependency on other fragments
Can fragments have dependency on other fragments [message #721717] Fri, 02 September 2011 16:38 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

I have fragment A and B. I have exported a package from fragment A and then import that package from within fragment B, but it seems that the package is not recognized from fragment B, is it possible at all to do this ?

Thanks & Regards,

Setya
Re: Can fragments have dependency on other fragments [message #721764 is a reply to message #721717] Fri, 02 September 2011 19:19 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
The short answer is yes you should be able to do this and the OSGi runtime fully supports this.

Do fragments A and B share the same host? If so then fragment B really does not need to import the package (by import I mean with the Import-Package manifest header). In fact this could result in a substituted export if the host ends up getting wired to another provider of the package. Conceptually fragments become part of the hosts they get attached to so if both A and B get attached to the same host it is like you have a single bundle which exports and imports the same package. This is referred to as substitutable packages.

In such a case I recommend you have fragment A provide some capability using the Provide-Capabilty header from the OSGi R4.3 specification (note this is only implemented in Equinox 3.7 Indigo release and later). Then you can have fragment B require the capability using the Require-Capability header. This avoids the need to import the package from B and also allows you to avoid exporting the package from A if this package is not intended to be used by other bundles.

All this is different if fragment A and B are attached to different hosts. In that case you should continue to export (using Export-Package) and import (using Import-Package) the package. With all that said I suspect you are actually running into the issue at development time using PDE and not at runtime. PDE does not automatically expose the content from fragments as API on the class path for compilation purposes. See the following thread for a similar discussion: http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg01608.html

HTH

Tom
Re: Can fragments have dependency on other fragments [message #721796 is a reply to message #721764] Fri, 02 September 2011 22:31 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

Thank you for your response.

Yes, fragment A & B share the same host.

One more thing that I forgot to mention is that package exposed by fragment A does not exist in the host.

Does your explanation still valid with above condition ? Because up until know the class editor still reports unable to resolve types that come from classes in that package.

Thanks & Regards,

Setya
Previous Topic:behaviors of XML editors for manifest and component.xml
Next Topic:How to bundle database drivers and expose a connection pool?
Goto Forum:
  


Current Time: Thu Mar 28 22:19:51 GMT 2024

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

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

Back to the top