Carbon configuration provides a framework for managing server configurations. With global configuration model, server will have only one configuration file for all server configurations. So that,
In global configuration file (deployment.yaml),
Sample file looks like:
# Carbon Configuration Parameters
wso2.carbon:
id: carbon-kernel
version: 5.2.0-SNAPSHOT
ports:
offset: 0
...
# Netty Transport Configurations
wso2.transports.netty:
listeners:
- id: msf4j-http
host: 127.0.0.1
port: 8080
bossThreadPoolSize: 2
workerThreadPoolSize: 250
parameters:
- name: "executor.workerpool.size"
value: 60
...
Following annotations are introduced for configuration bean classes.
org.wso2.carbon.config.annotations.Configuration
: This is a class-level annotation, which corresponds to a configuration bean to be used by a component.org.wso2.carbon.config.annotations.Element
: This is a field-level annotation, which corresponds to a field of the class.org.wso2.carbon.config.annotations.Ignore
: This is a field-level annotation, which specifies that the field needs to be ignored when the configuration is generated.Sample bean class with above annotations looks like:
@Configuration(namespace = "wso2.carbon", description = "Carbon Configuration Parameters")
public class CarbonConfiguration {
@Element(description = "value to uniquely identify a server", required = true)
private String id = "carbon-kernel";
@Element(description = "server name")
private String name = "WSO2 Carbon Kernel";
@Element(description = "server version")
private String version = "5.2.0";
@Ignore
private String tenant = Constants.DEFAULT_TENANT;
}
The framework provides maven plugin to read all configuration bean classes in the component and create the relevant segment of the configuration file(for documentation purposes) automatically at compile time.
The framework provides OSGI service(ConfigProvider) to read configuration from deployment.yaml file. Following apis are read configuration from the file.
getConfigurationObject(Class<T> configClass)
: Returns configuration object of the class with overriding the values of deployment.yaml. If configuration doesn't exist in deployment.yaml, returns object with default values.getConfigurationMap(String namespace)
: Returns configuration map of the namespace, if configuration exists for the given namespace in deployment.yaml.For more information, Please refer document link below.