1# Stage Model Development Overview 2 3<!--Kit: Ability Kit--> 4<!--Subsystem: Ability--> 5<!--Owner: @ccllee1; @Luobniz21--> 6<!--Designer: @ccllee1--> 7<!--Tester: @lixueqing513--> 8<!--Adviser: @huipeizi--> 9 10## Basic Concepts 11 12The following figure illustrates the stage model. 13 14**Figure 1** Stage model 15 16 17 18 19- [AbilityStage](abilitystage.md) 20 21 Each [HAP](../quick-start/hap-package.md) of the Entry or Feature type has an instance of the AbilityStage class at runtime. When the code in the [HAP](../quick-start/hap-package.md) is loaded to a process for the first time, the system creates an AbilityStage instance first. 22 23- [UIAbility](uiability-overview.md) and [ExtensionAbility](extensionability-overview.md) components 24 25 The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development. 26 27 - UIAbility is a type of application component that provides the UI for user interaction. For example, with a UIAbility component, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the **Back** button to return to the liquid layout. The lifecycle of the UIAbility component contains the **Create**, **Destroy**, **Foreground**, and **Background** states. Display-related states are exposed through WindowStage events. 28 29 - ExtensionAbility is used for specific scenarios. You cannot derive directly from ExtensionAbility. Instead, use the derived classes of ExtensionAbility for your scenarios, such as FormExtensionAbility for widget scenarios, InputMethodExtensionAbility for input method scenarios, and WorkSchedulerExtensionAbility for deferred task scenarios. For example, to enable a user to create a widget on the home screen, you must derive a class from FormExtensionAbility, implement callbacks, and configure the capability in the configuration file. The derived class instances are created by applications and their lifecycles are managed by the system. In the stage model, you must use the derived classes of ExtensionAbility to develop custom services of third-party applications based on your service scenarios. 30 31 A HAP can contain one or more UIAbility or ExtensionAbility components, which share the same AbilityStage instance at runtime. When the code (whether it is a UIAbility or an ExtensionAbility component) in the [HAP](../quick-start/hap-package.md) is first loaded into the process, the system creates the corresponding AbilityStage instance. 32- [WindowStage](../reference/apis-arkui/arkts-apis-window-WindowStage.md) 33 34 Each UIAbility instance is bound to a WindowStage instance, which functions as the window manager in the application process. The WindowStage class instance contains a main window. In other words, a UIAbility instance holds a main window through WindowStage, which provides a drawing area for ArkUI and can load different ArkUI pages. 35 36- [Context](application-context-stage.md) 37 38 In the stage model, Context and its derived classes provide a variety of resources and capabilities that can be called during the runtime. The UIAbility component and ExtensionAbility derived classes have different Context classes. These classes, which all inherit from the base class Context, provide different capabilities. 39 40## Elements 41 42The [Application Models](application-models.md) topic introduces the elements of the application model, which mainly include application components, configuration files, process models, thread models, and mission management models. Below, we use the Demo.app application as an example to introduce the elements of the stage model from both the development and runtime phases. 43 44The Demo.app application mainly implements the following features: 45- Implements two independent windows with UIs (UIAbilityA and UIAbilityB) for user interaction. 46- Implements widget functionality to allow users to add the application's widgets to the home screen. 47 48**Figure 2** Elements of the stage model 49 50 51 52**Development phase**: You need to use the application components provided by the stage model (UIAbility and ExtensionAbility components) to develop application functionalities and register relevant application information in the configuration files (**app.json5** and **module.json5**). 53 54- Application components: In this example, UIAbility components are used to develop modules with UIs for interaction, and FormExtensionAbility components are used to develop the widget module, implementing widget addition, deletion, and updates. To reduce dependencies and coupling between different modules, UIAbility and FormExtensionAbility implementations are placed in separate HAP files, whereas common functionalities shared by both are placed in an HSP file. 55 56- Configuration files: You can configure the application name, version number, and application icon in **app.json5**, and component lists and permissions of the HAP in **module.json5**. These configuration details are registered with the system during application installation, facilitating system and other modules to obtain detailed information about the application and interact with it. 57 58**Runtime phase**: When the application is installed and running on the device, the system uses a set of application process and thread management mechanisms to ensure orderly operation. <!--Del-->Additionally, a mission management mechanism is provided to manage mission creation, destruction, and foreground/background switching.<!--DelEnd--> 59 60- Process model: UIAbility components run in the main process by default, whereas FormExtensionAbility components run in separate processes. UIAbility and FormExtensionAbility components are process-isolated from each other. 61 62- Thread model: The stage model provides mechanisms such as Worker and TaskPool to support multithreaded development scenarios. If the application has complex, time-consuming logic to handle, it can create Worker threads to offload the processing. 63 64<!--Del--> 65- Mission management model: When a UIAbility is running, the system creates a corresponding mission. For example, when UIAbilityA in the figure is running, the mission for the Demo.app application can be seen in the recent task list. When the user taps this mission, the system brings UIAbilityA to the foreground. 66<!--DelEnd--> 67 68 69 70## How to Develop 71 72During application development based on the stage model, the following tasks are involved in the application model. 73 74**Table 1** Stage model development process 75 76| Task| Description| Guide| 77| -------- | -------- | -------- | 78| Application component development| Use the UIAbility and ExtensionAbility components of the stage model to develop your application.| - [Application- or Component-Level Configuration](application-component-configuration-stage.md)<br>- [UIAbility Component](uiability-overview.md)<br>- [ExtensionAbility Component](extensionability-overview.md)<br>- [AbilityStage Component Manager](abilitystage.md)<br>- [Context](application-context-stage.md)<br>- [Component Startup Rules](component-startup-rules.md)| 79| Process model development| Learn the process model and common IPC modes of the stage model.| [Process Model Overview](process-model-stage.md)| 80| Thread model development| Learn the thread model and common inter-thread communication modes of the stage model.| [Thread Model Overview](thread-model-stage.md)| 81| Configuration file development| Learn the requirements for developing application configuration files in the stage model.| [Application Configuration File](config-file-stage.md)| 82