What is CDI (Weld) equivalent for Guice's Names.bindProperties(Binder, Properties)?
-
30-06-2021 - |
Question
There's a convenient method in Google Guice which allows binding of properties in one call:
Names.bindProperties(binder(), myProperties);
which are then injectable by annotation:
@Inject
@Named("my.properties.server.url")
private String serverUrl;
Is there an equivalent method in CDI (implemented by Weld) or something even better?
Solution
Not in core CDI, but DeltaSpike's ConfigProperty (https://cwiki.apache.org/DeltaSpike/temporary-documentation.html#TemporaryDocumentation-@ConfigProperty) will probably do what you want.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow