扩展包在 OSGi 框架中的含义

Extension bundle meaning in OSGi framework

我正在开发一个基于 OSGi 的应用程序。在记录 OSGi 框架的特性时,我偶然发现了 extension bundle 概念。引用R4规范(OSGi R4):

Extension bundles can deliver optional parts of the Framework implementation or provide functionality that must reside on the boot class path. These packages cannot be provided by the normal import/export mechanisms. Boot class path extensions are necessary because certain package implementations assume that they are on the boot class path or are required to be available to all clients. An example of a boot class path extension is an implementation of java.sql such as JSR 169

可能只是我太笨了,但我在理解这个概念上遇到了困难。我有几个问题:

  1. 据我了解,扩展包似乎正在做 org.osgi.framework.system.packages.extraorg.osgi.framework.bootdelegation 相同的 工作(即 com.sun.*sun.*)。我对吗?如果不是,它们之间有什么区别?

  2. 你能告诉我扩展包的真实用例场景吗?上面写着:"you can't do it unless you use extension bundles!" Here 有人已经尝试提供扩展包的示例,但(至少对我而言)似乎可以通过调整 org.osgi.framework.system.packages.extra 和 [=11 来获得相同的结果=];

我知道已经有 this SO answer 但对我来说还没有完全切中要害。

感谢大家的热心回复!

扩展包可用于覆盖任何 class,甚至 java.lang classes。

您可能想要跟踪 System.gc() 何时被调用(例如,将堆栈跟踪写入日志文件)