Showing posts with label Sling. Show all posts
Showing posts with label Sling. Show all posts

Saturday, 14 September 2019

Apache Sling's Request Processing Analyzer

AEM provides a console to check recent requests, by default only 20 requests can be seen which is a troublesome in production environment as we get millions of requests. We can update the default value, but it will be difficult when we get some millions of requests in production.

Recent requests in AEM:



Apache Sling provides a tool to analyze all the recent requests using "Request Processing Analyzer". To install this tool download the code from GitHub and run mvn clean install. Once build is success, we can see jar files in target folder. Install org.apache.sling.reqanalyzer-0.0.1-SNAPSHOT.jar to AEM instance.

A log file requesttracker.txt is created in ${sling.home}/logs folder. To analyze this log file we need to run below command, which opens a graphical window
java -jar org.apache.sling.reqanalyzer-0.0.1-SNAPSHOT.jar D:\CQ5\CQ5\AEM6.4\crx-quickstart\logs\requesttracker.txt

We can see below info in the window
  • Start time stamp in milliseconds
  • Request processing time in milliseconds
  • Request method
  • Request URL
  • Response content type
  • Response status
To analyze a specific request, click on it then we can see new window with more info.

We can see below info
  • Timestamp - shows the timestamp of each step that the request
  • Delta - time between each step
  • Message - shows info about which step is processed

Monday, 14 August 2017

Sling Resource API vs JCR API - Performance

Check the article to compare the performance when using Sling Resource API and JCR API.

This article illustrates different tests performed to compare the performance of sling resource api and jcr api.

Test 1: Traversing /content/geometrixx tree
Result: JCR API is roughly twice as fast as the Sling API when traversing a tree.

Test 2: Creating simple pages (single save)
When creating a 1000 simple pages and saving them in one go, it takes respectively 0.20 and 0.26 ms for the JCR and Sling API to create a single page. Creating 1000 pages took 200 and 260 ms respectively for JCR and Sling in total.






Saturday, 18 March 2017

Populating AEM Component Dialog fields using JSON data returned by Sling Servlets

You can invoke an Adobe Experience Manager (AEM) Sling Servlet to populate fields that appear in AEM component dialog. That is, instead of hard-coding values in JavaScript, you can populate a dialog drop-down using a Servlet's return value (for example, JSON data), as shown in the following illustration. 

Saturday, 5 December 2015

Exception while calling a Servlet in AEM

Question:  I am trying to access a servlet with a doPost method from the JSP and getting the following exception -Caused by org.apache.sling.api.resource.PersistenceException: Resource at ‘/location/Stores’ is not modifiable.
  at rg.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(SlingPropertyValueHandler.java:153)
    at org.apache.sling.servlets.post.impl.operations.ModifyOperation.writeContent(ModifyOperation.java:411)
    at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:101)
My bundle is built successfully and the resource resolver shows the path as expected and resolves to the given path.Activate method of the servlet is successfully called.However while trying to give an Ajax call from the jsp it never reaches the doPost method.I tried it both with doPost and doGet.Please help.
Answer: Give your servlet path as /bin/location/Stores or /services/location/Stores which is configured in ‘Apache Sling Servlet Resolver’
If you want, you can add your own Servlet/Script resolver from /system/console/configMgr and your custom resourcePath will be resolved by the servlet resolver

Monday, 16 November 2015

Creating a Sightly and Sling Model DOM parser component

Check below url to create a sightly and sling model dom parser component :)
https://helpx.adobe.com/experience-manager/using/domparser.html


Images retrieved from the AEM Dom Parser component

Finding out what components my page is using

There are a few ways to do this. One way is to go into the felix console: http://localhost:4502/system/console/bundles, and go under main, and click on the "Sling Resource Resolver" link. Enter the url you want to know more about and press enter. It will give you a list of possible pages it is using. Open up crx/de or the Eclipse plug-in and find the page, and find where the page or template is located.

A quicker way is to add ?debug=layout to the end of the url of the page in question. It will display where every component on your page is located.

Friday, 13 November 2015

Disabling the XML and JSON render in Adobe CQ5/AEM

To disable the XML or JSON renderer, navigate to the OSGI configuration manager at the following URL:

http://localhost:8080/system/console/configMgr

Click on Apache Sling GET Servlet, uncheck “Enable XML” and Enable JSON , then click save.

Map multiple domains to one AEM instance

AEM which is based on Apache Sling [1] provides the necessary functionality through repository-based configuration. When resolving resources, these so-called mappings are applied.

The following example configuration is based on the Geometrixx website that comes per default with a AEM installation. The Geometrixx website is already multilingual and serves perfectly as example.

The goal is to configure these mappings:
Domain                     Content branch
www.geometrixx.fr/content/geometrixx/fr
www.geometrixx.de/content/geometrixx/de
These nodes have to be created in the default workspace of the repository via the CRX Content Explorer, required nodetypes in brackets:
1
2
3
4
5
6
7
/etc
   /map                       (sling:Folder)
      /http                   (sling:OrderedFolder)
         /www_geometrixx_fr   (sling:Mapping)
         /www.geometrixx.fr   (sling:Mapping)
         /www_geometrixx_de   (sling:Mapping)
         /www.geometrixx.de   (sling:Mapping)
2 mappings are required:
  • map the root context to the index-page of the language branch, e.g. www.geometrixx.fr --> /content/geometrixx/fr.html
  • map resources to the corresponding language branch
Following is the JSON representation of the configuration necessary to map these 2 domains (/etc/map/http.tidy.-1.json):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  "jcr:primaryType": "sling:OrderedFolder",
  "www_geometrixx_fr": {
    "sling:internalRedirect": [
      "/content/geometrixx/fr.html"
    ],
    "jcr:primaryType": "sling:Mapping",
    "sling:match": "www.geometrixx.fr/$"
  },
  "www.geometrixx.fr": {
    "sling:internalRedirect": [
      "/content/geometrixx/fr",
      "/"
    ],
    "jcr:primaryType": "sling:Mapping"
  },
  "www_geometrixx_de": {
    "sling:internalRedirect": [
      "/content/geometrixx/de.html"
    ],
    "jcr:primaryType": "sling:Mapping",
    "sling:match": "www.geometrixx.de/$"
  },
  "www.geometrixx.de": {
    "sling:internalRedirect": [
      "/content/geometrixx/de",
      "/"
    ],
    "jcr:primaryType": "sling:Mapping"
  }
}