【问题标题】:Getting the service specification and the service filter of an OSGI reference获取 OSGI 参考的服务规范和服务过滤器
【发布时间】:2014-05-20 12:33:52
【问题描述】:

假设我有一个包含类 X 的 OSGI Bundle。假设这个类包含对特定服务的 OSGI 引用。像这样的:

ServiceReference[] references = context.getServiceReferences (serviceSpecification,someFilter);

有没有一种方法可以动态识别引用所连接的服务规范?有没有办法同时识别服务过滤器(上面的第二个参数)?

例如,像这样的:

System.out.println(references[0].getServiceSpecification);
System.out.println(references[0].getServiceFilter);

我需要在包外的代码中找出这些值。

目前已完成的工作:

我使用iPOJO通过创建bundle的iPOJO组件实例来获取引用属性,然后获取它的属性描述,如下:

ComponentInstance  componentInstance = factory.createComponentInstance(configuration);
instanceDescription= (PrimitiveInstanceDescription) componentInstance.getInstanceDescription();
PropertyDescription[] propertyDescription = instanceDescription.getProperties();

我可以使用上面的propertyDescription 获取引用名称、类型、值,但是该值作为对象返回,我无法得到我需要的东西。有人可以帮忙吗?谢谢。

【问题讨论】:

    标签: service reference osgi soa ipojo


    【解决方案1】:

    请看Service Hooks。使用服务挂钩,您可以挂钩服务注册操作并观察服务的发现。

    【讨论】:

      猜你喜欢
      • 2018-12-25
      • 2014-08-29
      • 2014-12-22
      • 2013-08-12
      • 2011-01-07
      • 1970-01-01
      • 2012-09-16
      • 2010-10-26
      • 2010-09-23
      相关资源
      最近更新 更多