deltaspike-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karim de Fombelle (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (DELTASPIKE-311) @ConfigProperty injects property from a specific ConfigSource
Date Sun, 20 Jan 2013 18:04:12 GMT

    [ https://issues.apache.org/jira/browse/DELTASPIKE-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13558329#comment-13558329
] 

Karim de Fombelle edited comment on DELTASPIKE-311 at 1/20/13 6:03 PM:
-----------------------------------------------------------------------

Does providing my own ConfigSourceProvider (which is what I do currently) avoid other ConfigSourceProvider
available in the classpath to be loaded (DefaultConfigSourceProvider and eventual others).

I thought they will be all loaded via the Serviceloader mechanism.
If they are all loaded, even providing my own ConfigSourceProvider (actually it is what I
do), nothing prevents users of my framework to provide another ConfigSourceProvider, returning
a ConfigSource with a higher priority and overriding a property I am using in the framework.
It is an example, but most likely others can be found. 
Otherwise It could at least avoid having tricky issues and enhance readability/maintainability.
                
      was (Author: kawork):
    Does providing my own ConfigSourceProvider (which is what I do currently) avoid other
ConfigSourceProvider available in the classpath to be loaded (DefaultConfigSourceProvider
and eventual others). 
I thought they will be all loaded via the Serviceloader mechanism.
If they are all loaded, even providing my own ConfigSourceProvider (actually it is what I
do), nothing prevents users of my framework to provide another ConfigSourceProvider, returning
a ConfigSource with a higher priority and overriding a property I am using in the framework.
It is an example, but most likely othes can be found. 
Otherwise It could at least avoid having tricky issues and enhance readability/maintainability.
                  
> @ConfigProperty injects property from a specific ConfigSource
> -------------------------------------------------------------
>
>                 Key: DELTASPIKE-311
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-311
>             Project: DeltaSpike
>          Issue Type: Improvement
>          Components: Configuration
>    Affects Versions: 0.6-incubating
>            Reporter: Karim de Fombelle
>
> In deltapsike CDI configuration extension it is possible to add our own _ConfigSourceProvider_
via the service loader mechanism.
> Then when a property is searched from the @ConfigProperty annotation, the extension scans
all _ConfigSource_ loaded (according priorities defined as ConfigSource.ordinal attribute).
> This mechanism works fine.
> However it could be improved allowing users to target a specific ConfigSource for the
searched property.
> @Inject
> @ConfigProperty(configSourceId="classpath" name = "property1")
> private String property1;
> Or an URI scheme could be used as follows:
> @Inject
> @ConfigProperty(name = "configSourceUriScheme://property1") //classpath://property1 for
instance
> private String property1;
> Benefits would be to:
> -enhance a lot readability / maintainability of the code
> -enhance flexibility: allow a user to use a property name even it is already used elsewhere.
(i.e. from a different ConfigSource)
> -get rid of some tricky overriding if a property is accessible via several ConfigSource
> e.g.: a framework should ensure no application deployed within will add ConfigSourceProvider/ConfigSource
with a higher priority and the same property. One way to enforce this would be to implement
another CDI extension checking the ConfigSource priorities. 
> It really sounds over complex and highlights the enhancement would be valuable.
> For reference Spring proposes a mechanism not so far of the above and allowing enrichment
by inheritance:
> http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/core/io/DefaultResourceLoader.html

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message