Skip to main content
kautuk_sahni
Adobe Employee
Adobe Employee
December 2, 2020

Annotations for AEM | AEM Community Blog Seeding

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.

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