Hi all,

*Note:* This email is in reference to the "[Architecture] Carbon C5 - Server
 Configuration Model" previously sent to the Architecture mail thread.

I am currently working on moving the

   1. C5 server configuration model out of the carbon.core [1]
   <https://github.com/wso2/carbon-kernel/issues/1285> and creating a
   separate component which will support both OSGi and standalone mode.
   2. Using the C5 server configuration model to configure the executor
   pool in MSF4J

However, there is an issue that needs to be addressed in relation to the C5
configuration model and is as stated below:

Maven configuration plugin currently looks at the class template to process
configurations. However, this has certain limitations considering the below
example.

Let's say for instance that I want to have the following configuration
segment created.

listenerConfigurations:
-
  id: "msf4j-http"
  host: "127.0.0.1"
  port: 8080
-
  id: "jaxrs-http"
  host: "0.0.0.0"
  port: 8094
  scheme: https
  keyStoreFile: "src/test/resources/cert.jks"
  keyStorePass: secret
  certPass: secret


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)


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
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