Netflix / archaius

Library for configuration management API
Apache License 2.0
2.46k stars 485 forks source link

Load properties for @ConfigurationSource on @Provides methods #575

Open elandau opened 5 years ago

elandau commented 5 years ago

Loading configuration with @Provides methods currently requires a hack to inject a second type that is annotated with @ConfigurationSource. This change makes it possible to annotate the @Provides method with @ConfigurationSource to have the configuration loaded before the bean is provisioned. For example,

@ConfigurationSource({"foo"})
@Provides
@Singleton
Foo getFoo() {
}

will result in foo.properties (and it's variants) being loaded before getFoo is called.