replacing Felix annotations by OSGI R6 mannotations

sivas61374651 13-08-2018

Hi all,

I just want to have multiple selectors & multiple Method type in property attribute of @Component OSGI annotations. And here is the change I made. Is it right? will it work ? If not can anyone help me on this like what is expected?

@Component(service = {Servlet.class},

property = {

"sling.servlet.resourceTypes=" + "cq:Page",

"sling.servlet.selectors=" + HardwareConfiguratorJsonServlet.CONFIGURATOR_SELECTOR,

    HardwareConfiguratorJsonServlet.ONECLICKBUY_SELECTOR,

    HardwareConfiguratorJsonServlet.HARDWARE_SELECTOR,

"sling.servlet.extensions=" + "json",

"sling.servlet.methods=" + "POST",

"sling.servlet.methods=" + "GET"

})

public class HardwareConfiguratorJsonServlet extends AbstractJsonGeneratorServlet {

@SlingServlet(resourceTypes = "cq:Page",

    selectors = {HardwareConfiguratorJsonServlet.CONFIGURATOR_SELECTOR,

        HardwareConfiguratorJsonServlet.ONECLICKBUY_SELECTOR,

        HardwareConfiguratorJsonServlet.HARDWARE_SELECTOR},

    extensions = "json", methods = {"POST", "GET"})

public class HardwareConfiguratorJsonServlet extends AbstractJsonGeneratorServlet {

Thanks,

Vijay

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar
MVP
13-08-2018

Hi,

You can check Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache S... and Apache Sling :: Servlets and Scripts

You can try below

sling.servlet.resourceTypes = [ "sling/unused" ] sling.servlet.selectors = [ "img", "tab" ] sling.servlet.extensions = [ "html", "txt", "json" ]

OR

"sling.servlet.selectors=img",

"sling.servlet.selectors=tab",

Thanks

Arun