Hi all,

Considering the same example as stated above,

@Element(description = "Listener configurations") private
List<ListenerConfiguration> listenerConfigurations = Arrays.asList(new
HttpListenerConfiguration(), new HttpsListenerConfiguration());

What should be the case when `ListenerConfiguration` class do not have the
`@Configuration` annotation?

Should a warning or an exception be thrown when preparing the configuration
file?


On Wed, Feb 22, 2017 at 11:16 AM, Vidura Nanayakkara <[email protected]>
wrote:

> ​​
> Hi all,
>
> There are few points that are needed to be clarified in this email.
>
> First of all having
>
> @Element(description = "Listener configurations") private
> List<ListenerConfiguration> listenerConfigurations = Arrays.asList(new
> HttpListenerConfiguration(), new HttpsListenerConfiguration());
>
> Will produce the below configuration
>
> listenerConfiguration:
>  -{}
>  -{}
>
> assuming that *ListenerConfiguration* class has the *@Configuration*
> annotation present. So the intended behaviour stated in "[Architecture]
> Carbon C5 - Server Configuration Model" architecture mail thread is not
> working as intended and needs to be fixed.
>
> So the actual point that needs to be clarified is whether to consider the
> reference type or the instance type when preparing the configuration file.
>
> As mentioned by Danesh and Imesh and as per offline discussion with
> Kishanthan we will be looking at the reference type when preparing the
> configuration.
>
> Thanks,
> Vidura Nanayakkara
>
> On Tue, Feb 21, 2017 at 9:08 PM, Imesh Gunaratne <[email protected]> wrote:
>
>>
>>
>> On Tue, Feb 21, 2017 at 6:33 PM, Vidura Nanayakkara <[email protected]>
>> wrote:
>>
>>>
>>> In order to create the above configuration, I may write any of the
>>> below-mentioned code segments.
>>>
>>> 1)
>>>
>>> @Element(description = "Listener configurations")
>>>     private List<Configuration> listenerConfigurations =
>>>             Arrays.asList(new HttpListenerConfiguration(), new 
>>> HttpsListenerConfiguration());
>>>
>>>
>>> Since the plugin only looks at the argument type I will not be able to
>>> have the above-mentioned configuration (Plugin will check for annotations
>>> inside the "Configuration" class and therefore only the elements in the
>>> "Configuration" class will be written to the configuration file)
>>>
>>> Shouldn't that be the intended behaviour?
>>
>> In the above sample, if *listenerConfigurations* is a repeatable element
>> in a configuration file, it might need to have the same set of properties
>> in all the rows. Which means when* @Element *annotation is added to a
>> private variable the mapping between the configuration file and the domain
>> model might need to use the data type of the above variable instead of the
>> data type of the assigned value(s). WDYT?
>>
>> ​Thanks​
>>
>>
>>> 2)
>>>
>>> @Element(description = "Listener configurations")
>>>     private List<Object> listenerConfigurations =
>>>             Arrays.asList(new HttpListenerConfiguration(), new 
>>> HttpsListenerConfiguration());
>>>
>>> Since the plugin only looks at the argument type I will not be able to
>>> have the above-mentioned configuration (Plugin will check for annotations
>>> inside the "Object" class). Furthermore since "Object" class doesn't have
>>> any annotation, I will not have any of the configuration elements at all.
>>>
>>> 3)
>>>
>>> @Element(description = "Listener configurations")
>>>     private List listenerConfigurations =
>>>             Arrays.asList(new HttpListenerConfiguration(), new 
>>> HttpsListenerConfiguration());
>>>
>>>
>>> This will throw an exception since the argument type is not stated
>>> within the angle brackets (should take as Object by default right?)
>>>
>>> *Suggestion*
>>>
>>>    - Consider the instance rather than the reference type when creating
>>>    the configuration file to solve the above problems.
>>>    - Iterate through inherited classes when creating the configuration
>>>    file. This way we can avoid duplicating the same code in multiple places
>>>    and help solve the problem stated in (1)
>>>
>>>
>>> WDYT?
>>>
>>> [1] carbon-kernel issue 1285
>>> <https://github.com/wso2/carbon-kernel/issues/1285>
>>>
>>> Best Regards,
>>>
>>> *Vidura Nanayakkara*
>>> Software Engineer
>>>
>>> Email : [email protected]
>>> Mobile : +94 (0) 717 919277 <+94%2071%20791%209277>
>>> Web : http://wso2.com
>>> Blog : https://medium.com/@viduran <http://wso2.com/>
>>> Twitter : http://twitter.com/viduranana
>>> LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara
>>> <http://wso2.com/>
>>>
>>
>>
>>
>> --
>> *Imesh Gunaratne*
>> Software Architect
>> WSO2 Inc: http://wso2.com
>> T: +94 11 214 5345 M: +94 77 374 2057 <+94%2077%20374%202057>
>> W: https://medium.com/@imesh TW: @imesh
>> lean. enterprise. middleware
>>
>>
>
>
> --
> Best Regards,
>
> *Vidura Nanayakkara*
> Software Engineer
>
> Email : [email protected]
> Mobile : +94 (0) 717 919277 <+94%2071%20791%209277>
> Web : http://wso2.com
> Blog : https://medium.com/@viduran <http://wso2.com/>
> Twitter : http://twitter.com/viduranana
> LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara
> <http://wso2.com/>
>



-- 
Best Regards,

*Vidura Nanayakkara*
Software Engineer

Email : [email protected]
Mobile : +94 (0) 717 919277
Web : http://wso2.com
Blog : https://medium.com/@viduran <http://wso2.com/>
Twitter : http://twitter.com/viduranana
LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara <http://wso2.com/>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to