While migrating the code to 6.3, we are moving to OSGi DS Annotations. I created two files:
1. Interface (where I am keeping all the properties) - com.abc.web.config.TestConfiguration.java
2. Component/Service which will be actually used in other components in order to pull the properties configured. - com.abc.web.config.ConfigurationService.java
3. we have config.xml (sling:osgiConfig) files for this configurations because each environment needs to pull different values. - /apps/project/configuration/config/com.abc.web.config.TestConfiguration.xml
Interface:
@ObjectClassDefinition(name = "Test Config Name",
description = "Config Description")
public @interface TestConfiguration {
@AttributeDefinition(name = "Attribute One", description = "Attribute 1")
String attributeOne() default StringUtils.EMPTY;
@AttributeDefinition(name = "Attribute Two", description = "Attribute 2")
String attributeTwo() default StringUtils.EMPTY;
}
Component/Service:
@Component(immediate = true, service = ConfigurationService.class)
@Designate(ocd = TestConfiguration.class)
....... and so on.
config file:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
attributeOne="Value 1"
attributeTwo="Value 2"/>
The problem I am having is: it shows two configuration in Felix Console:
1. com.abc.web.config.TestConfiguration -- this shows all the values from config file: Value 1 and Value2
2. Test Config Name - this just shows two blank text fields: Attribute One and Attribute Two
The Configuration Binding field in Felix Console Configurations shows no binding information. It says "Unbound or no configuration". I tried clicking on "Save" to bind it but it didn't do anything. I have tried re-deploying the code, deleting the bundle etc.
Am I missing anything or doing anything wrong?