Hi @TB3dock
OSGi DS 1.4 (R7) component property type annotations for Sling Servlets (recommended) is supported from bnd-maven-plugin 4.1.0+ and maven-bundle-plugin 4.1.0+ and this is the recommended approach to write the Servlet. I personally am using this on my AEM 6.5.5.0 instance and it's not specific to AEM as Cloud SDK.
@Component(service = {Servlet.class})
@SlingServletResourceTypes(
resourceTypes = "/apps/my/type",
methods = "GET",
extensions = "html",
selectors = "hello")
public class MyServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
...
}
}
Simple OSGi DS 1.2 annotations were used earlier and also can be used now only if we cannot use the above approach which I believe will never be a case
All the articles that are written so far are before DS 1.4 was released and it's never updated. But we should always refer the Sling document for updates.
@Component(service = {Servlet.class},
property = {
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=/apps/my/type"
ServletResolverConstants.SLING_SERVLET_METHODS + "=GET",
ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=html",
ServletResolverConstants.SLING_SERVLET_SELECTORS + "=hello",
}
)
public class MyServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
...
}
}
I will suggest that you should go with DS 1.4 version.
Hope this helps!
Thanks