【发布时间】:2013-11-14 15:58:37
【问题描述】:
在 iPOJO 中,有没有办法在服务使用者中读取服务属性(例如 getProperty(key) )? 发布者非常直截了当,但在消费者看来我只能使用过滤器。
谢谢
【问题讨论】:
在 iPOJO 中,有没有办法在服务使用者中读取服务属性(例如 getProperty(key) )? 发布者非常直截了当,但在消费者看来我只能使用过滤器。
谢谢
【问题讨论】:
您必须使用回调来检索服务属性:
@Bind
public void bindService(HelloService hello, Dictionary<String, Object> properties) {
// ...
}
或
@Bind
public void bindService(HelloService hello, Map<String, Object> properties) {
// ...
}
您甚至可以检索 OSGi 服务注册:
@Bind
public void bindService(HelloService hello, ServiceReference<HelloService> reference) {
// ...
}
【讨论】: