Class ConfigPropertySourceProvider
- All Implemented Interfaces:
PropertySourceProvider
juneau.cfg (and the other names returned by
Config.getCandidateSystemDefaultConfigNames()) as a PropertySource for the
process-wide Settings singleton.
Discovered by ServiceLoader-based wiring through a
META-INF/services/org.apache.juneau.commons.settings.PropertySourceProvider entry
shipped in this module.
Lookup semantics: the registered source defers calling Config.getSystemDefault() to the
first get(name) invocation. This is deliberate — calling getSystemDefault() from
inside create() would create a static-initialization cycle because
Settings.<clinit> fires the ServiceLoader at class-load time, and Config's
static initializers transitively reference Settings (through Cache / SystemUtils.env(...))
which would re-enter the Settings.<clinit> block.
Lazy resolution makes the cycle a non-issue: by the time @Value("${...}") fires its first
lookup, all participating classes are fully initialized.
Silence on missing config:
If no system-default Config is discoverable (no juneau.cfg / default.cfg
/ application.cfg / etc. on the classpath or working directory), get(name)
returns PropertyLookupResult.missing() for every key. No logging, no exception — many
deployments have no classpath config and shouldn't see noise.
Ordering:
order() returns 100, which is "low" in the PropertySourceProvider
scheme — provider-discovered classpath defaults register near the bottom of the source list so
that programmatic Settings.get().addSource(...) calls (e.g. per-microservice config or
the Spring Environment bridge) shadow the classpath default. Settings walks
sources in reverse insertion order, so the most-recently-added source wins.
-
Constructor Details
-
ConfigPropertySourceProvider
public ConfigPropertySourceProvider()
-
-
Method Details
-
create
Description copied from interface:PropertySourceProviderCreates a property source.- Specified by:
createin interfacePropertySourceProvider- Returns:
- The property source, or
null to skip registration.
-
order
Description copied from interface:PropertySourceProviderSort key used by ServiceLoader wiring.Lower values are added first.
- Specified by:
orderin interfacePropertySourceProvider- Returns:
- The order value.
-