Showing posts with label fragment. Show all posts
Showing posts with label fragment. Show all posts

Sunday, December 6, 2015

Fragments in OSGI - Eclipse


A Bundle fragment, or simply a fragment, is a bundle whose contents are made available to another bundle (the fragment host). Importantly, fragments share the classloader of their parent bundle. One notable difference is that fragments do not participate in the lifecycle of the bundle, and therefore cannot have an Bundle-Activator.


Example:
These are 2 plugins which does not have any activator classes.
org.eclipse.epp.logging.aeri.ui
org.eclipse.epp.logging.aeri.ide - Host Plugin

And, In org.eclipse.epp.logging.aeri.ide plugin MANIFEST.MF file, you can find below section:
Fragment-Host: org.eclipse.epp.logging.aeri.ui;bundle-version="1.0.0"


At runtime the fragment is merged with its host plug-in and for the runtime both projects are just one. Fragments are always optional for their host plug-in and the host plug-in doesn't even know that it exists.