Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

OSGi DS Annotations - showing multiple configurations in Felix Console

Avatar

Level 4

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?

1 Accepted Solution

Avatar

Correct answer by
Level 6

Can you try adding AttributeType to @AttributeDefinition

sudo code :

@AttributeDefinition(

        name = "String Property",

        description = "Sample String property",

        type = AttributeType.STRING

    )

    String servicename_propertyname_string() default "foo";

import org.osgi.service.metatype.annotations.AttributeDefinition;

ref: Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache S...

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6

Can you try adding AttributeType to @AttributeDefinition

sudo code :

@AttributeDefinition(

        name = "String Property",

        description = "Sample String property",

        type = AttributeType.STRING

    )

    String servicename_propertyname_string() default "foo";

import org.osgi.service.metatype.annotations.AttributeDefinition;

ref: Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache S...