Interacting with the OSGi bundle cache
The bundle cache is a cell-wide store (or server-wide for single-server systems) of bundles 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.
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, we 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 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 Additional APIs section of the generated API documentation.
Use MBean methods with the AdminControl object of the wsadmin scripting client. For example:
objNameString = AdminControl.completeObjectName('WebSphere:type=BundleCacheManager,*') print AdminControl.invoke(objNameString, 'areAllDownloadsComplete')For more information about using MBean methods with the AdminControl object, see the "invoke" and "invoke_jmx" sections of Commands for the AdminControl object using wsadmin scripting.Some common tasks for which you might interact with the bundle cache are as follows:
- 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 we have imported an asset and not yet saved the changes to the master configuration.
- The bundle is not downloaded until you save the 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, we cannot add the asset to the application until all the bundles are downloaded. We might therefore choose to code the 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...
- 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 nternal 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 understand why the bundle download has failed.
- Download the bundle again.
Use either of the following approaches:
- Use the resetBundleDownload () method to make the bundle available for download again, 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 using the MBean interface; complete the following steps:
- Uninstall the applications that use the bundle.
- Use the removeBundleFromCache () method to remove the bundle from the bundle cache.
- Reinstall the applications.
Parent topic: Administer bundle repositories
Related tasks
Move bundles from an OSGi application to a bundle repository Administer bundles in nternal bundle repository Administer links to external bundle repositories Deploy an OSGi application as a business-level application
OSGi applications: Troubleshooting tips
Related information:
Bundle cache [Collection] Bundle cache [Settings]