This post shows how to create an OSGi service in Java (which we assume is the only way) which creates and uses some configuration parameters which can be edited in the configMgr
However, this is useless without the ability to distribute pre-set parameters for the various run modes as part of our code deployment.
AEM documentation seems to be lacking info on this subject, it only has info on configuration on the actual running servers themselves and talks about config under /apps/.
If we look at the wknd project, it seems to be putting config files in:
ui.config/src/main/content/jcr_root/apps/wknd/osgiconfig/*
These files have a strange naming convention, e.g. e.g. com.adobe.aem.graphql.sites.adapters.SlingSchemaServlet~wknd-graphql.cfg.json
Are these files, their location, naming and content structure documented?
We have created a new osgi service (just to read config params) called say MyService with the following path: /aem-guides-wknd.core/src/main/java/com/adobe/aem/guides/wknd/core/services/MyService.java
What should the corresponding config file be called, and where should it be located? How do we link our services config params to the config file?
=== UPDATE ===
@Asutosh_Jena_ kindly replied that I should put xml files under:
/apps/wknd/runmodes/config.dev
This sums up the discrepancy and why I am posting here: things like /apps/wknd/runmodes does not exist, nor anything like it, in the source code for wknd.
This is the wknd source code file structure:
Solved! Go to Solution.
Views
Replies
Total Likes
Not sure if you have already seen my explanations on this topic in your other thread.
The ui.config Maven module is a dedicated place to hold the OSGI configurations that you want to distribute. The structure of the module follows some conventions:
Everything up to (and including) the “jcr_content” folder is part of the Maven module structure (same as with “regular” Java modules holding all packages within the /src/main/java structure). Everything inside the “jcr_content” folder reflects the structure and hierarchy that will be created by the CRX package that the Maven module creates at build time.
Inside the repository all your project specific application code (including OSGI configs) should reside in the “/apps” tree. You will usually create your own folder (e. g. /apps/mysite) that holds all your templates, components, OSGI configs and more.
With regards to the OSGI configs, I have already outlined the naming convention of their respective folders (usually “config” or “config.RUNMODE”). Inside that/these folder/s you can create your OSGI configuration files. These files have to reflect the OSGI bundles PID (basically: fully qualified class name). So an according filename for your MyService class would be “com.adobe.aem.guides.wknd.core.services.MyService.cfg.json”.
Once you deploy your package (which will include the OSGI bundle at /apps/mysite/install/ and your OSGI config at /apps/mysite/config/) everything should be set. AEM will take care if deploying the OSGI bundle from the “install” folder to the OSGI context and apply the according config from the “config” folder. There is nothing more to do.
Recapitulating your specific questions:
Hope that helps.
Hi @TB3dock
If you OSGi Service interface is within
/aem-guides-wknd.core/src/main/java/com/adobe/aem/guides/wknd/core/services/ folder and the interface name is MyService.java
then you must have an Implementation class implementing the above interface which I believe you would have kept under
/aem-guides-wknd.core/src/main/java/com/adobe/aem/guides/wknd/core/services/impl with class name MyServiceImpl.java
If the above statements are true, then your config file will be kept under:
/apps/wknd/runmodes/config path with file name as:
com.adobe.aem.guides.wknd.core.services.imp.MyServiceImpl.xml (it will be full qualified name of the class with .xml as the extension for AEM 6.5 and for cloud service it will be .cfg.json with will be a JSON file)
Please see the sample OSGI XML file:
<?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"
siteKey="somevalue"
secretKey="somevalue"
validationEndpoint="https://www.google.com/recaptcha/api/siteverify"
scriptURL="https://www.google.com/recaptcha/api.js"/>
Highlighted keys will be the variable name those are defined inside the interface which will be mapped against your configuration.
Now for run mode specific you can keep the same .xml file under:
/apps/wknd/runmodes/config.dev
/apps/wknd/runmodes/config.qa
/apps/wknd/runmodes/config.uat
with different values based on the run mode.
Thanks!
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
@TB3dock If you see the above screenshot, you can see osgiconfig folder which is what I was referring as runmodes.
Hope this is clear now.
Thanks!
Views
Replies
Total Likes
Not sure if you have already seen my explanations on this topic in your other thread.
The ui.config Maven module is a dedicated place to hold the OSGI configurations that you want to distribute. The structure of the module follows some conventions:
Everything up to (and including) the “jcr_content” folder is part of the Maven module structure (same as with “regular” Java modules holding all packages within the /src/main/java structure). Everything inside the “jcr_content” folder reflects the structure and hierarchy that will be created by the CRX package that the Maven module creates at build time.
Inside the repository all your project specific application code (including OSGI configs) should reside in the “/apps” tree. You will usually create your own folder (e. g. /apps/mysite) that holds all your templates, components, OSGI configs and more.
With regards to the OSGI configs, I have already outlined the naming convention of their respective folders (usually “config” or “config.RUNMODE”). Inside that/these folder/s you can create your OSGI configuration files. These files have to reflect the OSGI bundles PID (basically: fully qualified class name). So an according filename for your MyService class would be “com.adobe.aem.guides.wknd.core.services.MyService.cfg.json”.
Once you deploy your package (which will include the OSGI bundle at /apps/mysite/install/ and your OSGI config at /apps/mysite/config/) everything should be set. AEM will take care if deploying the OSGI bundle from the “install” folder to the OSGI context and apply the according config from the “config” folder. There is nothing more to do.
Recapitulating your specific questions:
Hope that helps.
Views
Replies
Total Likes
Views
Replies
Total Likes
My question is, where can I find these /osigconfig files in CRXDE once they are deployed to AEM Cloud?
All the documentation I can find says after the deployment they should be under /apps/myproject/osigconfig in CRXDE.
I have two sites in an AEM Cloud environment. One boilerplate site was generated when the environment was setup. The other was created using the new "Standard AEM Site Template 2.1.1".
There isn't a /apps/myproject/osigconfig directory for either of them in CRXDE.
I see the boilerplate site files in our full-stack Adobe git repo: ui.config/src/main/content/jcr_root/apps/myproject/osgiconfig.
So where are they being moved to during deployment?
I'm assuming there has been a recent change to this?
I want to find the /osigconfig files for the "Standard AEM Site Template" site in CRXDE so I can copy them back into our git repo and make changes.
Thanks for your help.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies