Xavier Dury created DELTASPIKE-1295:
---------------------------------------

             Summary: 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
(v6.4.14#64029)

Reply via email to