AEM /conf and ConfMgr

Adobe Experience Manager | AEM/CQ | Apache Sling

AEM /conf and ConfMgr

As of AEM 6.1 you may have noticed the new /conf node at the root level along with /content, /etc, /apps and /libs. Over time the /etc folder's responsibility has expanded and configurations have been moved in an effort to clean it up a little. Whereas prior to 6.1 you would have stored site configurations in /etc, it's now recommended that you store those configurations under /conf. Along with the new node structure Adobe has provided a valuable, yet simple, utility to help manage these new site configurations in com.adobe.granite.confmgr.ConfMgr and com.adobe.granite.confmgr.Conf.

Read the Adobe provided documentation for  Conf and ConfMgr.

I have created a demo project and hosted it on GitHub at https://github.com/nateyolles/aem-slash-conf.

As an example, let's host a multi-tenant AEM instance with three projects and one subproject: Aviato, Pied Piper, Hooli and subproject Hooli XYZ.

/content/aviato
/content/piedpiper
/content/hooli
/content/hooli/hoolixyz

Add a cq:conf property of type String at the root of every project page and point it to the site's corresponding configuration path. A global configuration will be used if a cq:conf property is not specified as is the case for Aviato in this example.

/content/piedpiper/jcr:content/@cq:conf = "/conf/tentants/piedpiper"
/content/hooli/jcr:content/@cq:conf = "/conf/tentants/hooli"
/content/hooli/hoolixyz/jcr:content/@cq:conf = "/conf/tentants/hooli/hoolixyz"

Conf respects relative paths as it pertains to the cq:conf property. Therefore, the following settings could also be used:

/content/hooli/jcr:content/@cq:conf = "/conf/tentants/hooli"
/content/hooli/hoolixyz/jcr:content/@cq:conf = "hoolixyz"

The tree structure of /conf should closely resemble /content. The configuration nodes should be of type cq:Page with the configuration properties on the jcr:content sub-nodes. All configurations start below the path specified in cq:conf with the addition of /settings.

/conf/global/settings/socialmedia/facebook/jcr:content/@enabled = false
/conf/tenants/piedpiper/settings/socialmedia/facebook/jcr:content/@enabled = true
/conf/tenants/hooli/settings/socialmedia/facebook/jcr:content/@enabled = true
/conf/tenants/hooli/hoolixyz/settings/socialmedia/facebook/jcr:content/@enabled = true

/conf/global is special as it provides an ultimate fallback in the Conf inheritance mechanism. It this example Aviato does not have its own config, so it would use the global configs. /conf/tenants is not dictated by AEM, but is a convention worth following to help prevent namespace collision in multi-tenant scenarios.

Configs can live under /conf, /apps and /libs with the same apps-then-libs type resolution that you are already familiar with. The resolution order can be set in the Felix console com.adobe.granite.confmgr.impl.ConfMgrImpl configuration: http://localhost:4502/system/console/configMgr/com.adobe.granite.confmgr.impl.ConfMgrImpl.

Use a Conf object to get a site configuration. The Conf object is usually obtained by adapted a Resource or Page using Apache Sling's adaptTo() method. Once you have the site's Conf object, you can get any number of predefined ValueMaps and properties. Notice that the ValueMaps cannot be modified – they are read-only. Properties are retrieved from the ValueMap in the familiar way of passing in either a default value or the class type.

The Conf object you retrieve is based on the path of the resource. So if have a Sling Model or WCMUsePojo and you adapt the current page, you will get a different Conf than if you adapt the current resource.



As you can see, the ConfMgr is a fairly lightweight and transparent helper. Everything is in the JCR, so configurations can be accessed through normal channels such as a Resource Resolver. However, there are three main benefits to using com.adobe.granite.confmgr.Conf.

The most obvious advantage is the built in inheritance management. For instance, the site for Hooli might have ten configurations. If the subproject Hooli XYZ overwrites only one of those configurations, it will use the other nine provided by Hooli. If the Conf object is looking for a config that doesn't exist in the subproject or project, it will look under /global. Conf inherits and overwrites at the node level, not the property level.

Conf handles null values for you. If the configuration, ValueMap or individual properties are null, you can continue without null checks and you won't get a Null Pointer Exception.

Conf respects ACLs and multi-tenant privacy. If you setup your ACLs correctly, a shared component between two tenants will still only be able to access the configurations of the current tenant. Conf does not allow relative paths that try to move up the tree and into another tenant (i.e. "../../differentSite/foo/bar").

ConMgr can be used as a service.



When used as a service, a Resource Resolver can be passed in which allows the use of Sling Service Accounts, thereby respecting ACLs on the configurations.



All inherited configurations can be obtained by using the Conf#getList() method, which returns a List of ValueMaps. Configurations can also be chosen explicitly by using a Resource Resolver to get the specific resource.



