Interacting with the OSGi bundle cache

The bundle cache is a cell-wide store (or server-wide for single-server systems) of bundles that are referenced by OSGi applications, and that have been downloaded from both internal and external repositories. You can interact with the bundle cache using either the administrative console, or the methods of the OSGi BundleCacheManager MBean.

About this task

You can get an up-to-date list of the bundles in the bundle cache, check if all bundles are successfully downloaded, and request that one or more bundles be downloaded again. For a given bundle, you can view the bundle size, the download status, and a list of the assets and composition units that use the bundle. You can also view and refresh the repository URL for the repository that hosts the bundle.

The main differences between interacting with the OSGi bundle cache by using the administrative console and by using the MBean interface are as follows:
  • You can use the Bundle cache [Collection] panel to change the sort order in the table, and to filter by (for example) bundle name, or by bundle state.
  • You can use the MBean interface to remove a bundle from the cache.

The methods for the OSGi BundleCacheManager MBean interface are documented in the section of the generated API documentation.

You use the MBean methods with the of the . For example:
objNameString = AdminControl.completeObjectName('WebSphere:type=BundleCacheManager,*')
print AdminControl.invoke(objNameString, 'areAllDownloadsComplete')

Some common tasks for which you might interact with the bundle cache are as follows:

Procedure

  • Interrogate the state of bundles.
    You can use the MBean interface to complete the following tasks:
    • Check the state of a specific bundle.
    • List the completed downloads.
    • List the unsuccessful downloads.
    Similarly, the state of all bundles is displayed on the Bundle cache [Collection] panel. This is one of the following states:
    Unknown
    The bundle is not in the bundle cache and there has been no request to download the bundle.
    Download requested
    A request has been issued to download the bundle, but the download has not yet begun.
    Downloading
    The bundle is downloading.
    Downloaded
    The bundle download is complete.
    Failed
    The bundle download has failed.
    Unsaved
    The bundle is unsaved if you have imported an asset and not yet saved your changes to the master configuration.
    The bundle is not downloaded until you save your changes.
  • Check that all bundle downloads are complete before adding an enterprise bundle archive (EBA) asset to a business-level application.

    If all bundle downloads are complete, the state of every bundle is displayed as Downloaded on the Bundle cache [Collection] panel.

    You can use scripting to import an EBA file as an asset, then add the EBA asset to a business-level application. However, you cannot add the asset to the application until all the bundles are downloaded. You might therefore choose to code your script to call the areAllDownloadsComplete method, then wait until the method confirms that all bundles are downloaded before adding the EBA asset to the business-level application.

  • Resolve an unsuccessful bundle download.

    If a bundle does not download, complete the following steps:

    1. Fix the cause (for example an incorrect repository address, or a network failure).

      The Bundle cache [Settings] form for the bundle shows the repository address, and includes a button to refresh this address. This is useful if a bundle has been moved, for example from the internal bundle repository to an external repository. If the bundle state is Failed, the Bundle download exceptions pane is displayed. This pane contains trace information to help you understand why the bundle download has failed.

    2. Download the bundle again.
      Use either of the following approaches:
      • Use the resetBundleDownload method to make the bundle available for download again, then use the downloadBundles method to retry the download.
      • On the Bundle cache [Collection] panel, select one or more bundles then click Download Bundle Again.
  • Remove a bundle from the cache.
    You can do this only by using the MBean interface; complete the following steps:
    1. Uninstall the applications that use the bundle.
    2. Use the removeBundleFromCache method to remove the bundle from the bundle cache.
    3. Reinstall the applications.
    If you want to repeatedly add or remove OSGi extensions without deleting the composition unit, then you can use the OSGi BundleCacheManager MBean interface and the removeBundleFromCache method. Alternatively, you can delete and readd the composition unit to the business-level application.
    Note: The bundle cache entries for the extension are automatically deleted when the composition unit that was extended is deleted. If you do not delete the composition unit from the business-level application, then the bundle cache entries are not automatically deleted.