OSGI Embedded Equinox - 用于访问未在 osgi 框架中实例化的 pojo 的捆绑包

发布于 2024-12-25 17:17:25 字数 313 浏览 0 评论 0原文

我有一个服务器端应用程序,想要嵌入一个 osgi 框架以进行动态包加载。
假设我想公开一个实现 IQuote 的 QuoteImpl(实例化为服务器容器引导/Spring 的一部分)以供不同的 Bundle 使用。

Q1.是否有一种干净的方法将服务器应用程序实例公开给 Bundles ? (顺便说一句,由于遗留问题,不可能将服务器代码放入捆绑包中:)并且不想使整个应用程序 osgi'ed。

尝试通过服务公开并捆绑以投射到 IQuote 中。不确定我做得很好,但由于未解决的编译问题而失败,因为 IQuote 驻留在核心应用程序项目中,而不是捆绑项目中。有什么想法吗?

I have a server side application and want to embed an osgi framework into for dynamic bundle loading.
Suppose I want to expose a QuoteImpl implementing IQuote(instantiated as part of the server container bootstrap/Spring) to be used by different Bundles.

Q1. Is there a clean way of exposing server-application instances to Bundles ? (btw because of legacy it is not possible to make server code into bundle :) and donot want to make entire application osgi'ed.

Tried exposing via a service and bundle to cast into an IQuote. Not sure I am doing it well but fails with unresolved compilation problems as IQuote resides in the core app projects as opposed to the bundle project. any ideas?

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

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

发布评论

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

评论(2

究竟谁懂我的在乎 2025-01-01 17:17:25

是的,做到这一点的方法是使用服务。 “主机”应用程序将发布服务,OSGi 内的捆绑包将以正常方式使用该服务。

实现此功能的关键是主机应用程序必须通过系统捆绑导出来导出服务 API(即包含 IQuote 的包)。您可以在创建嵌入式 OSGi 框架时通过设置 org.osgi.framework.system.packages.extra 属性来控制这一点。我就这个主题写了一篇博客文章,应该可以帮助您入门(查找标题“公开应用程序包”)。

你说你有编译问题。要解决这些问题,有必要了解如何构建项目和构建系统。

Yes the way to do this is with a service. The "host" application would publish the service and the bundles inside OSGi would consume the service in the normal way.

The key to get this working is that the service API (i.e. the package containing IQuote) must be exported by the host application through the system bundle exports. You can control this by setting the org.osgi.framework.system.packages.extra property when you create the embedded OSGi framework. I wrote a blog post on this subject that should help you get started (look for the heading "Exposing Application Packages").

You state that you have compilation problems. To fix those it's necessary to know how you have structured your projects and build system.

等你爱我 2025-01-01 17:17:25

这就是我在 Java 类中嵌入 Equinox OSGi 运行时的方式。我想你也可以这样做。 https:/ /github.com/sarxos/equinox-launcher/blob/master/src/main/java/com/github/sarxos/equinox/Launcher.java

This is how I embedded Equinox OSGi runtime in my Java class. I suppose you could do the same. https://github.com/sarxos/equinox-launcher/blob/master/src/main/java/com/github/sarxos/equinox/Launcher.java

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