OSGi的/费利克斯声明式服务:如何筛选服务受约束? [英] OSGi/Felix Declarative Services: How to filter the services to be bound?

查看:313
本文介绍了OSGi的/费利克斯声明式服务:如何筛选服务受约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache费利克斯和声明式服务(SCR)到导线束之间的服务依赖关系。

I am using Apache Felix and its Declarative Services (SCR) to wire the service dependencies between bundles.

例如,如果我需要访问java.util.Dictionary中的我可以说下面有SCR提供一种:

For example, if I need access to a java.util.Dictionary I can say the following to have SCR provide one:

/**
* @scr.reference name=properties interface=java.util.Dictionary
*/

protected void bindProperties(Dictionary d) {
}

protected void unbindProperties(Dictionary d) {
}

现在,我有一个以上的字典服务,我想用名的服务属性(我只是想NAME = myDictionary)来过滤。我可以做到这一点与code(使用ServiceTracker的),但我宁愿在指定的@scr注释,而不是过滤器。

Now, I have more than one Dictionary service available, and I want to filter them using the "name" service property (I only want "name=myDictionary"). I can do that with code (using a ServiceTracker), but I'd rather specify the filter in the @scr annotation instead.

推荐答案

我觉得

target="(name=myDictionary)"

应该做的 @ scr.reference 标注的伎俩。请参见 http://felix.apache.org/site/apache-费利克斯 - Maven的SCR-plugin.html

这篇关于OSGi的/费利克斯声明式服务:如何筛选服务受约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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