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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Annotations for AEM | AEM Community Blog Seeding

kautuk_sahni
Community Manager
Community Manager

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies