关闭OSGi容器(特别是春分)的最佳方法

编程入门 行业动态 更新时间:2024-10-28 01:22:35
本文介绍了关闭OSGi容器(特别是春分)的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找关闭OSGi容器的最佳实践.

I'm looking for a best practice on shutting down an OSGi container.

当前,我们正在使用一个小的启动器应用程序,该应用程序将调用EclipseStarter.startup()并安装一些核心捆绑包.之后发射器终止.

Currently we are using a small launcher app which calls EclipseStarter.startup() and installs some core bundles. After that the launcher terminates.

当关闭测试GUI(作为捆绑包运行)时,它将调用System.exit(0)关闭容器,但是必须有一个比这更优雅的解决方案.

When the test GUI (running as a bundle) is closed it calls a System.exit(0) to shutdown the container, but there must be a more elegant solution than this.

谢谢

推荐答案

请不要使用System.exit(0)关闭OSGi框架.您应该通过停止ID为0的捆绑包(系统捆绑包)来实现.这样,您就可以为所有捆绑包有序关闭的机会(例如释放资源等).

Please, don't use System.exit(0) to shut down an OSGi framework. You should to it by stopping the bundle with the ID 0, the System bundle. This way, you give all bundles a chance to shut down in an orderly manner (e.g. to free resources etc).

OSGi规范定义了以下内容(核心规范,R4.x,4.2.6停止框架).

The OSGi specification defines the following (Core Specification, R4.x, 4.2.6 Stopping a Framework).

可以通过停止系统捆绑包或在框架对象上调用stop方法来启动关机.

Shutdown can be initiated by stopping the system bundle, [...] or calling the stop method on the framework object.

在该章中,给出了关闭框架时发生的详细描述.

In that chapter a detailed description is given what happens when a framework is shut down.

系统捆绑包响应.框架对象也已定义(第4.6章系统捆绑包):

The system bundle resp. the framework object is also defined (chapter 4.6 The System Bundle):

启动框架时,系统捆绑包类似于框架对象,但是不需要实现将相同的对象用于框架对象和系统捆绑包.但是,两个对象都必须具有束ID 0,相同的位置和束符号名称.

The system bundle resembles the framework object when a framework is launched, but implementations are not required to use the same object for the framework object and the system bundle. However, both objects must have bundle id 0, same location, and bundle symbolic name.

OSGi规范可在OSGi联盟的网站上免费获得( www.osgi /Specifications/HomePage ).

The OSGi spec is available for free at the OSGi Alliance's website (www.osgi/Specifications/HomePage).

更多推荐

关闭OSGi容器(特别是春分)的最佳方法

本文发布于:2023-10-07 17:02:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469965.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:春分   容器   方法   OSGi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!