Providing unique name for OSGI (R6) factory configuration | Community
Skip to main content
September 24, 2020
Solved

Providing unique name for OSGI (R6) factory configuration

  • September 24, 2020
  • 2 replies
  • 1914 views

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"



 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Manjunath_K

@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}"

 

 

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

 

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

 

2 replies

Vijayalakshmi_S
Level 10
September 24, 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:

From /apps/system/config :

From Felix console:

September 24, 2020
Hi VijayaLakshmi,
Manjunath_K
Manjunath_KAccepted solution
Level 7
September 24, 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}"

 

 

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

 

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

 

September 25, 2020
Thanks Manjunath....