(Quick Reference)

5.4 Application Lifecycle - Reference Documentation

Authors: Andres Almiray

Version: 1.2.0

5.4 Application Lifecycle

Every Griffon application goes through the same life cycle phases no matter in which mode they are running, with the exception of applet mode where there is an additional phase due to the intrinsic nature of applets. The application's lifecycle has been inspired by JSR-296, the Swing Application Framework.

Every phase has an associated life cycle script that will be invoked at the appropriate time. These scripts are guaranteed to be invoked inside the UI thread (the Event Dispatch Thread in Swing). The script names match each phase name; you'll find them inside griffon-app/lifecycle.

5.4.1 Initialize

The initialization phase is the first to be called by the application's life cycle. The application instance has just been created and its configuration has been read. No other artifact has been created at this point, which means that event publishing and the ArtifactManager are not yet available to the script's binding.

This phase is typically used to tweak the application for the current platform, including its Look & Feel.

Addons will be initialized during this phase.

The Initialize script will be called right after the configuration has been read but before addons are initialized. You wont have access to addon contributions.

5.4.2 Startup

This phase is responsible for instantiating all MVC groups that have been defined in the application's configuration (Application.groovy) and that also have been marked as startup groups in the same configuration file.

The Startup script will be called after all MVC groups have been initialized.

5.4.3 Ready

This phase will be called right after Startup with the condition that no pending events are available in the UI queue. The application's main frame will be displayed at the end of this phase.

5.4.4 Shutdown

Called when the application is about to close. Any artifact can invoke the shutdown sequence by calling shutdown() on the app instance.

The Shutdown script will be called before any ShutdownHandler or event handler interested in the ShutdownStart event.

5.4.5 Stop

This phase is only available when running on applet mode. It will be called when the applet container invokes destroy() on the applet instance.