View a complete example at https://github.com/nateyolles/aem-slash-conf.

Thanks to Alex Klimetschek ( @alexkli) for sharing his knowledge of /conf of which much of this blog post is based on.

43 comments

Brodie Yazaki | March 28, 2016 at 05:49 PM | Reply

Very interesting, this is a much cleaner and safer way. I appreciate the fact that you can now really enforce ACLs and not have accidental "copy paste and get unexpected results that sit in prod for a few days" kind of incidents.

Nicolas | March 29, 2016 at 08:23 PM | Reply

Great post, really looking forward to see it in action :) Since configurations could be called massively in components it would be great to hear something about performance? Is there a caching layer implemented?

Nate Yolles | March 30, 2016 at 12:01 AM | Reply

Conf is essentially a Resource Resolver with some extra logic specific to its task and reading from a node in the JCR is a lightweight operation.

Andre | March 30, 2016 at 02:56 PM | Reply

Do you know a way, how content author would be able to maintain configurations? So that content authors can edit / nodes under the /conf structure in order to provide flexibilty?

Nate Yolles | March 30, 2016 at 09:44 PM | Reply

You want to create groups with permissions to edit the /conf nodes, one group per tenant to keep them separate. As far as I'm aware, if you need a UI outside of CRXDE Lite, you will have to create one.

Nono Junang | April 04, 2016 at 10:09 PM | Reply

Great extension and great post. As you mentioned the great benefit here is the inheritance of configuration and fallback. I would have expected Adobe to provide this functionality as part of or as an extension to the existing Sling Tenant API instead of creating a new api for that, because you can also save tenant configuration using the Sling Tenant API. I fear this will only get confusing over time.

Matthieu Tremblay | April 05, 2016 at 02:43 PM | Reply

Great write-up, thanks! Will be putting this to use in my future projects.

Kunal | April 11, 2016 at 10:14 AM | Reply

Great write-up.. Very interesting and github project provides a great point of reference. However could you please update the filter for ui.content from /content to /content/aviato, /content/hooli, /content/piedpiper and /content/dam/slashconfdemo as it deletes everything under /content and overrides with the new content.

Nate Yolles | April 14, 2016 at 05:21 PM | Reply

I used the default settings from the AEM archetype, but I can update the filter. Thank you!

tosheer kalra | April 12, 2016 at 05:58 AM | Reply

Nice feature with a great write-up. But why AEM hasn't given feature to update the config as page property in the OOTB page properties dialog or i am missing anything.

Nono Junang | May 17, 2016 at 10:58 AM | Reply

Hi Nate, Can you elaborate what the difference is between this approach and using the Cloud Service Configuration approach? Regards,

Alex | November 16, 2016 at 11:25 PM | Reply

Please note that you have to also allow anonymous for the conf nodes when running this on the publisher. I spent ages trying to figure out why the conf nodes weren't returning anything in the publisher before I figured out it was good old node permissions!

Vineet | February 28, 2017 at 02:22 PM | Reply

Its OK for new configurations. Is there any support for context aware configs for OOTB OSGi services?

Jonas | September 11, 2017 at 01:19 PM | Reply

This sounds like a good way to allow authors to administer global non-technical settings (e.g. contact information, name of ceo, etc.). How can the /conf nodes be replicated to the publisher instances?

-- | February 01, 2018 at 03:08 PM | Reply

Comment removed by author.

MatAscedo | June 14, 2018 at 04:11 AM | Reply

Cash On Delivery Levaquin <a href=http://cialviag.com>cialis</a> Purchase Cialis From North America Cialis 5 Mg Comprime Pellicule Boite De 28 Periactin

dtaletioyo | August 07, 2018 at 06:32 AM | Reply

<a href="http://baymontelreno.com">buy cheap cialis generic</a> very cheap cialis http://baymontelreno.com

italetjiuj | August 18, 2018 at 12:37 AM | Reply

<a href="http://mphasset.com">how to take viagra 50mg</a> viagra retail price http://mphasset.com

ztaletrlok | August 19, 2018 at 01:28 AM | Reply

<a href="http://psychologytweets.com">how to take cialis for best results</a> how long does cialis 20 mg last http://psychologytweets.com

ytaletdwea | August 20, 2018 at 01:40 AM | Reply

<a href="http://mphasset.com">what does viagra feel like</a> how long does a 100mg viagra last http://mphasset.com

MatAscedo | August 27, 2018 at 08:51 PM | Reply

Cialis In Hong Kong Amoxil Clav Tablets <a href=http://cheapciali.com>cialis online</a> Viagra 40 Pills For $99

ptaletglsk | September 11, 2018 at 12:24 AM | Reply

<a href="http://istanbulexpressonline.com">viagra instructions for use</a> viagra for woman http://istanbulexpressonline.com

utaletiybv | September 11, 2018 at 06:24 PM | Reply

