捆绑OSGi依赖库的标准方法是什么? [英] What is the standard way to bundle OSGi dependent libraries?

查看:110
本文介绍了捆绑OSGi依赖库的标准方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目引用了许多开源库,一些是新的,一些不是那么新。也就是说,它们都很稳定,我希望坚持使用我选择的版本,直到我有时间迁移到更新的版本(我昨天测试了hsqldb 2.0,它包含许多api更改)。

I have a project that references a number of open source libraries, some new, some not so new. That said, they are all stable and I wish to stick with my chosen versions until I have time to migrate to the newer versions (I tested hsqldb 2.0 yesterday and it contains many api changes).

我希望嵌入的其中一个库是Jasper Reports,但是你们肯定知道,它附带了一大堆支持jar文件,我只需要山的一部分(已知)因此我是计划自定义捆绑我所有的依赖库。

One of the libraries I have wish to embed is Jasper Reports, but as you all surely know, it comes with a mountain of supporting jar files and I have only need a subset of the mountain (known) therefore I am planning to custom bundle all of my dependant libraries.

所以:


  • 是否每个人都为他们正在使用的开源库定制自己的OSGi包,或者是OSGi版本的公共库的主要来源吗?

  • Does everyone custom-make their own OSGi bundles for open-source libraries they are using or is there a master source of OSGi versions of common libraries?

此外,我认为我的每个捆绑包只是简单地将其依赖的jar嵌入捆绑包本身就会简单得多。这可能吗?如果我选择在一个包中嵌入第三方foc库,我假设我需要生成2个jar文件,一个没有嵌入式库(用于通过类路径通过标准类加载器加载的库),以及一个包含的osgi版本嵌入式库,因此我应该选择这样的包名<< myprojectname>> - << subproject>> -osgi-.1.0.0.jar?

Also, I was thinking that it would be far simpler for each of my bundles simply to embed their dependent jars within the bundle itself. Is this possible? If I choose to embed the 3rd party foc libraries within a bundle, I assume I will need to produce 2 jar files, one without the embedded libraries (for libraries to be loaded via the classpath via standard classloader), and one osgi version that includes the embedded libraryy, therefore should I choose a bundle name like this <<myprojectname>>-<<subproject>>-osgi-.1.0.0.jar ?

如果我无法嵌入开源库并选择自定义捆绑开源库(通过bnd),我应该选择一个唯一的捆绑名称以避免与可能的官方捆绑冲突吗?例如<< myprojectname>> - <<< 3rdpartylibname>> - <<< 3rdpartylibversion>> .jar?

If I cannot embed the open source libraries and choose to custom bundle the open source libraries (via bnd), should I choose a unique bundle name to avoid conflict with a possible official bundle? e.g. <<myprojectname>>-<<3rdpartylibname>>-<<3rdpartylibversion>>.jar ?

我的非OSGi启用的项目当前通过Service.providers(...)扫描我的各种插件罐中的META-INF文件夹来扫描自定义插件。如果我去OSGi,这个机制还能运作吗?

My non-OSGi enabled project currently scans for custom plugins via scanning the META-INF folders in my various plugin jars via Service.providers(...). If I go OSGi, will this mechanism still work?

推荐答案

我更喜欢不嵌入依赖的罐子(是的,这是可能的)。它会导致两个问题,

I prefer to not embed the dependent jars (yes it is possible). It causes two problems,

1)没有重用此代码。许多捆绑包可能只是做同样的事情(嵌入相同的jar),你最终安装了多次相同的jar。您可以争辩说,您的软件包也可以导出嵌入式jar的接口,但这很难看,因为它不应该是您的捆绑责任来公开该代码。它还使得暴露库的多个版本或同一版本的多个提供者更容易。

1) There is no reuse of this code. Many bundles may simply do the same thing (embed the same jar) and you end up with the same jar installed many times. You can argue that your bundle can export the interfaces for the embedded jar as well, but this gets ugly since it should not be your bundles responsibility to expose that code. It also makes it easier to have multiple versions of the library exposed, or multiple providers of the same version.

2)这是特定于Eclipse的 - 嵌入式jar不在开发环境中正确解析(仍然在运行时工作)。我的捆绑包可能依赖于我的目标平台中的捆绑包,它将无法解析嵌入式jar中的元素,必须将它们导入工作区才能工作。

2) This is Eclipse specific - The embedded jars don't resolve properly in the development environment (still works at runtime). My bundle may depend on a bundle in my target platform, and it will fail to resolve elements in the embedded jars, they have to be imported into the workspace to work.

我发现大多数开源jar已经很好地由Spring的好朋友捆绑。还有其他的回购,但不幸的是我丢失了他们的链接。

I have found that most open source jars have already been kindly bundled by the nice folks at Spring. There are other repos available as well, but unfortunately I lost my links to them.

这篇关于捆绑OSGi依赖库的标准方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