This document describes how Component manager interacts with individual component instances to manage their lifecycle.
Component instances progress through the following major lifecycle states:
Component instances may retain isolated persistent state on a storage medium while they are not running, which can be used to help them maintain continuity across restarts.
A component instance may be created in the following ways:
Every component instance has a component URL that describes how to resolve the component, and a moniker that uniquely identifies the instance by its path from the root. For more details, see component identifiers.
Resolving a component instance fetches the component declaration for the specified component URL. Component manager resolves component URLs by finding a component resolver that supports a matching URL scheme in the environment. Developers can resolve components manually using the
ffx component resolve command.
Components must successfully resolve before they can be started.
Starting a component instance loads and runs the component's program and provides it access to the capabilities that it requires.
The most common reason for starting a component instance is when another component binds to one of its exposed capabilities. Developers can also start components manually using the
ffx component start command.
Once started, a component instance continues to run until it is stopped.
The Component Framework may stop a component instance for the following reasons:
A component can implement a lifecycle handler (example) to receive a notification of events such as impending termination. Note that components may not receive these events in circumstances such as resource exhaustion, crashes, or power failure.
Component manager sets the final execution state of a component instance to shutdown to indicate that it cannot be restarted and to signal that the instance can be safely destroyed.
A component instance may be destroyed in the following ways:
Once destroyed, Component manager completely removes the instance from the component topology, including all persistent state. New instances of the same component will each have their own identity and state distinct from all prior instances.
This section describes common actions used by the Component Framework to transition the lifecycle state of component instances.
A component instance
A binds to another component instance
A connects to some capability that is provided by
B. This causes component
B to start if it is not already running.
Concretely, there are two ways that
A can bind to
Aconnects to a capability in its namespace which is exposed or offered by
B. This is the most common way.
Abinds to the
fuchsia.component.Binderframework protocol which is exposed or offered by
B. Unlike a traditional capability, this protocol is implemented by the component framework.
Note: For more details on running components during development, see Run components.