Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x Docs: global config #7681

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/se/config/introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ Config config = Config.create(); // <1>
----
<1> The `Config` object is created with default settings.

=== Global Configuration

Global configuration is a singleton instance of `Config` that is implicitly used by some components of Helidon, plus it provides a convenient mechanism for your application to retrieve configuration from anywhere in your code.
By default global configuration is initialized to the default `Config` object (as returned by `Config.create()`). But it is recommended that you initialize it explicitly. This is especially important if you define custom config sources.

```
Config config = Config.create(); // <1>
Config.global(config); // <2>
```
<1> Create configuration. This shows creating the default config, but it could be created from custom config sources.
<2> Assign it to the application's global configuration

You can use global configuration to conveniently retrieve the application's configuration:

```
Config config = Config.global();
```

=== Custom Config Sources

Although the default configuration is very simple to use, your application can take full control of all configuration sources and precedence. You can do so by creating and invoking methods on a `Config.Builder` object to construct a `Config` instance.
Expand Down
Loading