The order or OSGi configs is handled by Apache Sling. Sling has a system that determines priority for Installable Resources which includes OSGi configurations.
Out of the box, the most powerful component of calculating the priority is the root folder - /apps
vs /libs
. See the JcrInstaller and its configuration in your localhost at http://localhost:4502/system/console/configMgr/org.apache.sling.installer.provider.jcr.impl.JcrInstaller. The difference between the /libs
and /apps
"points" is large at 100 ({"/libs:100", "/apps:200"}
).
After the root priority is determined, the Sling run modes are added up. See org.apache.sling.installer.provider.jcr.impl.FolderNameFilter#getPriority. Each run mode is valued at 1 "point" regardless of order. For example, at this point if you have run modes alpha
and bravo
, config.alpha.bravo
is equal to config.bravo.alpha
.
Priority then looks at certain things such as the Resource State and whether the resource is installed or not and whether the resource is a SNAPSHOT
version which probably will apply more to bundles than configurations in your project. Ultimately, the comparison of the OSGi configs will come down to a lexicographically string comparison of the URLs. Going back to our example, at this point, config.alpha.bravo
has a higher priority than config.bravo.alpha
.
Should the OSGi configs be lexicographically equal, the final comparison is an MD5 hash of the Digest. See org.apache.sling.installer.provider.jcr.impl.ConfigNodeconverter#computeDigest.
See the full comparison function at org.apache.sling.installer.core.impl.RegisteredResourceImpl#compare.
/apps/[your-site]/config
is asling:Folder
or asling:OrderedFolder
. – Khania