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 2018/04/04 10:57:00 UTC

[jira] [Commented] (DELTASPIKE-1295) Make @ConfigProperty.converter optional when there is only one possible converter for the considered injected type

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

Mark Struberg commented on DELTASPIKE-1295:
-------------------------------------------

We should probably implement the same logic I added to mp-config. To be able to register a Converter the same way like a ConfigSource (java.util.ServiceLoader)?

> Make @ConfigProperty.converter optional when there is only one possible converter for the considered injected type
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: DELTASPIKE-1295
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1295
>             Project: DeltaSpike
>          Issue Type: Improvement
>          Components: Configuration
>    Affects Versions: 1.8.0
>            Reporter: Xavier Dury
>            Priority: Minor
>
> Currently, {{@ConfigProperty}} can be used to inject members of types {{String}}, {{Boolean}}, {{Class}}, {{Integer}}, {{Long}}, {{Float}} and {{Double}}.
> Other types can be injected as well if a {{ConfigResolver.Converter<T>}} class is given in the annotation ({{@ConfigProperty(name = "...", converter = MyTypeConverter.class)}}).
> The actual instance of the converter will be resolved through the {{BeanManager}}.
> If there exists only one converter for the target type, it should be possible to resolve the instance to be used with {{beanManager.resolveBean(new ParameterizedTypeImpl(Converter.class, targetType))}}.
> So you would only need to specify the {{ConfigProperty.converter}} attribute:
> * if the field type does not directly match the parameter T in your {{Converter<T>}} or
> * if there are more than one eligible converter for that type.
> The logic should be changed to: is a converter specified in the annotation? (!= default value)
> * yes: proceed with that converter
> *  no: is the target type one of the default supported types?
> ** yes: proceed without converter
> ** no: try to resolve the possible unique resolver for that type and use that converter, throw an exception if there are multiple converters for that type
> What do you think?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)