Application bundles, use bundles and provision bundles

Application bundles are instance-specific, and each instance of an application includes its own instance of the bundle. Shared bundles are not instance-specific, and a single instance of a package or service from a shared bundle can be used by many applications. Shared bundles are further sub-divided into use bundles and provision bundles.

Application bundles

Application bundles are bundles that you create specifically for your application. They are instance-specific or isolated; that is, they are not intended to be shared. They are referenced in the application manifest in the Application-Content header.

Shared bundles

Shared bundles are not application-specific. A single instance of a package from a shared bundle can be used by many applications. Shared bundles cannot import packages or services from application bundles. Shared bundles must be provided by reference rather than contained directly in an application.

Shared bundles are further subdivided into use bundles and provision bundles:
Use bundles
A use bundle provides at least one package to an application bundle. Use bundles are shared bundles that are referenced in the application manifest in the Use-Bundle header.
By specifying a particular shared bundle as a use bundle, you can control which bundle is provisioned to provide a shared package. For example, if there are two possible providers of a package, bundle A and bundle B, and there is a use bundle statement for bundle A, then bundle A is always provisioned and used.
Provision bundles
A provision bundle provides at least one package or service to an application bundle, a use bundle or another provision bundle. Provision bundles are not referenced in the application manifest, and your application does not know how the requirement for each provision bundle is satisfied.

If you have two separate OSGi applications, and you want them to share the same API classes, you can package those classes as a shared bundle then reference that bundle in the Use-Bundle header of both application manifests. For administrators, another benefit of use bundles is that you can monitor and update them using the administrative console or wsadmin commands.

Bundle usage and bundle provisioning terminology

OSGi bundles can be stored in any of the following locations:
  • The enterprise bundle archive (EBA) file for the application.
  • The internal bundle repository.
  • External OSGi bundle repositories.

Application bundles can be stored either in the EBA file or in a repository. Shared bundles are stored in a repository (otherwise they cannot be shared).

The process of getting bundles from the repositories is known as provisioning. For provisioning purposes, the following terminology is used for bundles:
Referenced bundles
A referenced bundle is a bundle that is referenced in the application manifest, and stored in a repository.
Dependency bundles
A dependency bundle is a bundle that is not referenced in the application manifest, but that is used by bundles that are referenced in the application manifest, or by other dependency bundles.
This is how the terminology for bundle usage (that is, application, use and provision bundles) maps to the terminology for bundle provisioning (that is, referenced and dependency bundles):
  • Application bundles that are not directly contained in the EBA file are instance-specific referenced bundles.
  • Use bundles are shared referenced bundles.
  • Provision bundles are shared dependency bundles.