【发布时间】: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