Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

replacing Felix annotations by OSGI R6 mannotations

Avatar

Level 3

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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



Arun Patidar

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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



Arun Patidar