Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to Migrate @Property with new osgi annotaion

Avatar

Level 4

I have a requirement to have multiple value in props

@Component(service = Servlet.class, metatype = true,
property = {
"sling.servlet.resourceTypes" + "NameConstants.NT_PAGE",
"sling.servlet.selectors" + "image",
"sling.servlet.extensions" + "jpg" ,"jpeg","png","gif",
"sling.servlet.resourceTypes" + "NameConstants.NT_PAGE",
"sling.servlet.selectors" + "image",
})

 Is this the right way? "sling.servlet.extensions" + "jpg" ,"jpeg","png","gif", to have multiple values?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @saurabh_kumar_02, you should use separate entry for each extension, like below

@Component(service = Servlet.class, metatype = true,
        property = {
                "sling.servlet.resourceTypes=" + "NameConstants.NT_PAGE",
                "sling.servlet.selectors=" + "image",
                "sling.servlet.extensions=" + "jpg",
                "sling.servlet.extensions=" + "jpeg",
                "sling.servlet.extensions=" + "png",
                "sling.servlet.extensions=" + "gif"
        })

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @saurabh_kumar_02, you should use separate entry for each extension, like below

@Component(service = Servlet.class, metatype = true,
        property = {
                "sling.servlet.resourceTypes=" + "NameConstants.NT_PAGE",
                "sling.servlet.selectors=" + "image",
                "sling.servlet.extensions=" + "jpg",
                "sling.servlet.extensions=" + "jpeg",
                "sling.servlet.extensions=" + "png",
                "sling.servlet.extensions=" + "gif"
        })