Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Providing unique name for OSGI (R6) factory configuration

Avatar

Level 1

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"



 

1 Accepted Solution

Avatar

Correct answer by
Level 8

@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

 

View solution in original post

7 Replies

Avatar

Community Advisor

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

Avatar

Level 1
We are creating node with jcr:primaryType="sling:OsgiConfig", while committing in the repositry, we commit as xml files. Although the node type is sling:OsgiConfig and has uniqueIdentifier, it is not picking up

Avatar

Community Advisor

Can you try to add it manually from CRXDE (Perhaps in your local instance if the issue is reproducible there, create OSGI config node under config folder of your project) and observe the behavior in Felix console?

Avatar

Correct answer by
Level 8

@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