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
W: https://medium.com/@imesh TW: @imesh
lean. enterprise. middleware
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to