
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
Q&A
Please use this thread to ask the related questions.