You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Mark Struberg (Jira)" <ji...@apache.org> on 2021/12/06 19:18:00 UTC

[jira] [Assigned] (DELTASPIKE-1441) ConfigProperty support for maps

     [ https://issues.apache.org/jira/browse/DELTASPIKE-1441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg reassigned DELTASPIKE-1441:
-----------------------------------------

    Assignee: Mark Struberg

> ConfigProperty support for maps
> -------------------------------
>
>                 Key: DELTASPIKE-1441
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1441
>             Project: DeltaSpike
>          Issue Type: Wish
>      Security Level: public(Regular issues) 
>            Reporter: Andrew Marinchuk
>            Assignee: Mark Struberg
>            Priority: Major
>
> Let's assume that we have the following configuration:{code}my.param.a=1
> my.param.b=2
> my.param.c=3
> ...{code}
> And we want to load all the {{my.param.*}} parameters into the {{Map<String, Integer>}}.
> With the current configuration api there two ways to load such config:
> # add parameter {{my.param.all=a,b,c,...}} with complete list of {{my.param.*}} parameters, add an {{@Inject}}'ed {{List<String>}} field with {{@ConfigProperty}} annotation to read this parameter and then fill the map values by reading value by each of the provided keys.
> # iterate through ConfigResolver.getAllProperties() by code like [filterPropsByPrefix function|https://issues.apache.org/jira/browse/DELTASPIKE-1212?focusedCommentId=16986128&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16986128] and fill the Map with it
> But I think that loading such config shouldn't be a user problem, library should be capable of loading it. Of course, user can introduce the {{@ApplicationScoped}} bean which will inherits the {{org.apache.deltaspike.core.spi.config.BaseConfigPropertyProducer}} and introduce the {{@Producer}} methods for {{Map<String, ?>}} analog for producers introduced in  org.apache.deltaspike.core.impl.config.DefaultConfigPropertyProducer. But it should be a library code.
> Another use case which should be covered is loading Map<String, Intf> where Intf - interface with {{@Configuration}} annotation, i.e.:
> {code}datasources.one.url=jdbc://...
> datasources.one.user=myuser
> datasources.one.password=pass
> datasources.two.url=jdbc://....
> datasources.two.user=myuser2
> datasources.two.password=pass2
> ...{code}
> Currently we use code from [this comment|https://issues.apache.org/jira/browse/DELTASPIKE-1212?focusedCommentId=16986128&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16986128] to load such configuration, but it could be much simpler if deltaspike had ConfigProperty support for maps with ability to use @Configuration interfaces as values.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)