有没有办法查看OSGi应用程序中的注册服务? [英] is there a way to view registered services in an OSGi application?

查看:76
本文介绍了有没有办法查看OSGi应用程序中的注册服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行Equinox的OSGi应用程序.我想查看应用程序提供的服务.我该怎么办?

I have an OSGi application running Equinox. I'd like to see the services that are provided by the application. How can I do this?

推荐答案

这取决于您是使用OSGi Shell进行交互还是通过应用程序进行编程.

It depends whether you mean interactively, using an OSGi shell, or programmatically from your application.

交互式

您可以使用 Equinox控制台.请参阅服务".要仅查看已部署的服务,您需要使用LDAP过滤器.这是一个示例:

You can use the Equinox console. See 'services'. To only see the services you have deployed you need to use an LDAP filter. Here's an example:

(objectClass=my.package.name.*)

也请参阅@Neil Bartlett的回答,因为您可以通过捆绑包ID进行约束(假设您知道它,但这很容易找到),因此答案可能会更容易.

Also see @Neil Bartlett's answer which might be easier as you can just constrain by bundle id (assuming you know it, but that's easy to find).

以编程方式

使用ServiceTracker方法. Neil也写了所有这一切,因此请确保也给他投票: )

Use the ServiceTracker approach. Neil also wrote all about this, so make sure to give him your upvotes too :)

这篇关于有没有办法查看OSGi应用程序中的注册服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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