Friday, April 21, 2017

AEM6 | How To DO's

1. Ensuring that component/ servelet works in specific environment only

There are several workarounds to it. But the suggested solution is to bind a configuration policy with your component which might be a service, servlet, job, workflow etc. The declaration looks like this-

@Component(policy=ConfigurationPolicy.REQUIRE)

Now, you need to create configuration settings file for only those environment where you want your component to work i.e. runmode based configuration file. For example if you want your component to work only in authoring environment then create a configuration file for your component under "/apps/{yourProjectCodeRoot}/config.author".

2. Configuration preferences order

Resolution order at startup- 

  1. /apps/*/config
  2. /libs/*/config
  3. crx-quickstart/launchpad/config

Resolution order at runtime- 

  1. Chnage in OSGi console
  2. /apps/*/config
  3. /libs/*/config

3. Runmode preferences order

There are several methods for specifying which run mode to use; the order of resolution is:
  1. sling.properties file
  2. -r option through command line
  3. system properties (-D) in start up script
  4. Filename detection/ Jar name

4. Production Ready Mode

If you start AEM instance with "nosamplecontent" runmode, it will ensure that by default the instance is pre-configured with major security measures.

5. AEM instance behavior to author/ publish

Behavior of an AEM instance is driven by the run mode. For authoring instance- run mode must be set to "author". For publisher instance- run mode must be set to "publish".  "author, publish, samplecontent, nosamplecontent" - are the Installation run modes. They can not be changed after installation.

In addition, the "Day CQ WCM Filter" should be set to "edit" on author and "disabled" on publish instances from the OSGi console or through the OSGi configuration file.

6. Linking SonarQube with Jenkins 

Refer the instruction on the SonarQube website- https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins

The simple way to integrate the two is - "Analyzing with the SonarQube Scanner for Maven". Follow the instructions on the above link. When setting up the Build profile in Jenkin set the Goal as shown in below snapshot-

7. Accessing AEM logs

You can use this URL- http://{host:port}/system/console/slinglog/tailer.txt?tail=500&name=/logs/error.log

No comments:

Post a Comment

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps: 1. Develop Custom TransportHandler Develop a custom Trans...