关闭OSGi容器(特别是春分)的最佳方法 [英] Best way to shutdown an OSGi Container (specifically equinox)

查看:83
本文介绍了关闭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联盟的网站上免费获得( http://www.osgi.org /Specifications/HomePage ).

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

这篇关于关闭OSGi容器(特别是春分)的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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