Can a ConfigSource make use of Config?

17 views
Skip to first unread message

Laird Nelson

unread,
Sep 20, 2018, 4:45:04 PM9/20/18
to Eclipse MicroProfile

I'm writing a ConfigSource.  In order to provide a value for a property, ideally I'd like to ask the MicroProfile Config machinery that the ConfigSource is part of for a particular value.

If, obviously, I do not ask for a value that I myself am providing (that would be circular), does the specification permit me to do the following from within my getValue(String) implementation:

ConfigProvider.getConfig().getValue(somePropertyMyConfigSourceWillNeverProduce, someType);

…?  May I do this from the constructor, or is that too early?

Thanks,
Best,
Laird

Laird Nelson

unread,
Sep 20, 2018, 4:45:55 PM9/20/18
to Eclipse MicroProfile
…aaaaaand of course I immediately find https://groups.google.com/forum/#!topic/microprofile/rkkZJGJpxMU.  Sorry for the noise.

Laird Nelson

unread,
Sep 20, 2018, 5:48:13 PM9/20/18
to Eclipse MicroProfile
Actually, more noise.  :-)

Must a MicroProfile Config implementation permit this behavior?  It seems like this has to be specified one way or the other, because someone writing a ConfigSource needs to know whether they can rely on this behavior in all MicroProfile implementations or not.

Best,
Laird

Emily Jiang

unread,
Sep 21, 2018, 12:36:57 PM9/21/18
to Eclipse MicroProfile
I don't quite understand your question on "implementations permitting this behaviour". Which behaviour do you refer to?

By the way, the getValue() can be called in a class constructor. If you are not sure whether the value is provided by any config sources, use getOptionalValue() instead and provide a default.

Thanks
Emily
Reply all
Reply to author
Forward
0 new messages