Hello; I had some questions from an implementor's perspective on the JSR 330 aspects of MicroProfile Config 1.2.1, specifically as they relate to CDI.
I see in both WildFly's and Open Liberty's implementations that injection of @ConfigProperty-annotated fields and parameters is handled by a Bean implementation that uses a Weld-specific, non-portable implementation trick to access the current InjectionPoint from the Bean#create(CreationalContext) method. Part of the trick involves creating a fake InjectionPoint implementation that helps trick Weld, via its use of proxies, into handing you an InjectionPoint reference that reflects the actual InjectionPoint at which the return value of the Bean's create() method will be applied. The other part of the trick appears to be having the bean say that it is handling ConfigProperty(name = "", defaultValue = "") injection points, which of course it is not doing—it is handling injection points annotated with specific instances of ConfigProperty (i.e. ones with "real" values for name and defaultValue, not empty Strings).
In each case, because the Bean being implemented is making use of this little trick, there must be some other magic going on, and I admit to being somewhat confused by it. Specifically, the Bean being implemented reports its qualifiers as being equivalent to exactly:
@ConfigProperty(name = "", defaultValue = "")
Now, normally this would rule out injection points annotated with, say:
@ConfigProperty(name = "java.home", defaultValue = "No Home Found")
…because ConfigProperty#name() and ConfigProperty#defaultValue() are not annotated with @NonBinding. So how does returning a ConfigProperty annotation literal with empty String values somehow "match" an injection point annotated with a ConfigProperty annotation with specific String values? Normally this match wouldn't happen. I suspect this is somehow also related to the Weld trick.
How does this work, exactly?
It most likely won't work for BeanManager#getReference or other mechanisms of programmatic lookup. Is this OK with respect to the MicroProfile Config specification. Is that OK?
The portable way to do this would result in the creation of potentially many Bean implementations. Is that correct?
Best,
Laird