Skip to content

Commit 1df87f1

Browse files
authored
Docs: add description of global configuration (helidon-io#7681)
1 parent cb67381 commit 1df87f1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

docs/se/config/introduction.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ Config config = Config.create(); // <1>
108108
----
109109
<1> The `Config` object is created with default settings.
110110
111+
=== Global Configuration
112+
113+
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.
114+
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.
115+
116+
```
117+
Config config = Config.create(); // <1>
118+
Config.global(config); // <2>
119+
```
120+
<1> Create configuration. This shows creating the default config, but it could be created from custom config sources.
121+
<2> Assign it to the application's global configuration
122+
123+
You can use global configuration to conveniently retrieve the application's configuration:
124+
125+
```
126+
Config config = Config.global();
127+
```
128+
111129
=== Custom Config Sources
112130
113131
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.

0 commit comments

Comments
 (0)