本文介绍了一个OSGi实例中部署了多个捆绑版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在CQ中部署了三个应用程序,它们都依赖于一个捆绑软件(例如核心)。

I have three applications deployed in CQ which all depend on one bundle (say 'core').

Core正在经历重大变革,需要定义所有三个应用程序对不同版本的Core的依赖关系,例如

Core is undergoing a major face lift and there is a requirement to define the dependency of all three application on different versions of core, e.g.


  • A将依赖于核心1.0

  • B将依赖于核心1.5

  • C将依赖于核心2.0

是否可以这样做?

推荐答案

OSGi(已嵌入CQ本身)支持同时部署的多个版本的软件包。您可以部署 core的3个版本,然后在清单中为导入的应用程序请求特定版本:

OSGi (which CQ itself is embedded in) supports multiple versions of packages deployed at the same time. You could deploy the 3 versions of 'core' and then request a specific version in your Manifest for the importing applications:

Import-Package: package.name.of.core;version="1.0"



Bundle B



Bundle B

Import-Package: package.name.of.core;version="1.5"



捆绑C



Bundle C

Import-Package: package.name.of.core;version="2.0"

如果使用的是Maven Bundle插件,则可以通过捆绑包的POM进行相同的操作,以生成正确的Manifest标头:

If you're using the Maven Bundle plugin, you can do the same via your bundle's POM to generate the correct Manifest headers:

<dependency>
    <groupId>group.of.core</groupId>
    <artifactId>core</artifactId>
    <version>2.0.0</version>
</dependency>






您可以在清单中提供绑定版本范围,例如


You could supply a bound version range in your Manifest, e.g.

Import-Package: package.name.of.core;version="[1.0,1.1)"



Bundle B



Bundle B

Import-Package: package.name.of.core;version="[1.5,1.6)"



捆绑C



Bundle C

Import-Package: package.name.of.core;version="[2.0,3.0)"



捆绑C(通过POM )



Bundle C (via POM)

<dependency>
    <groupId>group.of.core</groupId>
    <artifactId>core</artifactId>
    <version>[2.0.0,3.0.0)</version>
</dependency>

这将允许您继承错误修复程序,例如-如果已部署的版本更改为 2.0.1 ,则无需重新编译&

This would allow you to inherit bug fixes for example — if the deployed version changed to 2.0.1, you wouldn't need to recompile & redeploy Bundle C.


  • 方括号[即上面的 []告诉捆绑软件接受所提供的第一个版本。

  • 右括号[即]表示接受最多但不包括所提供的第二个版本。

  • The open-square bracket [i.e. [ ] above tells the bundle to accept from the first version provided.
  • The closing bracket [i.e. ) ] tells it accept up to but excluding the second version provided.

附带说明一下,如果您的依赖项正确地控制了它们自己的版本控制(即遵循 ) ,您应该始终能够提供该版本的范围-从当前版本到下一个主要版本。

As a side note, if your dependencies are controlling their own versioning correctly (i.e. following semantic versioning), you should always be able to supply a range for the version — from the current version up to the next major release.

即在您的情况下,应用程序A也应该能够使用版本1.5,因为次要版本不应包含向后兼容性方面的重大更改。

I.e. in your case, Application A should also be able to use version 1.5, as a minor release shouldn't contain breaking changes in terms of backwards compatibility.

这篇关于一个OSGi实例中部署了多个捆绑版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 08:31