Extension bundle meaning in OSGi framework

被刻印的时光 ゝ 提交于 2019-12-10 18:54:52

问题


I'm developing an OSGi based application. While documenting myself on the features of the OSGi framework I stumbled on the extension bundle concept. Citing the R4 specification (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

Probably it's just me being stupid, but I'm having difficulties on understanding the concept. I have several questions:

  1. From what I understood it seems that extension bundles are doing the same work of org.osgi.framework.system.packages.extra and org.osgi.framework.bootdelegation(i.e. com.sun.* or sun.*). Am I right? If not, what are the differences between them?

  2. Can you show me a real use case scenario for extension bundles? Something that says: "you can't do it unless you use extension bundles!" Here someone already tried to provide an example for extension bundles but (at least for me) it seems one can achieve the same result by tweaking org.osgi.framework.system.packages.extra and org.osgi.framework.bootdelegation;

I know there is already this SO answer but to me it didn't fully hit the point.

Thanks for all kind replies!


回答1:


extension bundles can be used to override any class, even java.lang classes.

You might want to trace when System.gc() is called for example (e.g. write a stack trace to a log file)



来源:https://stackoverflow.com/questions/39868428/extension-bundle-meaning-in-osgi-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!