Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for Map injection #750

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

rmanibus
Copy link

fix #562

@eclipse-microprofile-bot
Copy link
Contributor

Can one of the admins verify this patch?

@@ -121,6 +121,11 @@ public class InjectedConfigUsageSample {
@ConfigProperty(name="myprj.some.supplier.timeout", defaultValue="100")
private java.util.function.Supplier<Long> timeout;

//Injects a Map to resolve multiple configuration parameters under the same configuration key.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Map injection, what types for Key, Value do you propose to support? We need to clarify that.

//Injects a Map to resolve multiple configuration parameters under the same configuration key.
@Inject
@ConfigProperty(name = "myprj.some.reasons", defaultValue = "200=OK;201=Created")
private java.util.Map<Integer, String> reasons;
Copy link
Member

@otaviojava otaviojava Sep 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private java.util.Map<Integer, String> reasons;
private java.util.Map<String, String> reasons;

Once we're talking about configuration, I believe the key must be a String

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree to narrow down to Map<String, String>. Otherwise, it will be overwhelming with the tests and it might have more issues to deal with regarding conversion errors.

@@ -121,6 +121,11 @@ public class InjectedConfigUsageSample {
@ConfigProperty(name="myprj.some.supplier.timeout", defaultValue="100")
private java.util.function.Supplier<Long> timeout;

//Injects a Map to resolve multiple configuration parameters under the same configuration key.
@Inject
@ConfigProperty(name = "myprj.some.reasons", defaultValue = "200=OK;201=Created")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specification must define how the map properties are parsed (both on a source and in the defaults).

public class MapConverterBean {

@Inject
@ConfigProperty(name = "tck.config.test.javaconfig.converter.map.string.string")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we call the programmatic API? What happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to fetch multiple config parameters as a Map
5 participants