Featured
- Get link
- X
- Other Apps
Adobe Experience Manager - configure OSGI Configurations
In this article, we are going to discuss the different ways to add configurations into the AEM instance. Technically there are four simple ways to add configurations into an AEM instance, in this article in addition to the explanation for the different types I included a few examples for each to help with the implementation in your projects.
Technical details and Assumptions:
All the following details are tested in AEM version 6.5.8, Java version 11.0.2
Across this article, I am assuming that you have already created a custom config to configure or just updating a default configuration that's built-in AEM as out-of-box configurations.
To create a new OSGi configuration, check my other article about it here.
Different methods to add configurations:
1) Configuring manually in the web console
A little unfortunate that this web console does not have an inbuilt search system. We can just use the browser's page-level search function using Ctrl + F. Once we get a hold of which config to update, the update is straightforward.
For explaining purposes I am using the default Apache logger (Apache Sling Logging Logger Configuration). I chose a config with multiple configurations in this example so that, both single and multiple configurations can be explained.
The plus icon helps to create a new configuration.
For editing the configurations, you can either click on the pen icon or the entire row to open the overlay which helps to update the configurations. this overlay looks like the follows,
The necessary changes can be made and saved to be reflected in the AEM instance. Similarly, we have a delete and unbind option which can help to remove the config temporarily or permanently.
2) Add configurations to the codebase
If you are planning to create a new configuration entry or update one that has already been added, you can check under the following hierarchy with a repository node of type sling:OsgiConfig or property files,
/apps/*/config
Now let's check now the configurations can be arranged and categorized, One main way to do that is based on the run-modes. Please feel free to look into the official AEM documentation here. Usually, inside your project folder under /apps folder, the configurations are placed.
The folder names are given based on the run mode, AEM prioritization is based on how specific the configuration is written to the given AEM instance.
/config/
/config.dev/
/config.dev.author/
/config.stage/
/config/stage.publisher/
As long as the configs are placed under a folder that has a naming similar to the above and is under /apps folder, the configs should be loaded into the AEM instance.
Specs of the configuration file:
Diving into the specs of the config file, here for explaining the steps I and using the following email configuration com.day.cq.mailer.DefaultMailService
a) the name of the configuration file should be in the following format,
<class-name>.xml
A sample configuration file name would look like this,
com.day.cq.mailer.DefaultMailService.xml
Note: if the implementation class is implemented via interface.classname will be the interface name otherwise it will be an implementation class.b) the XML file should look like the following,
<?xml version="1.0" encoding="UTF-8"?> | |
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" | |
jcr:primaryType="sling:OsgiConfig" | |
debug.email="{Boolean}false" | |
smtp.port="{Long}25" | |
smtp.user="you-know-i-cannot-say-this-here" | |
smtp.ssl="{Boolean}false" | |
from.address="mostly-your-mail-id" | |
smtp.host="whatever-your-host-says" | |
/> |
Just building the code with this XML in it will help to load the configurations automatically
3) Add configuration as a package:
debug.email="{Boolean}false" | |
smtp.port="{Long}25" | |
smtp.user="you-know-i-cannot-say-this-here" | |
smtp.ssl="{Boolean}false" | |
from.address="mostly-your-mail-id" | |
smtp.host="whatever-your-host-says" |
4) Add configurations directly to the AEM instance:
:org.apache.felix.configadmin.revision:=L"1" | |
debug.email=B"false" | |
from.address="mostly-your-mail-id" | |
service.pid="com.day.cq.mailer.DefaultMailService" | |
smtp.host="whatever-your-host-says" | |
smtp.port=L"25" | |
smtp.ssl=B"false" | |
smtp.user="you-know-i-cannot-say-this-here" |
Which one takes priority?
the order of precedence can be categorized into two based on whether its run-time/startup,order of precedence during startup:
2) Repository nodes with type sling:OsgiConfig under /libs/*/config.... (out-of-the-box definitions).
3) Any .config files from <*cq-installation-dir*>/crx-quickstart/launchpad/config/.... on the local file system.
order of precedence during run-time:
1) Modifying a configuration in the Web console will take immediate effect as it takes precedence at runtime.2) Modifying a configuration in /apps will take immediate effect.
3) Modifying a configuration in /libs will take immediate effect unless it is masked by a configuration in /apps.
Comments
Post a Comment