Providing unique name for OSGI (R6) factory configuration

Avatar

Avatar

asha998919

Avatar

asha998919

asha998919

24-09-2020

To make a OSGI factory configuration, provided factory = true using R6 annotations and was able to create factory configs, but when uploaded the configs via xmls using a unique identifier, that identifier is not picked in the display name.

 

For example config.xml's name  is "com.x.y.z.someserviceimpl-<identifier>" while displaying in the felix console it shows some randomly generated number "com.x.y.z.someserviceimpl.09433545561-447d-98b3-1a514342323". As we have multiple xmls, it's tedious to open each config to change a property in runtime. Is there a specific property which we can give, so that config picks the specific name?

 

Similar to  factory configurations PIDs like "org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl" and "org.apache.sling.commons.log.LogManager.factory.config"



 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Manjunath_K

Avatar

Manjunath_K

Manjunath_K

24-09-2020

@asha998919 

Please try below solution for your requirement.

 

Config property: define this "webconsole_configurationFactory_nameHint" in config class & this configuration property which defines a name template which is used to build the configuration factory item name when displayed in the Configuration Manager. It allows referencing other service property names as placeholders by enclosing in brackets.

 

if you already have some unique name in existing property list then you can reuse that instead of defining new one like name() property in below screenshot & add that property as default "some text : {uniquePropertyName}"

 

configclass.png

 

Run modes : define unique id/name for each config in run modes

runmode1.png

 

System Console Configuration Manager : it will show unique name as defined in run modes for each config

console.png

 

Answers (1)

Answers (1)

Avatar

Avatar

Vijayalakshmi_S

MVP

Avatar

Vijayalakshmi_S

MVP

Vijayalakshmi_S
MVP

24-09-2020

Hi @asha998919,

While having configs as part of code package, make sure to create a node of type sling:OsgiConfig in the name of PID-<<uniqueIdentifier>>

not as an XML file.

  • You can cross check by creating new factory config directly in felix console -> entry with respect to the newly created config would have been created in /apps/system/config as an XML file.(with auto generated identifier)
  • In CRXDE, create a node of type sling:OsgiConfig with name in the above format -> you would see the config created with respective identifier in felix console. 

Screenshots for reference:

From project specific config folder:

Vijayalakshmi_S_0-1600953839605.png

From /apps/system/config :

Vijayalakshmi_S_1-1600953935888.png

From Felix console:

Vijayalakshmi_S_2-1600953986203.png