从 OSGi 容器外部查找 OSGi 服务 [英] Looking up OSGi services from outside the OSGi container

查看:33
本文介绍了从 OSGi 容器外部查找 OSGi 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Karaf 中部署了一组包,并公开了许多 OSGi 服务,我希望能够从运行在(可能)不同机器和非 OSGi 容器上的应用程序远程查找和调用这些服务.我最初是使用 JNDI 查找来获取我想要的服务,但是我从 较早的 stackoverflow 帖子 这可能不受支持(我说可能是因为我无法找到有关 Aries JNDI 实现是否有任何更改的任何信息过去一年).在这种情况下,我想我的其他选择是使用 CXF 为我的服务公开 JAX-WS 或 JAX-RS API.

I have a set of bundles deployed in Karaf and exposing a number of OSGi services which I would like to be able to lookup and call remotely, from an application running on a (possibly) different machine and in a non-OSGi container. My initial though was to use JNDI lookup to get the services I want however I understand from an earlier stackoverflow post that this might not be supported (I say might since I haven't been able to find any information on whether anything has changed on the Aries JNDI implementation in the past year). In that case I guess my other options would be to use CXF to expose a JAX-WS or JAX-RS API for my services.

我对情况的理解是否正确?在我的情况下,JNDI 查找真的不是一个选项吗?还有其他我没有想到的替代方案吗?

Is my understanding of the situation correct? Is JNDI lookup really not an option in my case? Are there any other alternatives I have not thought of?

推荐答案

简单的 jndi 查找将不起作用.OSGi 服务本身不适合远程处理.所以即使你可以通过某种方式得到 jndi 对象,你也无法调用它.

A simple jndi lookup will not work. OSGi services are not suitable for remoting per se. So even if you can get the jndi object in some way you can not call it.

可能的解决方案是手动 cxf 代理和端点,就像您已经找到的分布式 OSGi.请参阅 CXF-DOSGi 和 Eclipse ECF.两者都可以提供从一个 OSGi 框架到另一个框架的透明服务调用.如果您还在客户端使用 OSGi,DOSGi 是理想的选择.至少在 CXF DOSGi 的情况下,也可以在服务器端使用 DOSGi,在客户端使用普通的 CXF 客户端.因此,您可以尽量减少服务器端的工作量.

Possible solutions are manual cxf proxies and endpoints like you already found and Distributed OSGi. See CXF-DOSGi and Eclipse ECF. Both can offer transaparent service calls from one OSGi framework to another. DOSGi is ideal if you also use OSGi on the client side. At least in case of CXF DOSGi it is also possible to use DOSGi on the server side and a normal CXF client on the client side. So you can keep the effort on the server side minimal.

另请参阅此CXF DOSGi 教程

这篇关于从 OSGi 容器外部查找 OSGi 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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