someInstance.select(Frobnicator.class, myConfigPropertyLiteral).get();
ConfigProvider.getConfig().However, it's not explicitly stated that the default config should enable discovered converters. I believe this is covered by tests in the TCK, but to clarify this I've raised an issue: https://github.com/eclipse/microprofile-config/issues/348
> Also the specification never says what the Config#getValue(String, Class) method is obliged to do
This is intentional, because it depends on how the Config instance is created. If you use a builder to create it, default converters need to be turned on with ConfigBuilder.addDiscoveredConverters, otherwise default convetersare are disabled.
@Overridepublic <T> T getValue(final String name, final Class<T> type) {// use java.beans.PropertyEditor or something else to perform conversion// e.g. no Converter<T> used here at all, let's sayreturn result; // or just return null}
If anybody finds out a way how to create producers dynamically on demand it would be worth to let others know.
@Inject@ConfigProperty(name = "frobnicationInterval")private final Number frobnicationInterval; // note: Number, not Integer, not Long, not Double….
In the current world, it also just occurred to me rather hazily that even with scanning injection points—i.e. not just with strange, non-typical programmatic Instance lookups—you still might not have what you need (not entirely sure about this). An injection point might be, for example:@Inject@ConfigProperty(name = "frobnicationInterval")private final Number frobnicationInterval; // note: Number, not Integer, not Long, not Double….…and although this is an utterly contrived example I'm not sure it would work, right? Could I generate a producer for this? Ultimately I'd do config.getValue("frobnicationInterval", Number.class)…and what would happen? Maybe this is covered somewhere; not sure.
I think that the case with injecting Number would be automatically raised as a problem by every CDI container. There are default converters for Float, Double, Integer, etc. and all of them could be injected at the injection point.
Supporting retrieval of
someInstance.select(Frobnicator.class, myConfigPropertyLiteral).get();
in a portable way isn't possible AFAIK.
I've clarified this in this pull request: https://github.com/eclipse/microprofile-config/pull/353/files
Please review and comment.
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/3kXLoA1KVz8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile+unsubscribe@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/7c446b99-2d36-4190-a5e3-446756bb132a%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/CACZTZYX1h2dnEjhJM9LAKCYmjUx%3DcBV2gZb%2B_3R17JU1_eBvhw%40mail.gmail.com.
I guess it depends on how it is written whether or not I’d be ok with this.The Number class doesn’t have a valueOf method so I wouldn’t expect to be able to inject a Number given MP Config 1.2. Perhaps the spec should state that the type conversion is based on the target type and not any super class or interfaces?Alasdair
On Apr 20, 2018, at 7:23 PM, Ondro Mihályi <ondrej....@gmail.com> wrote:
--OndroI agree it's good to rather overspecify than leave gaps in the spec. I'll try to add all clarifications into the PR. You are also free to raise a PR if you find something missing. To accept contributions from you we only need you to sign the Eclipse Foundation Contributor Agreement.MicroProfile and Eclipse is all about feedback and collaboration. So we're glad for your feedback :)
2018-04-20 23:55 GMT+02:00 Laird Nelson <ljne...@gmail.com>:
On Friday, April 20, 2018 at 5:42:41 AM UTC-7, Ondro Mihályi wrote:I've clarified this in this pull request: https://github.com/eclipse/microprofile-config/pull/353/files
Please review and comment.I added a couple of comments over there.In general I think the specification and hence the javadoc language should be very explicit in terms of what you can and cannot do, because CDI is so wiggly. Right now IMHO as an implementor it is not (I can obviously figure out what was intended, but that's not what we're talking about here).So if @Inject @ConfigProperty private Number someNumber and other classes of this problem are forbidden, say so. If programmatic lookup is impossible, say explicitly that that behavior is not guaranteed. If @Inject @ConfigProperty private Collection<? extends String> strings is non-deterministic, or is allowed, say so explicitly. Maybe it's simplest to identify the cases that are guaranteed to work, and to issue a blanket statement of undefined behavior for all other cases.Thanks for your work here and willingness to accept feedback.Best,Laird
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/3kXLoA1KVz8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/7c446b99-2d36-4190-a5e3-446756bb132a%40googlegroups.com.