Annotations for AEM | AEM Community Blog Seeding

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.7K

Likes

1.0K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.7K

Likes

1.0K

Correct Reply

1.1K
kautuk_sahni
Community Manager

01-12-2020

BlogImage.jpg

Annotations for AEM by Kiran Vedantam

Abstract

As many of you know, we are now already out of SCR annotations and moving swiftly into OSGI Declarative services[Post AEM 6.2]. In this blog we are going to discuss only about the OSGI declarative services annotations [R7] which can be used in different scenarios.

All the Annotations below can be used directly in the places mentioned. So happy and fast coding 😁

Note: Before we start using the annotations, we need to have the dependencies added in the pom (pre-requisite of course 😉)


org.osgi
osgi.annotation
7.0.0
provided


Servlet Annotation:

Servlet Method — GET via path: @Component(service = Servlet.class, property = {
Constants.SERVICE_DESCRIPTION + “=Sample GET Servlet”,
“sling.servlet.methods=” + HttpConstants.METHOD_GET, “sling.servlet.paths=” + “/bin/sampleServlet” })

Servlet Method — POST via path: @Component(service = Servlet.class, property = { Constants.SERVICE_DESCRIPTION + “=Sample POST Servlet”, “sling.servlet.methods=” + HttpConstants.METHOD_POST, “sling.servlet.paths=” + “/bin/sampleServlet” })

Servlet Method — GET via resource type: @Component(service=Servlet.class, property={ Constants.SERVICE_DESCRIPTION + “=Sample Demo Servlet”, “sling.servlet.methods=” + HttpConstants.METHOD_GET, “sling.servlet.resourceTypes=”+”sampleproject/components/structure/page”, “sling.servlet.selectors=” + “json”})

Servlet Method — POST via resource type: @Component(service=Servlet.class, property={ Constants.SERVICE_DESCRIPTION + “=Sample Demo Servlet”, “sling.servlet.methods=” + HttpConstants.METHOD_POST, “sling.servlet.resourceTypes=”+”sampleproject/components/structure/page”, “sling.servlet.selectors=” + “json”})

Read Full Blog

Annotations for AEM

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager