远程处理和 OSGi

发布于 2024-07-25 19:30:52 字数 154 浏览 8 评论 0原文

是否有一种优雅的方式可以在 OSGi 容器之间或之间使用服务?

这可能吗?

例如,假设我的本地计算机上有一个服务接口。 我可以使用哪些方法/技术来通过远程 OSGi 容器的 BundleContext 访问该服务接口?

Is there an elegant way to use Services across or between OSGi containers?

Is it even possible?

For instance, lets say I have a service interface on my local machine. What methodologies/technologies can I use to get that service interface accessible through a remote OSGi container's BundleContext?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

執念 2024-08-01 19:30:52

有一个名为远程服务(以前称为分布式 OSGi)的 RFC,它正是您想要实现的目标。 RFC 已基本完成,目前已经有 2 个实现,分别由 Apache CXF 和 Eclipse ECF 提供。

这两种实现都允许对 OSGi 服务进行透明的远程处理。 您只需像往常一样定义 OSGi 服务,并添加一些配置参数以使其成为远程服务。

检查:
http://cxf.apache.org/distributed-osgi.html

There is a RFC called Remote Services (formerly Distributed OSGi) that does exactly what you are trying to achieve. The RFC is almost completed, and there are already 2 implementations provided respectively by Apache CXF and Eclipse ECF.

Both the implementations allows to do transparent remoting of an OSGi service. You just have to define the OSGi service as usual, and add some configuration parameters to make it a remote service.

Check:
http://cxf.apache.org/distributed-osgi.html

小…楫夜泊 2024-08-01 19:30:52

这是可能的,但是没有库(据我所知)可以为您执行此操作。 我已经为目前的工作做好了准备。 OSGi运行在客户端和服务器上,RMI是传输。 我不得不大量使用代理对象。

在服务器的 OSGi 运行时 (Equinox) 中注册服务。 我有一个侦听器,它监视所有寻找属性/属性的服务,指示该服务应该导出(设为远程),例如“remotable=true”。 使用 ServiceTracker 可以轻松进行过滤。 通过 RMI,我指示客户端使用服务接口创建一个代理对象。 对此代理对象的所有调用通常都通过 RMI 发回(类似 execService serviceid、方法名称、var args params 的调用),然后在 REAL 服务上调用。

我省略了一些低级细节,但您可能可以解决它。 如果您可以远离 RMI,您可能需要研究 Riena (甚至可能有一个为 Riena 编写 RMI 传输的方法,我只是懒得尝试)

It is possible, but there are no libraries (afaik) that will do this for you. I've rolled my own for my current job. OSGi runtime on client and server, RMI is the transport. I've had to make HEAVY use of Proxy objects.

Register a service in the server's OSGi runtime (Equinox). I have a listener that watches all services looking for a property/attribute indicating this service should be exported (made remote), something like "remotable=true". It's easy to filter using the ServiceTracker. Over RMI I instruct the client to create a Proxy object with the service interface. All calls to this proxy object are generically send back over RMI (a call like execService serviceid, method name, var args params) and then invoked on the REAL service.

I've left out some of the low level details, but you can probably sort it out. If you can stray away from RMI, you may want to look into Riena (there may even be a way to write an RMI transport for Riena, I just haven't bothered to try)

花想c 2024-08-01 19:30:52

目前还不清楚你想要实现什么目标。 您已经有了一个服务,可以使用 RMI 访问它,并且需要作为 OSGi 服务提供?

我想你可以为本地机器服务编写一个接口。 然后,您可以编写一个连接到该服务的包,并在 OSGi 服务注册表中公开该接口。 然后,您的主包可以使用接口名称或服务名称来定位该服务。

获得与本地服务的 RMI 连接应该不会有太多工作。 也许有一些配置选项来建立初始连接。 在将服务发布到 OSGi 中之前,为服务编写外观可能很重要,以便实现某种形式的解耦,并且可能隐藏它是 RMI 服务的事实。

但也许我完全误解了你,这一切都是无用的。

It's not very clear what you are trying to achieve. You have got a service, you can access it using RMI, and you need to available as an OSGi service?

I guess you could write an interface to you local machine service. You could then write a bundle that connectes to that service and exposes that interface in the OSGi service registry. Then, your main bundle could locate that service using the interface name or service name.

It shouldn't be too much work to get an RMI connection to your local service. Maybe some config options to establish the initial connection. It might be important to write a facade for your service before you publish it in OSGi, in order to achieve some form of decoupling, and perhaps to hide the fact that it is an RMI service.

But then maybe I completely misunderstood you and all this is useless.

情感失落者 2024-08-01 19:30:52

除了上面的 CXF 之外,还有 Eclipse ECF,它是通信框架的集合,并提供 OSGi 4.2 远程服务(又名分布式 OSGi)的早期实现。 它的工作原理是注册客户端在虚拟机中绑定的本地服务,然后在远程计算机上创建代理,并使用您选择的技术(RMI、WebServices 等)可以远程调用。

显然,这使用了按值方法调用语法(您的服务需要了解该语法),但除此之外,任何通信错误都是 RuntimeException。

As well as CXF above, there's also Eclipse ECF, which is a collection of communication frameworks and provies an early implementation of the OSGi 4.2 remote services (aka distributed OSGi). It works by registering a local service to which your client binds in the VM, then creates a proxy on the remote machine, and using a technology of your choice (RMI, WebServices etc.) can remote the calls.

Obviously this uses by-value method invocation syntax (which your service needs to know about) but other than that, any comms errors are RuntimeException.

贵在坚持 2024-08-01 19:30:52

这当然是有可能的。 查看 https://docs.paremus.com//display/NIM20/Home其中包括 OSGi RSA 实现,其中包括高性能 RMI 分发提供程序。

It certainly is possibly. Check out https://docs.paremus.com//display/NIM20/Home which includes an OSGi RSA implementation that includes a high performance RMI distribution provider.

看轻我的陪伴 2024-08-01 19:30:52

检查 OSGi 规范版本 4.2 中的“远程服务”一章。
它定义了在多个 OSGi 容器之间分发服务的标准方法。

OSGi 规范的全新版本 4.3 对此提供了更详细的支持 - 请参阅第 6 章远程服务和 112 远程服务管理服务。

Check the chapter "Remote Services" in the OSGi specification version 4.2.
It defines a standard way for distributing services between several OSGi containers.

The brand new version 4.3 of the OSGi spec has even more detailed support for this - see chapter 6 Remote Services and 112 Remote Service Admin Service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文