5.5. Cooperation with Asynchronous Events

BundleEvents and FrameworkEvents are useful for administrative bundles. For example, a management bundle may present a user interface that enumerates all bundles currently installed in the framework. By listening to BundleEvents, it can dynamically update the list—remove an entry when the bundle is uninstalled, add an entry when a new bundle is installed, or change the status when a bundle is activated.

As another example, some diagnostic bundle may listen to FrameworkEvent.ERROR events and may report error conditions raised that way.

Let us demonstrate, in the following example, how bundles can cooperate using BundleEvent, and what to look for when dealing with asynchronously delivered events. Recall ...

Get Programming Open Service Gateways with Java Embedded Server™ Technology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.