简体   繁体   English

OSGi-获取捆绑包文件名(* .jar)

[英]OSGi - get bundle filename (*.jar)

Let's suppose I have Bundle bundle=...; 假设我有Bundle bundle=...; Can I get this OSGi bundle's filename? 我可以获取此OSGi捆绑包的文件名吗? I've searched but didn't find anything. 我已经搜索了,但没有找到任何东西。 The only thing I can do now is to get bundle symbolic name via headers, but it's not filename as symbolic name is set in manifest and can be not equal to filename. 我现在唯一能做的就是通过标题获取捆绑包的符号名,但是它不是文件名,因为符号名是在清单中设置的,并且不能等于文件名。

The answer, in general, is no. 答案通常是“否”。 The OSGi specification does not require that the framework preserve the jar file. OSGi规范不要求框架保留jar文件。 For example, an OSGi framework implementation can expand the jar file into the file system or put the contents in a database. 例如,OSGi框架实现可以将jar文件扩展到文件系统中,或将内容放入数据库中。 It is free to store the bundle contents in any way it desires. 可以以任何所需的方式自由存储分发包内容。

Implementation of the OSGi framework may provide non-standard ways to locate the jar, if it still exists. OSGi框架的实现可能会提供非标准的方式来定位jar,如果它仍然存在的话。 I believe Equinox provides a FileLocator service which can be used for this. 我相信Equinox提供了可用于此目的的FileLocator服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM