Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to Enable Run-Mode Specific Servlets in AEM? | AEM Community Blog Seeding

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,369 posts

Correct Reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,369 posts

Correct Reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

30-11-2020

BlogImage.jpg

How to Enable Run-Mode Specific Servlets in AEM? by Albin Issac

Abstract

Enable Run-Mode Specific Servlets in AEM
Servlets are one of the important building blocks of the AEM system to enable the AEM system interacts with external applications, servlets can expose data with external applications also data to be consumed by the Font-End layer.

Some of the time, we may have the use case to enable the servlets based on the run mode(author, publish, etc)of the AEM server, for example, the servlet should be enabled only in the servers with run mode publish or should be enabled only in servers with run mode dev.

In this tutorial, let us see the details on enabling the Servlets in AEM based on the run mode.
The ConfigurationPolicy helps to set the policy for the components through DS annotation.
The configurationPolicy controls whether component configurations must be satisfied depending on the presence of a corresponding Configuration object in the OSGi Configuration Admin service(osgi:config). A corresponding configuration is a Configuration object where the PID is the name of the component.
ConfigurationPolicy.IGNORE — Always allow the component configuration to be satisfied and do not use the corresponding Configuration object even if it is present.

ConfigurationPolicy.OPTIONAL — Use the corresponding Configuration object if present but allow the component to be satisfied even if the corresponding Configuration object is not present.

ConfigurationPolicy.REQUIRE — There must be a corresponding Configuration object for the component configuration to become satisfied.
By specifying the configuration policy as REQUIRE the component will be enabled only when the configuration(osgi:config) is available for the specific run mode otherwise the component will be unsatisfied.

By following this, we should be able to enable the Servlets on specific run mode, create the configuration(osgi:config) for the servlet PID on required run modes so the servlet will be enabled for those specific run modes and disabled on other run modes.

Read Full Blog

How to Enable Run-Mode Specific Servlets in AEM?

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager