Which config is applied when number of matched run modes is the same

后端 未结 1 1659
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 18:30

I am using OSGI config files to define configuration for different environments, as specified in OSGI Configuration. I have configurations for multiple run modes saved in t

1条回答
  •  生来不讨喜
    2021-01-12 18:45

    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.

    0 讨论(0)
提交回复
热议问题