osgi r6 service.component.annotations property list

爱⌒轻易说出口 提交于 2019-12-12 04:12:36

问题


maybe I am plain stupid, but how do I set a list in a property value? For example with the felix scr annotations, a servlet looked somewhat like this

@Component(metatype = false)
@SlingServlet(
 methods = { "GET", "POST" },
 resourceTypes = "sling/servlet/default",
 selectors = { "size" },
 paths = { "/some/stupid/path/.*" }

with the new osgi service annotations

@Component(service = Servlet.class,
    property = { 
     "sling.servlet.methods=GET",
     "sling.servlet.methods=POST",
     "sling.servlet.resourceTypes=sling/servlet/default",
     "sling.servlet.selectors=size",
     "sling.servlet.paths=/some/stupid/path.*" })

How can I set the servlet.methods as a list? Admittedly in this example it is not much of a problem, but I have a servlet that activates on a lot of selectors, and I really do not want to have 20 lines of "sling.servlet.selectors=..."


回答1:


From the javadoc: To specify a property with multiple values, use multiple name, value pairs. For example, "foo=bar", "foo=baz". So what you have should work in that the value of sling.servlet.methods will be an array [GET,POST]

Support for the future DS 1.4 spec should make this easier by allowing annotations to set property values. See 5.10 in RFC 222.



来源:https://stackoverflow.com/questions/41243873/osgi-r6-service-component-annotations-property-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!