元件管理員會在相關環境中尋找支援相符網址架構的解析器,然後使用 fuchsia.component.resolution.Resolver
通訊協定傳送要求,藉此解析元件網址。
如果解析成功,元件解析器會傳回 ComponentDecl
,也就是 元件資訊清單的 FIDL 表示法。如果要解析的元件具有相關聯的套件,元件解析器也會傳回套件目錄的 fuchsia.io.Directory
句柄。
提供解析器功能
如要提供解析器能力,元件必須宣告 resolver
能力,其 path
會指定實作 fuchsia.component.resolution.Resolver
的 FIDL 通訊協定,並從元件的
{
capabilities: [
{
resolver: "my_resolver",
path: "/svc/fuchsia.component.resolution.Resolver",
},
],
}
元件管理員會將要求提交至這個通訊協定,以解析元件網址。
轉送解析工具功能
如要進一步瞭解架構如何轉送元件功能,請參閱「功能轉送」。
公開
公開解析器能力可讓元件的父項存取該能力:
{
expose: [
{
resolver: "my_resolver",
from: "self",
},
],
}
提供
提供解析器能力可讓子元件存取該能力:
{
offer: [
{
resolver: "my_resolver",
from: "self",
to: [ "#child-a" ],
},
],
}
註冊元件解析器
元件解析器會透過元件的環境提供給元件。如要在環境中註冊新的解析器,請在 environments
宣告的 resolvers
部分新增項目:
environments: [
{
name: "my-environ",
extends: "realm",
resolvers: [
{
resolver: "my_resolver",
scheme: "my-scheme",
from: "parent",
}
],
},
]
系統會使用已註冊的解析器,解析網址架構與提供的 scheme
相符的元件網址。
如要進一步瞭解如何將環境套用至元件,請參閱環境說明文件。
架構解析器
元件架構會提供下列內建元件解析器,以支援標準 Fuchsia URL 配置:
解析器 | 網址配置 |
---|---|
boot_resolver |
fuchsia-boot |
base_resolver |
fuchsia-pkg |
full-resolver |
fuchsia-pkg |