How to Register Servlets Dynamically in AEM? | AEM Community Blog Seeding | Community
Skip to main content
kautuk_sahni
Community Manager
Community Manager
December 1, 2020

How to Register Servlets Dynamically in AEM? | AEM Community Blog Seeding

  • December 1, 2020
  • 1 reply
  • 3101 views

BlogImage.jpg

How to Register Servlets Dynamically in AEM? by Albin Issac

Abstract

Most of the time while working on the project we will have scenarios to dynamically register the servlets with different resource types, selector and extension, etc — registering the same servlet with different resource types, selector, extensions, etc.

Let's assume we have a servlet that is registered with a specific resource type but later we have a requirement to enable the same servlet for a different resource type, one of the common options is modifying the source code to enable the additional resource types. The code change might not be the optimal solution in most cases.

In this tutorial, let us see the simple approach to register the servlets dynamically with different resource types, selectors, and extensions.

The OSGi Metatype Annotations(OSGi Declarative Services Annotations) can be used to register the dynamic servlets.

ObjectClassDefinition — Generate a Meta Type Resource using the annotated type

AttributeDefinition — AttributeDefinition information for the annotated method.

Designate — Generate a Designate element in the Meta Type Resource for an ObjectClassDefinition using the annotated Declarative Services component.

Read Full Blog

How to Register Servlets Dynamically in AEM?

Q&A

Please use this thread to ask the related questions.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Level 4
December 1, 2020

Hi @kautuk_sahni ,

Is there any specific reason is there that JSON or txt extensions can be accessed only from jcr:content node.

 

Please provide me some explanation.

 

In this article for configuration class static is added. Because of that configuration is not registering. After removing static it worked perfectly.

public static @interface Config 

Thanks,

Sandeep. 

 

 

 

kautuk_sahni
Community Manager
Community Manager
December 1, 2020

@sandeep6  This is a Blog post from Albin. I have asked him to assist you.

 

Kautuk Sahni