Osgi configuration admin file naming
Issue
I have deployed properties file my-properties.cfg to the <FUSE-ESB>/etc folder. When I check the config:list from the Karaf console, the PID is set to my.<guid>
FuseESB:karaf@root> config:list | grep my
Pid: my.12d24996-38e4-4331-a9e4-91820516e293
If I use dot in file name ('my.properties.cfg'), the PID is as expected:
FuseESB:karaf@root> config:list | grep my
Pid: my.properties
Why can't a dash be used in a properties file to the Config Admin service?
Resolution
It is related to the file naming convention described at http://felix.apache.org/documentation/subprojects/apache-felix-file-install.html.
Configuration file names are related to the PID and factory PID. The structure of the file name is as follows:
filename ::= <pid> ( '-' <subname> )? '.cfg'
If the form is <pid>.cfg, the file contains the properties for a Managed Service. The <pid> is then the PID of the Managed Service. See the Configuration Admin service for details.
When a Managed Service Factory is used, the situation is different. The <pid> part then describes the PID of the Managed Service Factory. You can pick any <subname>, this bundle will then create an instance for the factory for each unique name. For example:
com.acme.xyz.cfg // configuration for Managed Service
// com.acme.xyz
com.acme.abc-default.cfg // Managed Service Factory,
// creates an instance for com.acme.abc
If a configuration managed by File Install is modified, File Install will write the configuration back to a property file to ensure persistence across restarts.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
