osgi r6 service.component.annotations属性列表 [英] osgi r6 service.component.annotations property list

查看:123
本文介绍了osgi r6 service.component.annotations属性列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我很愚蠢,但是如何在属性值中设置列表? 例如,使用felix scr批注,一个servlet看起来像这样

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/.*" }

带有新的osgi服务注释

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.*" })

如何将servlet.methods设置为列表?可以肯定的是,在这个例子中这不是什么大问题,但是我有一个可以在很多选择器上激活的servlet,我真的不希望有20行"sling.servlet.selectors = ..."

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=..."

推荐答案

来自javadoc:To specify a property with multiple values, use multiple name, value pairs. For example, "foo=bar", "foo=baz".因此,您应该执行的工作是sling.servlet.methods的值将是一个数组[GET,POST]

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]

通过允许注释设置属性值,对将来的DS 1.4规范的支持应使此操作更容易.参见 RFC 222 中的5.10.

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.

这篇关于osgi r6 service.component.annotations属性列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