Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

osgi

aem

sling

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 the same repository. The documentation states

"If multiple configurations for the same PID are applicable, the configuration with the highest number of matching run modes is applied."

What is the mechanism if multiple configurations for the same PID are applicable and two or more configurations are tied for the highest number of matching run modes? Which one gets applied?

like image 896
Shawn Avatar asked Jun 20 '16 21:06

Shawn


People also ask

How many run modes are in AEM?

There are two types of run modes, standard and custom. The standard run mode is used at installation time and then fixed for the entire lifetime of the instance, they cannot be changed.

Which configuration takes precedence at runtime when multiple configurations exist in AEM?

Then the following order of precedence applies: Modifying a configuration in the Web console will take immediate effect as it takes precedence at runtime. Modifying a configuration in /apps will take immediate effect.

What is the use of OSGi configuration in AEM?

OSGi is a fundamental element in the technology stack of AEM. It is used to control the composite bundles of AEM and their configuration. OSGi “provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components.

What is Runmode in AEM?

Run modes allow you to configure AEM instances for specific purposes. For example, author instances use the author run mode, and publish instances use the publish run mode.


1 Answers

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.

like image 72
nateyolles Avatar answered Sep 18 '22 12:09

nateyolles