Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Reading sling:OsgiConfig into @ObjectClassDefinition

Avatar

Avatar
Validate 1
Level 2
Adilmo
Level 2

Likes

6 likes

Total Posts

65 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
Adilmo
Level 2

Likes

6 likes

Total Posts

65 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
Adilmo
Level 2

20-08-2020

We have a OSGI Service (using R7 DS annotation). We are using OCD as innerclass within the service.

Also, we would like the component to read properties from the predefined sling:osgiconfig nodes in JCR.

Configuration policy is defined as required.

When the component/service load it goes into a "no config" state.

Need help to read these configs from sling:osgiConfig nodes.

View Entire Topic

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,118 likes

Total Posts

3,149 posts

Correct Reply

1,073 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,118 likes

Total Posts

3,149 posts

Correct Reply

1,073 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

22-08-2020

You can find a working example at https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/0ffd40a15460f8be8d3591e17d5648184f...

 

It features an OSGI service, which uses an inner class for configuration; it should behave according to your requirements.

Adilmo
Could you please provide any method to debug this? We have sling:osgiconfig under the /apps/*/config folder but component never recognize these properties. Please note that when we explicitly open the config, it populates with the sling:osgiconfig correctly and when we save it gets bound. Problem only happens when the bundle starts up, at that point component never finds the config and goes into "no config" state. Please advise and help
Adilmo
I am still having this issue where sling:OsgiConfig is not mapped to my OCD object, even through the PID matches.
Jörg_Hoh
Can you post the code of that class in question somwhere?
Adilmo
@component(immediate = true, configurationPolicy = ConfigurationPolicy.OPTIONAL, service = DataConfigImpl.class, property = { Constants.SERVICE_DESCRIPTION+"=Data Config", Constants.SERVICE_VENDOR+"=ABC" } ) @ServiceDescription("DataConfig Service") @Designate(ocd = DataConfigImpl.Configuration.class) public final class DataConfigImpl implements DataConfig { @ObjectClassDefinition(name = "DataConfigImpl" ) public @interface Configuration { @AttributeDefinition( name = "paths", description = "Paths", type = AttributeType.STRING ) String my_paths() default ""; } @SuppressWarnings("rawtypes") private Dictionary props = null; @activate Configuration configuration; @activate ComponentContext componentContext; @activate @MODIFIED protected void activate() { try { } } }
Adilmo
Hi Jorg..... does ConfigAdmin reads sling:OsgiConfig properties to populate its persistence properties data ?? Is there a way to populate configadmin property set before hand so that when component loads we get the configuration ?
Jörg_Hoh

The configadmin does all what you expect. Things to check:

  • Is the PID correct? It should be the full qualified class name of the service (and not the one of the configuration class)
  • When you update the config, do you see it picked up by the JCR Installer? (Check the logs for it)
  • Use the webconsole and provide some configuration for it. Does it then work as expected? And normally you will find these configured values in /apps/system ... Compare the node names and the structure with the one you are using.
Adilmo
Hi Jorg.... Our sling:OsgiConfig are under /apps/*/config folder.... they are loaded as sling:OsgiConfig nodes. These nodes are not able to provide initial configuration to the component. (No activate methods called with configuration.policy=required). However, we can open these nodes with webconsole configuration. The same values populates on the console and when we save the configs, they get saved under /apps/*/config folder as jcr:content under the respective sling:osgiconfig nodes. Once this happens, component is activated and even when we restart bundle component gets activated. Basically, component cannot get activated with initial sling:osgiconfig nodes ...it is only when the jcr:content is created under those nodes that the component gets the configuration and gets activated. Is it a good idea to package sling:osgiconfig with jcr content nodes in a content package ... so that cmponent gets activated by default.
Adilmo
Is there any reference OSGI configurator implementation for AEM ?? I need to add the configuration is configadmin before the component is activated .. kindly advise... as of now component activation is not fetching the configadmin configs (created through sling:osgiconfig)