


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”})
Please use this thread to ask the related questions.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes