寻求有关使用 Blueprint 以编程方式访问 ServiceMix 捆绑包状态信息的指导

发布于 2025-01-08 11:33:27 字数 649 浏览 0 评论 0原文

我们正在运行 Apache ServiceMix 4 ESB,它运行 Apache Karaf 基于 OSGi 的容器。 OSGi 提供了在 ServiceMix 控制台中公开的工具,报告有关 的信息容器中安装的捆绑包的状态

osgi:list

我已经搜索了很多。现在我问:有谁知道任何工作示例、使用 API 的指南或其他从 ESB 中运行的代码访问此信息的指南吗?理想情况下,我想:

  1. 确定安装了哪些捆绑包;
  2. 监控已识别包的状态;并且至少
  3. 动态停止/卸载并启动/重新安装已识别的捆绑包,

请分享与此相关的任何可用信息,或者只是开始更好地研究它的任何途径。

谢谢。

We are running Apache ServiceMix 4 ESB which runs an Apache Karaf container based on OSGi. OSGi offers facilities, which are exposed in the ServiceMix console, that report information on the state of bundles installed in the container:

osgi:list

I've searched high and low. Now I'm asking: Does anyone know of any working examples, guides on using the API or other guidance in accessing this information from within code running in the ESB? Ideally, I would like to:

  1. Identify which bundles are installed;
  2. Monitor the state of the identified bundle; and, at least,
  3. Dynamically stop/uninstall and start/re-install the identified bundle,

Please share any information available on this, or just any avenues from which to start better researching it.

Thanks.

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

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

发布评论

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

评论(1

伴随着你 2025-01-15 11:33:27

蓝图对此的用途有限,因为蓝图根据定义是声明性的,并且您希望以编程方式执行某些操作。但是,Blueprint 可以通过注入 bundle 上下文来帮助您按自己的方式进行操作。有了捆绑上下文后,您可以使用 org.osgi.framework API 用于获取所有包 (context.getBundles())、查询它们的状态、启动和停止它们等等。

您的要求 3)(加载捆绑包)在 OSGi 上下文中实际上没有意义,因为它们的生命周期是安装然后启动。如果尚未安装捆绑包,则它不会包含在 getBundles() 中,但可以使用上下文进行安装。

要将上下文注入 Blueprint bean,请使用特殊属性:

<bean class="SomeClass">
    <property name="context" ref="blueprintBundleContext"/>
</bean>

我从 Enterprise OSGi in Action< 中借用了该示例/a>,但是在developerWorks 上有一个非常好的蓝图教程:http://www.ibm.com/developerworks/opensource/library/os-osgiblueprint/

最近有人提出了类似的问题,您可能也会发现它很有用: 我应该如何将 OSGi 控制台实现为Bundle?ssbundle:list 类似,尽管它不提供任何特定于蓝图的信息)。

Blueprint is of limited use for this, since Blueprint is by definition declarative and you want to do something programatically. However, Blueprint can set you on your way by injecting a bundle context. Once you have a bundle context you can use the org.osgi.framework APIs to get all the bundles (context.getBundles()), query their state, start and stop them, and so on.

Your requirement 3), loading a bundle, doesn't really make sense in an OSGi context, since their lifecycle is that they get installed and then started. If a bundle hasn't been installed it won't be included in getBundles(), but it can be installed using the context.

To inject the context into a Blueprint bean, use a special property:

<bean class="SomeClass">
    <property name="context" ref="blueprintBundleContext"/>
</bean>

I've borrowed that example from Enterprise OSGi in Action, but there's a very good Blueprint tutorial on developerWorks: http://www.ibm.com/developerworks/opensource/library/os-osgiblueprint/

A similar question was asked recently, which you may also find useful: How should I implement the OSGi console into a Bundle? (ss is similar to bundle:list, although it doesn't give any Blueprint-specific information).

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