what is the use of png.java in AEM

127 views Asked by At

I have an file with the name

apps\cq\personalization\components\clientcontext\command\thumbnail\png.java

what is use of this file.This file seems to be creating many static analysis issues.

1

There are 1 answers

0
santiagozky On BEST ANSWER

First of all, in AEM it is possible to put JAVA files inside the jcr repository. they will be treated the same way as any script (jsp, sightly, etc) and follow the same render conditions. The img.JAVA servlet, which renders most images in AEM, is a good example of this.

In your case, your file is an overlay for a file originally in /libs/cq/personalization/components/clientcontext/command/thumbnail/png.java, which means that it is probably a variation of the original file.

This is a servlet which will respond to requests with the png extension for resources with resourceType cq/personalization/components/clientcontext/command/thumbnail.

Quickly looking through it, it seems it simply renders an image that is located inside the AEM Client Context path.

I agree with you that it is a curious approach (note the TODO inside the file ). If you need an overlay for this and dont want to keep a Java file inside your repository, you could achieve the same by registering the same servlet as an OSGi declarative service for the right extension and resourceType using the @SlingServlet annotation.