Developing a composite bundle

A composite bundle groups shared bundles together into aggregates. It provides one or more packages at specific versions to an OSGi application. You can also extend a deployed application by adding one or more composite bundles to the composition unit for the application. You can use OSGi application tooling to develop a composite bundle.

About this task

When you want to ensure consistent behavior from a set of shared bundles in an OSGi application, you use a composite bundle to provide that set of bundles to the application. If a required package or service is available at the same version from both a bundle and a composite bundle, the provisioning process selects the package or service from the composite bundle.

When you want to extend a deployed business-level application that contains an OSGi application, and you do not want to stop the application or modify the underlying EBA asset, you add one or more composite bundles to the composition unit.

A composite bundle is packaged as a composite bundle archive (CBA) file. This file is a compressed archive file with a .cba file extension. If the composite bundle is part of an enterprise OSGi application, the CBA file can be directly contained within the enterprise bundle archive (EBA) file for the application, or pulled in by reference from the internal bundle repository or from an external repository that can process composite bundles. A composite bundle can directly contain bundles in its CBA file. It can also include by reference bundles that are hosted alongside the CBA file within the same EBA file, or bundles that are installed in the same bundle repository.

A composite bundle is described in a composite bundle manifest file, META-INF/COMPOSITEBUNDLE.MF. This manifest file lists the OSGi bundles that are directly contained in the composite bundle, and the reference bundles that are hosted alongside the composite bundle in the same EBA file, or in the same bundle repository.

If you want to use your composite bundle to extend a deployed application, you must install the CBA file in the internal bundle repository or in an external repository that can process composite bundles. If you install a composite bundle in a bundle repository, and the composite bundle includes bundles by reference, you must ensure that the referenced bundles are also available in the same repository. If you use the internal bundle repository, and the composite bundle directly contains bundles, the contained bundles are not listed separately and are only available as part of the composite bundle. For more information, see Composite bundles.

Rational® Application Developer Version 8.5 provides graphical support for creating and packaging composite bundles. You can also use other tools.

Procedure

  1. Develop the bundles.

    See Creating a service bundle and Creating a client bundle. You might also want to explore the sample OSGi applications.

  2. Create the composite bundle manifest.

    Most OSGi application tooling, including IBM® Rational Application Developer, helps you create the composite bundle manifest. See also Example: OSGi composite bundle manifest file.

  3. Package the directly-contained bundles and the composite bundle manifest as a compressed file with a .cba file extension.
    Note: The file extension must be.cba, but the composite bundle name need not include cba.
  4. Check that all referenced bundles are available in the EBA file (if the composite bundle is part of an enterprise OSGi application), or in a bundle repository that can process composite bundles (such as the internal bundle repository).
  5. Add the CBA file to the EBA file or to the bundle repository.

What to do next