<a href="http://timsbmw.com">where can i get levitra</a> how long does levitra last http://timsbmw.com

ctaletmctu | September 13, 2018 at 07:05 AM | Reply

<a href="http://istanbulexpressonline.com">buy viagra overnight</a> buy viagra online discount http://istanbulexpressonline.com

gtaletrtwc | September 13, 2018 at 10:13 AM | Reply

<a href="http://waltzweekend.com">order viagra online without a prescription</a> order pfizer viagra http://waltzweekend.com

ftaletofmc | September 14, 2018 at 04:14 AM | Reply

<a href="http://istanbulexpressonline.com">buy viagra online without</a> mail order viagra uk http://istanbulexpressonline.com

rtaletcfbt | September 14, 2018 at 07:50 PM | Reply

<a href="http://waltzweekend.com">generic viagra soft</a> cheap viagra canada pharmacy http://waltzweekend.com

ztaletcjev | September 15, 2018 at 12:22 AM | Reply

<a href="http://valladium.com">cheap cialis from india</a> buy generic cialis online canada http://valladium.com

ntaletvnon | September 15, 2018 at 07:20 AM | Reply

<a href="http://waltzweekend.com">generic viagra pills</a> best place to order viagra online http://waltzweekend.com

otaletpbmk | September 15, 2018 at 10:32 AM | Reply

<a href="http://unishade.com">buy cialis canada</a> buy cialis online without prescription http://unishade.com

htaletutat | September 16, 2018 at 08:31 AM | Reply

<a href="http://viciolatino.com">buy generic viagra cheap</a> buy viagra cheap http://viciolatino.com

wtaletnkma | September 18, 2018 at 07:09 AM | Reply

<a href="http://top-monterey-salinas-dentists.com">levitra professional 20 mg</a> levitra.com http://top-monterey-salinas-dentists.com

htalettbqo | September 18, 2018 at 09:56 AM | Reply

<a href="http://canadian-pharmabuy.com">internet order viagra</a> buy viagra in mexico http://canadian-pharmabuy.com

ptaletbsku | September 18, 2018 at 08:13 PM | Reply

<a href="http://viciolatino.com">buy viagra online discount</a> buy viagra new york http://viciolatino.com

htaletswcb | September 19, 2018 at 03:20 AM | Reply

<a href="http://istanbulexpressonline.com">cheap female viagra</a> internet order viagra http://istanbulexpressonline.com

ntaletdsse | September 19, 2018 at 08:46 AM | Reply

<a href="http://missreplicawatches.com">buy cialis online with paypal</a> cialis by mail order http://missreplicawatches.com

otaletaafn | September 19, 2018 at 04:11 PM | Reply

<a href="http://buyviagraonl1ne.us">online order for viagra</a> generic viagra from canada http://buyviagraonl1ne.us

otaletvhfc | September 20, 2018 at 02:33 PM | Reply

<a href="http://waltzweekend.com">buy viagra now</a> best online pharmacy viagra http://waltzweekend.com

pauio | September 22, 2018 at 08:56 AM | Reply

https://pauio.com/live/ - ë ¼ì ´ë¸ ì¹´ì§ ë…¸ / https://pauio.com/world/ - ì ë ì¹´ì§ ë…¸ / https://pauio.com/super/ - ì í ¼ì¹´ì§ ë…¸ / https://pauio.com/mka/ - Mì¹´ì§ ë…¸ / https://pauio.com/ssca/ - ì ¼ì ¼ì¹´ì§ ë…¸ /

dancesweb | September 22, 2018 at 08:57 AM | Reply

https://dancesweb.com/yesca/ - ì ì ¤ì¹´ì§ ë…¸ / https://dancesweb.com/obama/ - ì ¤ë° ë§ ì¹´ì§ ë…¸ / https://dancesweb.com/ - ì í ¼ì¹´ì§ ë…¸/

stylebet77 | September 22, 2018 at 08:57 AM | Reply

https://stylebet77.com/yes/ - ì ì ¤ì¹´ì§ ë…¸ / https://stylebet77.com/first/ - í ¼ì ¤í ¸ì¹´ì§ ë…¸ /

como79 | September 22, 2018 at 08:58 AM | Reply

https://como79.com/yes/ - YESì¹´ì§ ë…¸ / https://como79.com/mcasino/ - Mì¹´ì§ ë…¸ / https://como79.com/obama/ - ì ¤ë° ë§ ì¹´ì§ ë…¸ /

custory | September 22, 2018 at 08:59 AM | Reply

https://custory.com/yescasino/ - YESì¹´ì§ ë…¸ / https://custory.com/obama/ - ì ¤ë° ë§ ì¹´ì§ ë…¸ / https://custory.com/super/ - ì í ¼ì¹´ì§ ë…¸ / https://custory.com/33casino/ - 33ì¹´ì§ ë…¸ /

Leave a Comment