OSGi 包的相对路径

发布于 2024-09-06 02:36:34 字数 370 浏览 7 评论 0原文

我有一个更新程序包,它在特定文件夹“包”中查找并检查要安装的新包并更新当前安装的包。在父目录中,OSGi框架位于“/framework”目录中,更新程序包位于“/system”目录中,需要检查的目录是否是同一父目录中的“/bundles”目录。在更新程序包内,创建了一个具有相对路径的 File 对象,但它不适用于“./bundles”字符串,并且我不知道该路径应该与哪个 jar 文件相关。我将不胜感激有关此问题的任何见解或信息。 谢谢, Deniz

编辑:已经弄清楚了。看起来路径是根据我用来启动 Equinox 的 Ruby 脚本解析的。所以解析路径是一个目录,我通过使用 Ruby 系统传递一个“-console”标志来启动 Equinox。 感谢您的回答,德尼兹

I have a updater bundle that lookups in a specific folder "bundle" and checks for new bundles to install and updates for currently installed bundles. Inside a parent directory, OSGi framework is in the "/framework" directory, updater bundle is in the "/system" directory and the directory needs to be checked is the "/bundles" directory in the same parent directory. Inside the updater bundle, a File object with a relative path is created but it's not working with the "./bundles" string, and i dont know which jar file the path is supposed to be relative with. I would appreciate any insight or information about this problem..
Thanks,
Deniz

Edit: Already figured out. Looks like path is resolved according to the Ruby script i use to start Equinox. So resolution path is a directory i start Equinox by passing it a "-console" flag using Ruby system.
Thanks for answers, Deniz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

混吃等死 2024-09-13 02:36:34

执行 new File("./bundles") 针对当前工作目录解析

您可以通过自己获取输入流并调用 BundleContext#installBundle(String, InputStream) 来安装捆绑包。

OSGi 本身不对文件系统布局做出任何假设,也不假设捆绑包甚至位于磁盘上。
但如果您使用 Equinox 作为框架,您可以解析“osgi.install.area”的相对路径。 位置服务可以为您提供此信息。然后使用绝对路径来安装捆绑包。

或者,您可以获取系统捆绑包 (BundleContext.getBundle(0)),并使用 FileLocator(来自 org.eclipse.equinox.common)在磁盘上查找它。

Doing new File("./bundles") resolves against the current working directory.

You can install your bundle by getting an input stream yourself and calling BundleContext#installBundle(String, InputStream).

OSGi itself makes no assumptions about filesystem layout, or that bundles are even on disk.
But if you are using Equinox as your framework you can resolve your relative paths against the "osgi.install.area". The Location service can give you this. And then use the absolute path to install the bundle.

Or, you can get the System Bundle (BundleContext.getBundle(0)), and use FileLocator (from org.eclipse.equinox.common) to find it on disk.

眼泪都笑了 2024-09-13 02:36:34

取决于您的 OSGi 配置和实现。它可能与许多地方相关,最有可能的是框架位置。为什么不通过使用相对路径创建文件来进行测试,并检查希望

new File("./bundles").getAbsolutePath();

这会有所帮助。

Depends on your OSGi configuration and implementation. It could be relative to a number of places, the most likely one being the framework location. Why don't you test by creating your File with a relative path, and the checking the value of

new File("./bundles").getAbsolutePath();

Hope this helps.

情归归情 2024-09-13 02:36:34

已经想通了。看起来路径是根据我用来启动 Equinox 的 Ruby 脚本解析的。所以解析路径是一个目录,我通过使用 Ruby 系统传递一个“-console”标志来启动 Equinox。
感谢您的回答,德尼兹

Already figured out. Looks like path is resolved according to the Ruby script i use to start Equinox. So resolution path is a directory i start Equinox by passing it a "-console" flag using Ruby system.
Thanks for answers, Deniz

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文