How to respond to close and open events for tiles within the Composite Application Framework (Mosaic)

Within the Composite Application Framework, responding to the closing of tiles can be problematic. A tile can detect its own closing. Problems arise if the tile attempts to notify other parts of the program that it is closing through calls to shared services or changing global values. Before the tile can dispatch Mosaic events to other tiles it is closed.

Underlying Mosaic is the Client Component Framework (Gravity). Gravity is an OSGi-inspired framework that allows for plugins or modules to be added and removed to Flash applications. When a tile closes, the Gravity BundleEvent.BUNDLE_UNINSTALLED event is dispatched.

Here is an example snippet passed to me that shows how to listen for Gravity-oriented events:

BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_INSTALLED, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_RESOLVED, bundleChange)
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_RESOLVING, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_STARTED, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_STARTING, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_STOPPED, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_STOPPING, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_UNINSTALLED, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_UNINSTALLING, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_UPDATED, bundleChange);
BundleContext.currentContext.addEventListener(BundleEvent.BUNDLE_UPDATING, bundleChange);

BundleContext.currentContext.addEventListener(ServiceEvent.SERVICE_MODIFIED, bundleChange);
BundleContext.currentContext.addEventListener(ServiceEvent.SERVICE_REGISTERED, bundleChange);
BundleContext.currentContext.addEventListener(ServiceEvent.SERVICE_UNREGISTERING, bundleChange);

 

Comments are closed.