有什么方法可以制作 Knoplerfish 所需的捆绑包吗?
如果特定包无法初始化,是否有任何方法可以中止 Knoplerfish 的启动?默认情况下,FrameworkErrorEvent 会打印到控制台,并且框架会继续加载。
init.xargs
-initlevel 80
-istart my-required-bundle.jar
控制台输出
[stdout] Installed and started: file:jars/my-required-bundle.jar (id#34)
[stdout] ## DEBUG: errors - FrameworkErrorEvent bundle #34
[stdout] ## DEBUG: errors - FrameworkErrorEvent throwable:
[stderr] org.osgi.framework.BundleException: BundleActivator start failed
Is there any way to abort the startup of Knoplerfish if a specific bundle fails to initialize? By default, a FrameworkErrorEvent is printed to the console and the framework continues to load.
init.xargs
-initlevel 80
-istart my-required-bundle.jar
console output
[stdout] Installed and started: file:jars/my-required-bundle.jar (id#34)
[stdout] ## DEBUG: errors - FrameworkErrorEvent bundle #34
[stdout] ## DEBUG: errors - FrameworkErrorEvent throwable:
[stderr] org.osgi.framework.BundleException: BundleActivator start failed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有标准的 OSGi 方法可以做到这一点,因为没有标准的方法来告诉框架要安装哪些捆绑包(这取决于启动器)。也没有标准方法来获取此事件的通知,因此您可以采取行动。如果 Knopflerfish 没有提供特定的系统属性或类似的东西来处理这个问题,我看到您可以采取两种路线。
BundleContext
来安装捆绑包。然后,您可以捕获来自包的start()
方法的BundleException
,并在类型为RESOLVE_ERROR
时中止启动。BundleContext
获取所有当前安装的捆绑包的列表)。如果其中之一未处于状态INSTALLED
,您可以通过停止系统捆绑包(即捆绑包 0)来停止框架。There is no standard OSGi way to do this, since there is no standard way to tell the framework what bundles to install (that is up to a launcher). There is also no standard way to get notified of this event, so you can act on it. If Knopflerfish does not provide a specific system property or something similar to handle this, I see two routes you could take.
org.knopflerfish.framework.Main
, configure it (there is some information in the readme on this), and install the bundles by getting aBundleContext
from the framework. You can then catchBundleException
s that come from the bundle'sstart()
method, and abort the startup when it has typeRESOLVE_ERROR
.BundleContext
). If one of them is not in stateINSTALLED
, you can stop the framework by stopping the system bundle (i.e., bundle 0).