Configuration to object mapping #25902
Replies: 1 comment
-
There are some ways to retrieve the keys programmatically: # retrieves all keys
ConfigProvider.getInstance().getPropertyNames();
# retrieves all keys from a mapping class
io.smallrye.config.ConfigMappings#getProperties(ConfigClassWithPrefix)
Mappings are populated at the application start. If there is an error in loading, exceptions are thrown with the proper key names that caused the issue.
What exactly do you want to test here? Can you give me an example?
The problem is that not every key is static. We support
Configuration is immutable, and we don't support reloading it. We had that discussion many times and while we understand the use case, we also think it raises a lot of issues. For instance, how do we deal with changing a jdbc connection?
The use case is definitely interesting. This would require an additional level of integration between Config and Bean Validation. Maybe we can think of a way to make this generic to be read from any annotation. Just not sure how useful that would be. A lot of these annotations are read during the build and code is generated during compile time, so any configuration change would require a rebuild of the application.
Yes, you can either inject it in CDI contexts or get it programmatically. How would you like to access it in static contexts?
We had to go with instances because a mapping or nested mapping can represent a different root, but with the same keys of configuration.
Thank you for the ideas. I've tried to address all the points. We are more than happy to keep improving the configuration mechanism. Mappings are recent (maybe 1 year old now), and they are only becoming stable and mainstream in the last couple of months. We are giving some time for people to adjust and migrate. There is also a Jakarta Config specification group: https://github.com/eclipse-ee4j/config, working right now to make a configuration standard, where some of these ideas were also discussed. I recommend you to join if possible and help us with that :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys!
I like the possibility to configure my Quarkus applications through mapping configuration to objects.
How to do this
@ConfigMapping
and optionally some other annotations for validation and so on.@Inject
s the Configuration. For example:Unfortunately I've encountered some drawbacks.
I can retrieve only configuration values, not the keys.
ConfigurationPropery
in e.g. ajava.util.AbstractMap.SimpleEntry<K,V>
orjava.lang.Record
to access both keys and values.I didn't find a way to change the configuration properties during runtime.
Values resolved via the
@ConfigMapping
annotation cannot be accessed from a static context.Just like this
What do you think of my ideas? Do you know any solutions for them? Did I miss something? Or are my thoughts all garbage? Feel free to join the discussion.
Beta Was this translation helpful? Give feedback.
All reactions